List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getRootCauseMessage
public static String getRootCauseMessage(final Throwable th)
From source file:org.apache.syncope.core.provisioning.java.pushpull.RealmPushResultHandlerImpl.java
private void doHandle(final Realm realm) throws JobExecutionException { ProvisioningReport result = new ProvisioningReport(); profile.getResults().add(result);/*from ww w.j a va 2 s . co m*/ result.setKey(realm.getKey()); result.setAnyType(REALM_TYPE); result.setName(realm.getFullPath()); LOG.debug("Propagating Realm with key {} towards {}", realm.getKey(), profile.getTask().getResource()); Object output = null; Result resultStatus = null; String operation = null; // Try to read remote object BEFORE any actual operation ConnectorObject beforeObj = getRemoteObject(realm.getName(), profile.getConnector(), profile.getTask().getResource().getOrgUnit()); if (profile.isDryRun()) { if (beforeObj == null) { result.setOperation(getResourceOperation(profile.getTask().getUnmatchingRule())); } else { result.setOperation(getResourceOperation(profile.getTask().getMatchingRule())); } result.setStatus(ProvisioningReport.Status.SUCCESS); } else { try { if (beforeObj == null) { operation = UnmatchingRule.toEventName(profile.getTask().getUnmatchingRule()); result.setOperation(getResourceOperation(profile.getTask().getUnmatchingRule())); switch (profile.getTask().getUnmatchingRule()) { case ASSIGN: for (PushActions action : profile.getActions()) { action.beforeAssign(this.getProfile(), realm); } if (!profile.getTask().isPerformCreate()) { LOG.debug("PushTask not configured for create"); } else { assign(realm); } break; case PROVISION: for (PushActions action : profile.getActions()) { action.beforeProvision(this.getProfile(), realm); } if (!profile.getTask().isPerformCreate()) { LOG.debug("PushTask not configured for create"); } else { provision(realm); } break; case UNLINK: for (PushActions action : profile.getActions()) { action.beforeUnlink(this.getProfile(), realm); } if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { link(realm, true); } break; case IGNORE: LOG.debug("Ignored any: {}", realm); break; default: // do nothing } } else { operation = MatchingRule.toEventName(profile.getTask().getMatchingRule()); result.setOperation(getResourceOperation(profile.getTask().getMatchingRule())); switch (profile.getTask().getMatchingRule()) { case UPDATE: for (PushActions action : profile.getActions()) { action.beforeUpdate(this.getProfile(), realm); } if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { update(binder.getRealmTO(realm)); } break; case DEPROVISION: for (PushActions action : profile.getActions()) { action.beforeDeprovision(this.getProfile(), realm); } if (!profile.getTask().isPerformDelete()) { LOG.debug("PushTask not configured for delete"); } else { deprovision(realm); } break; case UNASSIGN: for (PushActions action : profile.getActions()) { action.beforeUnassign(this.getProfile(), realm); } if (!profile.getTask().isPerformDelete()) { LOG.debug("PushTask not configured for delete"); } else { unassign(realm); } break; case LINK: for (PushActions action : profile.getActions()) { action.beforeLink(this.getProfile(), realm); } if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { link(realm, false); } break; case UNLINK: for (PushActions action : profile.getActions()) { action.beforeUnlink(this.getProfile(), realm); } if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { link(realm, true); } break; case IGNORE: LOG.debug("Ignored any: {}", realm); break; default: // do nothing } } for (PushActions action : profile.getActions()) { action.after(this.getProfile(), realm, result); } result.setStatus(ProvisioningReport.Status.SUCCESS); resultStatus = AuditElements.Result.SUCCESS; output = getRemoteObject(realm.getName(), profile.getConnector(), profile.getTask().getResource().getOrgUnit()); } catch (IgnoreProvisionException e) { throw e; } catch (Exception e) { result.setStatus(ProvisioningReport.Status.FAILURE); result.setMessage(ExceptionUtils.getRootCauseMessage(e)); resultStatus = AuditElements.Result.FAILURE; output = e; LOG.warn("Error pushing {} towards {}", realm, profile.getTask().getResource(), e); for (PushActions action : profile.getActions()) { action.onError(this.getProfile(), realm, result, e); } throw new JobExecutionException(e); } finally { notificationManager.createTasks(AuditElements.EventCategoryType.PUSH, REALM_TYPE.toLowerCase(), profile.getTask().getResource().getKey(), operation, resultStatus, beforeObj, output, realm); auditManager.audit(AuditElements.EventCategoryType.PUSH, REALM_TYPE.toLowerCase(), profile.getTask().getResource().getKey(), operation, resultStatus, beforeObj, output, realm); } } }
From source file:org.apache.syncope.core.provisioning.java.sync.AbstractPushResultHandler.java
protected final void doHandle(final Any<?, ?, ?> any) throws JobExecutionException { AnyUtils anyUtils = anyUtilsFactory.getInstance(any); ProvisioningResult result = new ProvisioningResult(); profile.getResults().add(result);/*from w w w . j a va 2s. c o m*/ result.setKey(any.getKey()); result.setAnyType(any.getType().getKey()); result.setName(getName(any)); Boolean enabled = any instanceof User && profile.getTask().isSyncStatus() ? ((User) any).isSuspended() ? Boolean.FALSE : Boolean.TRUE : null; LOG.debug("Propagating {} with key {} towards {}", anyUtils.getAnyTypeKind(), any.getKey(), profile.getTask().getResource()); Object output = null; Result resultStatus = null; String operation = null; // Try to read remote object BEFORE any actual operation Provision provision = profile.getTask().getResource().getProvision(any.getType()); String connObjecKey = MappingUtils.getConnObjectKeyValue(any, provision); ConnectorObject beforeObj = getRemoteObject(connObjecKey, provision.getObjectClass()); Boolean status = profile.getTask().isSyncStatus() ? enabled : null; if (profile.isDryRun()) { if (beforeObj == null) { result.setOperation(getResourceOperation(profile.getTask().getUnmatchingRule())); } else { result.setOperation(getResourceOperation(profile.getTask().getMatchingRule())); } result.setStatus(ProvisioningResult.Status.SUCCESS); } else { try { if (beforeObj == null) { operation = UnmatchingRule.toEventName(profile.getTask().getUnmatchingRule()); result.setOperation(getResourceOperation(profile.getTask().getUnmatchingRule())); switch (profile.getTask().getUnmatchingRule()) { case ASSIGN: for (PushActions action : profile.getActions()) { action.beforeAssign(this.getProfile(), any); } if (!profile.getTask().isPerformCreate()) { LOG.debug("PushTask not configured for create"); } else { assign(any, status); } break; case PROVISION: for (PushActions action : profile.getActions()) { action.beforeProvision(this.getProfile(), any); } if (!profile.getTask().isPerformCreate()) { LOG.debug("PushTask not configured for create"); } else { provision(any, status); } break; case UNLINK: for (PushActions action : profile.getActions()) { action.beforeUnlink(this.getProfile(), any); } if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { link(any, true); } break; case IGNORE: LOG.debug("Ignored any: {}", any); break; default: // do nothing } } else { operation = MatchingRule.toEventName(profile.getTask().getMatchingRule()); result.setOperation(getResourceOperation(profile.getTask().getMatchingRule())); switch (profile.getTask().getMatchingRule()) { case UPDATE: for (PushActions action : profile.getActions()) { action.beforeUpdate(this.getProfile(), any); } if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { update(any, status); } break; case DEPROVISION: for (PushActions action : profile.getActions()) { action.beforeDeprovision(this.getProfile(), any); } if (!profile.getTask().isPerformDelete()) { LOG.debug("PushTask not configured for delete"); } else { deprovision(any); } break; case UNASSIGN: for (PushActions action : profile.getActions()) { action.beforeUnassign(this.getProfile(), any); } if (!profile.getTask().isPerformDelete()) { LOG.debug("PushTask not configured for delete"); } else { unassign(any); } break; case LINK: for (PushActions action : profile.getActions()) { action.beforeLink(this.getProfile(), any); } if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { link(any, false); } break; case UNLINK: for (PushActions action : profile.getActions()) { action.beforeUnlink(this.getProfile(), any); } if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { link(any, true); } break; case IGNORE: LOG.debug("Ignored any: {}", any); break; default: // do nothing } } for (PushActions action : profile.getActions()) { action.after(this.getProfile(), any, result); } result.setStatus(ProvisioningResult.Status.SUCCESS); resultStatus = AuditElements.Result.SUCCESS; output = getRemoteObject(connObjecKey, provision.getObjectClass()); } catch (IgnoreProvisionException e) { throw e; } catch (Exception e) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(ExceptionUtils.getRootCauseMessage(e)); resultStatus = AuditElements.Result.FAILURE; output = e; LOG.warn("Error pushing {} towards {}", any, profile.getTask().getResource(), e); for (PushActions action : profile.getActions()) { action.onError(this.getProfile(), any, result, e); } throw new JobExecutionException(e); } finally { notificationManager.createTasks(AuditElements.EventCategoryType.PUSH, any.getType().getKind().name().toLowerCase(), profile.getTask().getResource().getKey(), operation, resultStatus, beforeObj, output, any); auditManager.audit(AuditElements.EventCategoryType.PUSH, any.getType().getKind().name().toLowerCase(), profile.getTask().getResource().getKey(), operation, resultStatus, beforeObj, output, any); } } }
From source file:org.apache.syncope.core.provisioning.java.sync.AbstractSyncResultHandler.java
private void create(final AnyTO anyTO, final SyncDelta delta, final String operation, final ProvisioningResult result) throws JobExecutionException { Object output;// ww w . j a v a 2s . com Result resultStatus; try { AnyTO actual = doCreate(anyTO, delta, result); result.setName(getName(actual)); output = actual; resultStatus = Result.SUCCESS; for (SyncActions action : profile.getActions()) { action.after(this.getProfile(), delta, actual, result); } } catch (IgnoreProvisionException e) { throw e; } catch (PropagationException e) { // A propagation failure doesn't imply a synchronization failure. // The propagation exception status will be reported into the propagation task execution. LOG.error("Could not propagate {} {}", anyTO.getType(), delta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), delta, result, e); } } catch (Exception e) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(ExceptionUtils.getRootCauseMessage(e)); LOG.error("Could not create {} {} ", anyTO.getType(), delta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), delta, result, e); } } audit(operation, resultStatus, null, output, delta); }
From source file:org.apache.syncope.core.provisioning.java.sync.AbstractSyncResultHandler.java
protected List<ProvisioningResult> update(final SyncDelta delta, final List<Long> anys, final Provision provision) throws JobExecutionException { if (!profile.getTask().isPerformUpdate()) { LOG.debug("SyncTask not configured for update"); return Collections.<ProvisioningResult>emptyList(); }/* ww w . j a va 2 s . c om*/ LOG.debug("About to update {}", anys); List<ProvisioningResult> results = new ArrayList<>(); SyncDelta workingDelta = delta; for (Long key : anys) { LOG.debug("About to update {}", key); ProvisioningResult result = new ProvisioningResult(); result.setOperation(ResourceOperation.UPDATE); result.setAnyType(provision.getAnyType().getKey()); result.setStatus(ProvisioningResult.Status.SUCCESS); result.setKey(key); AnyTO before = getAnyTO(key); if (before == null) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(String.format("Any '%s(%d)' not found", provision.getAnyType().getKey(), key)); } else { result.setName(getName(before)); } Result resultStatus; Object output; if (!profile.isDryRun()) { if (before == null) { resultStatus = Result.FAILURE; output = null; } else { try { AnyMod anyMod = connObjectUtils.getAnyMod(before.getKey(), workingDelta.getObject(), before, profile.getTask(), provision, getAnyUtils()); // Attribute value transformation (if configured) AnyMod actual = anyTransformer.transform(anyMod); LOG.debug("Transformed: {}", actual); for (SyncActions action : profile.getActions()) { workingDelta = action.beforeUpdate(this.getProfile(), workingDelta, before, anyMod); } AnyTO updated = doUpdate(before, anyMod, workingDelta, result); for (SyncActions action : profile.getActions()) { action.after(this.getProfile(), workingDelta, updated, result); } output = updated; resultStatus = Result.SUCCESS; result.setName(getName(updated)); LOG.debug("{} {} successfully updated", provision.getAnyType().getKey(), key); } catch (IgnoreProvisionException e) { throw e; } catch (PropagationException e) { // A propagation failure doesn't imply a synchronization failure. // The propagation exception status will be reported into the propagation task execution. LOG.error("Could not propagate {} {}", provision.getAnyType().getKey(), workingDelta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), workingDelta, result, e); } } catch (Exception e) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(ExceptionUtils.getRootCauseMessage(e)); LOG.error("Could not update {} {}", provision.getAnyType().getKey(), workingDelta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), workingDelta, result, e); } } } audit(MatchingRule.toEventName(MatchingRule.UPDATE), resultStatus, before, output, workingDelta); } results.add(result); } return results; }
From source file:org.apache.syncope.core.provisioning.java.sync.AbstractSyncResultHandler.java
protected List<ProvisioningResult> deprovision(final SyncDelta delta, final List<Long> anys, final Provision provision, final boolean unlink) throws JobExecutionException { if (!profile.getTask().isPerformUpdate()) { LOG.debug("SyncTask not configured for update"); return Collections.<ProvisioningResult>emptyList(); }/*from www. ja va 2 s .c o m*/ LOG.debug("About to update {}", anys); final List<ProvisioningResult> updResults = new ArrayList<>(); for (Long id : anys) { LOG.debug("About to unassign resource {}", id); Object output; Result resultStatus; ProvisioningResult result = new ProvisioningResult(); result.setOperation(ResourceOperation.DELETE); result.setAnyType(provision.getAnyType().getKey()); result.setStatus(ProvisioningResult.Status.SUCCESS); result.setKey(id); AnyTO before = getAnyTO(id); if (before == null) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(String.format("Any '%s(%d)' not found", provision.getAnyType().getKey(), id)); } if (!profile.isDryRun()) { if (before == null) { resultStatus = Result.FAILURE; output = null; } else { result.setName(getName(before)); try { if (unlink) { for (SyncActions action : profile.getActions()) { action.beforeUnassign(this.getProfile(), delta, before); } } else { for (SyncActions action : profile.getActions()) { action.beforeDeprovision(this.getProfile(), delta, before); } } doDeprovision(id, unlink); output = getAnyTO(id); for (SyncActions action : profile.getActions()) { action.after(this.getProfile(), delta, AnyTO.class.cast(output), result); } resultStatus = Result.SUCCESS; LOG.debug("{} {} successfully updated", provision.getAnyType().getKey(), id); } catch (IgnoreProvisionException e) { throw e; } catch (PropagationException e) { // A propagation failure doesn't imply a synchronization failure. // The propagation exception status will be reported into the propagation task execution. LOG.error("Could not propagate {} {}", provision.getAnyType().getKey(), delta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), delta, result, e); } } catch (Exception e) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(ExceptionUtils.getRootCauseMessage(e)); LOG.error("Could not update {} {}", provision.getAnyType().getKey(), delta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), delta, result, e); } } } audit(unlink ? MatchingRule.toEventName(MatchingRule.UNASSIGN) : MatchingRule.toEventName(MatchingRule.DEPROVISION), resultStatus, before, output, delta); } updResults.add(result); } return updResults; }
From source file:org.apache.syncope.core.provisioning.java.sync.AbstractSyncResultHandler.java
protected List<ProvisioningResult> link(final SyncDelta delta, final List<Long> anys, final Provision provision, final boolean unlink) throws JobExecutionException { if (!profile.getTask().isPerformUpdate()) { LOG.debug("SyncTask not configured for update"); return Collections.<ProvisioningResult>emptyList(); }// w w w . j av a2 s . c o m LOG.debug("About to update {}", anys); final List<ProvisioningResult> updResults = new ArrayList<>(); for (Long key : anys) { LOG.debug("About to unassign resource {}", key); Object output; Result resultStatus; ProvisioningResult result = new ProvisioningResult(); result.setOperation(ResourceOperation.NONE); result.setAnyType(provision.getAnyType().getKey()); result.setStatus(ProvisioningResult.Status.SUCCESS); result.setKey(key); AnyTO before = getAnyTO(key); if (before == null) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(String.format("Any '%s(%d)' not found", provision.getAnyType().getKey(), key)); } if (!profile.isDryRun()) { if (before == null) { resultStatus = Result.FAILURE; output = null; } else { result.setName(getName(before)); try { if (unlink) { for (SyncActions action : profile.getActions()) { action.beforeUnlink(this.getProfile(), delta, before); } } else { for (SyncActions action : profile.getActions()) { action.beforeLink(this.getProfile(), delta, before); } } output = doLink(before, result, unlink); for (SyncActions action : profile.getActions()) { action.after(this.getProfile(), delta, AnyTO.class.cast(output), result); } resultStatus = Result.SUCCESS; LOG.debug("{} {} successfully updated", provision.getAnyType().getKey(), key); } catch (IgnoreProvisionException e) { throw e; } catch (PropagationException e) { // A propagation failure doesn't imply a synchronization failure. // The propagation exception status will be reported into the propagation task execution. LOG.error("Could not propagate {} {}", provision.getAnyType().getKey(), delta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), delta, result, e); } } catch (Exception e) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(ExceptionUtils.getRootCauseMessage(e)); LOG.error("Could not update {} {}", provision.getAnyType().getKey(), delta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), delta, result, e); } } } audit(unlink ? MatchingRule.toEventName(MatchingRule.UNLINK) : MatchingRule.toEventName(MatchingRule.LINK), resultStatus, before, output, delta); } updResults.add(result); } return updResults; }
From source file:org.apache.syncope.core.provisioning.java.sync.AbstractSyncResultHandler.java
protected List<ProvisioningResult> delete(final SyncDelta delta, final List<Long> anys, final Provision provision) throws JobExecutionException { if (!profile.getTask().isPerformDelete()) { LOG.debug("SyncTask not configured for delete"); return Collections.<ProvisioningResult>emptyList(); }// www . j a va2s .com LOG.debug("About to delete {}", anys); List<ProvisioningResult> delResults = new ArrayList<>(); SyncDelta workingDelta = delta; for (Long id : anys) { Object output; Result resultStatus = Result.FAILURE; ProvisioningResult result = new ProvisioningResult(); try { AnyTO before = getAnyTO(id); result.setKey(id); result.setName(getName(before)); result.setOperation(ResourceOperation.DELETE); result.setAnyType(provision.getAnyType().getKey()); result.setStatus(ProvisioningResult.Status.SUCCESS); if (!profile.isDryRun()) { for (SyncActions action : profile.getActions()) { workingDelta = action.beforeDelete(this.getProfile(), workingDelta, before); } try { doDelete(id); output = null; resultStatus = Result.SUCCESS; for (SyncActions action : profile.getActions()) { action.after(this.getProfile(), workingDelta, before, result); } } catch (IgnoreProvisionException e) { throw e; } catch (Exception e) { result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage(ExceptionUtils.getRootCauseMessage(e)); LOG.error("Could not delete {} {}", provision.getAnyType().getKey(), id, e); output = e; for (SyncActions action : profile.getActions()) { action.onError(this.getProfile(), workingDelta, result, e); } } audit(ResourceOperation.DELETE.name().toLowerCase(), resultStatus, before, output, workingDelta); } delResults.add(result); } catch (NotFoundException e) { LOG.error("Could not find {} {}", provision.getAnyType().getKey(), id, e); } catch (UnauthorizedException e) { LOG.error("Not allowed to read {} {}", provision.getAnyType().getKey(), id, e); } catch (Exception e) { LOG.error("Could not delete {} {}", provision.getAnyType().getKey(), id, e); } } return delResults; }
From source file:org.apache.syncope.core.rest.cxf.RestServiceExceptionMapper.java
@Override public Response toResponse(final Exception ex) { LOG.error("Exception thrown", ex); ResponseBuilder builder;/* www .j a v a 2 s . c om*/ if (ex instanceof AccessDeniedException) { // leaves the default exception processing to Spring Security builder = null; } else if (ex instanceof SyncopeClientException) { SyncopeClientException sce = (SyncopeClientException) ex; builder = sce.isComposite() ? getSyncopeClientCompositeExceptionResponse(sce.asComposite()) : getSyncopeClientExceptionResponse(sce); } else if (ex instanceof DelegatedAdministrationException || ExceptionUtils.getRootCause(ex) instanceof DelegatedAdministrationException) { builder = builder(ClientExceptionType.DelegatedAdministration, ExceptionUtils.getRootCauseMessage(ex)); } else if (ex instanceof EntityExistsException || ex instanceof DuplicateException || ex instanceof PersistenceException && ex.getCause() instanceof EntityExistsException) { builder = builder(ClientExceptionType.EntityExists, getJPAMessage(ex instanceof PersistenceException ? ex.getCause() : ex)); } else if (ex instanceof DataIntegrityViolationException || ex instanceof JpaSystemException) { builder = builder(ClientExceptionType.DataIntegrityViolation, getJPAMessage(ex)); } else if (ex instanceof ConnectorException) { builder = builder(ClientExceptionType.ConnectorException, ExceptionUtils.getRootCauseMessage(ex)); } else if (ex instanceof NotFoundException) { builder = builder(ClientExceptionType.NotFound, ExceptionUtils.getRootCauseMessage(ex)); } else { builder = processInvalidEntityExceptions(ex); if (builder == null) { builder = processBadRequestExceptions(ex); } // process JAX-RS validation errors if (builder == null && ex instanceof ValidationException) { builder = builder(validationEM.toResponse((ValidationException) ex)) .header(RESTHeaders.ERROR_CODE, ClientExceptionType.RESTValidation.name()) .header(RESTHeaders.ERROR_INFO, ClientExceptionType.RESTValidation .getInfoHeaderValue(ExceptionUtils.getRootCauseMessage(ex))); ErrorTO error = new ErrorTO(); error.setStatus(ClientExceptionType.RESTValidation.getResponseStatus().getStatusCode()); error.setType(ClientExceptionType.RESTValidation); error.getElements().add(ExceptionUtils.getRootCauseMessage(ex)); builder.entity(error); } // ...or just report as InternalServerError if (builder == null) { builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).header(RESTHeaders.ERROR_INFO, ClientExceptionType.Unknown.getInfoHeaderValue(ExceptionUtils.getRootCauseMessage(ex))); ErrorTO error = new ErrorTO(); error.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); error.setType(ClientExceptionType.Unknown); error.getElements().add(ExceptionUtils.getRootCauseMessage(ex)); builder.entity(error); } } return builder == null ? null : builder.build(); }
From source file:org.apache.syncope.core.rest.cxf.RestServiceExceptionMapper.java
private ResponseBuilder processBadRequestExceptions(final Exception ex) { // This exception might be raised by Flowable (if enabled) Class<?> ibatisPersistenceException = null; try {//from w w w .j a v a2 s. co m ibatisPersistenceException = Class.forName("org.apache.ibatis.exceptions.PersistenceException"); } catch (ClassNotFoundException e) { // ignore } if (ex instanceof WorkflowException) { return builder(ClientExceptionType.Workflow, ExceptionUtils.getRootCauseMessage(ex)); } else if (ex instanceof PersistenceException) { return builder(ClientExceptionType.GenericPersistence, ExceptionUtils.getRootCauseMessage(ex)); } else if (ibatisPersistenceException != null && ibatisPersistenceException.isAssignableFrom(ex.getClass())) { return builder(ClientExceptionType.Workflow, "Currently unavailable. Please try later."); } else if (ex instanceof JpaSystemException) { return builder(ClientExceptionType.DataIntegrityViolation, ExceptionUtils.getRootCauseMessage(ex)); } else if (ex instanceof ConfigurationException) { return builder(ClientExceptionType.InvalidConnIdConf, ExceptionUtils.getRootCauseMessage(ex)); } else if (ex instanceof ParsingValidationException) { return builder(ClientExceptionType.InvalidValues, ExceptionUtils.getRootCauseMessage(ex)); } else if (ex instanceof MalformedPathException) { return builder(ClientExceptionType.InvalidPath, ExceptionUtils.getRootCauseMessage(ex)); } return null; }
From source file:org.apache.syncope.core.rest.cxf.service.AbstractServiceImpl.java
protected SearchCond getSearchCond(final String fiql, final String realm) { try {//ww w . ja v a2 s . c o m SearchCondVisitor visitor = new SearchCondVisitor(); visitor.setRealm(realm); SearchCondition<SearchBean> sc = searchContext.getCondition(fiql, SearchBean.class); sc.accept(visitor); return visitor.getQuery(); } catch (Exception e) { LOG.error("Invalid FIQL expression: {}", fiql, e); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSearchExpression); sce.getElements().add(fiql); sce.getElements().add(ExceptionUtils.getRootCauseMessage(e)); throw sce; } }