Search in sources :

Example 96 with SyncopeClientException

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);
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) SchedulerException(org.quartz.SchedulerException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 97 with SyncopeClientException

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;
}
Also used : SchedulerException(org.quartz.SchedulerException) Report(org.apache.syncope.core.persistence.api.entity.Report) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) JobTO(org.apache.syncope.common.lib.to.JobTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 98 with SyncopeClientException

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)));
}
Also used : DuplicateException(org.apache.syncope.core.persistence.api.dao.DuplicateException) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 99 with SyncopeClientException

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)));
}
Also used : DuplicateException(org.apache.syncope.core.persistence.api.dao.DuplicateException) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 100 with SyncopeClientException

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));
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)240 Test (org.junit.jupiter.api.Test)105 UserTO (org.apache.syncope.common.lib.to.UserTO)50 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)42 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)40 Response (javax.ws.rs.core.Response)34 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)20 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)19 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)18 Realm (org.apache.syncope.core.persistence.api.entity.Realm)18 GroupTO (org.apache.syncope.common.lib.to.GroupTO)17 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)16 AttrTO (org.apache.syncope.common.lib.to.AttrTO)15 Map (java.util.Map)14 SyncopeClientCompositeException (org.apache.syncope.common.lib.SyncopeClientCompositeException)14 ArrayList (java.util.ArrayList)12 List (java.util.List)12 ItemTO (org.apache.syncope.common.lib.to.ItemTO)12 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)11