use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class ReportLogic method create.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_CREATE + "')")
public ReportTO create(final ReportTO reportTO) {
Report report = entityFactory.newEntity(Report.class);
binder.getReport(report, reportTO);
report = reportDAO.save(report);
try {
jobManager.register(report, null, confDAO.find("tasks.interruptMaxRetries", 1L));
} catch (Exception e) {
LOG.error("While registering quartz job for report " + report.getKey(), e);
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
sce.getElements().add(e.getMessage());
throw sce;
}
return binder.getReportTO(report);
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class ReportLogic method getJob.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_READ + "')")
@Override
public JobTO getJob(final String key) {
Report report = reportDAO.find(key);
if (report == null) {
throw new NotFoundException("Report " + key);
}
JobTO jobTO = null;
try {
jobTO = getJobTO(JobNamer.getJobKey(report));
} catch (SchedulerException e) {
LOG.error("Problems while retrieving scheduled job {}", JobNamer.getJobKey(report), e);
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
sce.getElements().add(e.getMessage());
throw sce;
}
if (jobTO == null) {
throw new NotFoundException("Job for report " + key);
}
return jobTO;
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class AnyTypeClassLogic method create.
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPECLASS_CREATE + "')")
public AnyTypeClassTO create(final AnyTypeClassTO anyTypeClassTO) {
if (StringUtils.isBlank(anyTypeClassTO.getKey())) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
sce.getElements().add(AnyTypeClass.class.getSimpleName() + " name");
throw sce;
}
if (anyTypeClassDAO.find(anyTypeClassTO.getKey()) != null) {
throw new DuplicateException(anyTypeClassTO.getKey());
}
return binder.getAnyTypeClassTO(anyTypeClassDAO.save(binder.create(anyTypeClassTO)));
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class AnyTypeLogic method create.
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_CREATE + "')")
public AnyTypeTO create(final AnyTypeTO anyTypeTO) {
if (StringUtils.isBlank(anyTypeTO.getKey())) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
sce.getElements().add(AnyType.class.getSimpleName() + " key");
throw sce;
}
if (anyTypeDAO.find(anyTypeTO.getKey()) != null) {
throw new DuplicateException(anyTypeTO.getKey());
}
return binder.getAnyTypeTO(anyTypeDAO.save(binder.create(anyTypeTO)));
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class ConnectorLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_UPDATE + "')")
public ConnInstanceTO update(final ConnInstanceTO connInstanceTO) {
if (connInstanceTO.getAdminRealm() == null) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
sce.getElements().add("Invalid or null realm specified: " + connInstanceTO.getAdminRealm());
throw sce;
}
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.CONNECTOR_UPDATE), connInstanceTO.getAdminRealm());
securityChecks(effectiveRealms, connInstanceTO.getAdminRealm(), connInstanceTO.getKey());
return binder.getConnInstanceTO(binder.update(connInstanceTO));
}
Aggregations