@Override public String getLocalizedMessage() { return localizedUserFriendlyMessage != null ? localizedUserFriendlyMessage : getMessage(); }
@Override public OrgType getOrgByOid(String oid, boolean preAuthorized) throws SchemaException { try { return getObject(OrgType.class, oid, preAuthorized); } catch (ObjectNotFoundException|SecurityViolationException e) { return null; } catch (CommunicationException|ConfigurationException|ExpressionEvaluationException e) { throw new SystemException("Couldn't get org: " + e.getMessage(), e); // really shouldn't occur } }
public static <O extends ObjectType> ModelContext<O> unwrapModelContext(LensContextType lensContextType, ModelInteractionService modelInteractionService, Task opTask, OperationResult result) throws ObjectNotFoundException { if (lensContextType != null) { try { return modelInteractionService.unwrapModelContext(lensContextType, opTask, result); } catch (SchemaException | CommunicationException | ConfigurationException |ExpressionEvaluationException e) { // todo treat appropriately throw new SystemException("Couldn't access model operation context in task: " + e.getMessage(), e); } } else { return null; } } }
public Collection<ObjectDeltaOperation<? extends ObjectType>> applyDelta(ObjectDelta delta, ModelExecuteOptions options, ExecutionContext context, OperationResult result) throws ScriptExecutionException { try { return modelService.executeChanges(Collections.singleton(delta), options, context.getTask(), result); } catch (ObjectAlreadyExistsException|ObjectNotFoundException|SchemaException|ExpressionEvaluationException|CommunicationException|ConfigurationException|PolicyViolationException|SecurityViolationException e) { throw new ScriptExecutionException("Couldn't modify object: " + e.getMessage(), e); } }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { try { return getPrincipal(username); } catch (ObjectNotFoundException e) { throw new UsernameNotFoundException(e.getMessage(), e); } catch (SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) { throw new SystemException(e.getMessage(), e); } }
private PrismObject<SystemConfigurationType> getSystemConfiguration(OperationResult result) { PrismObject<SystemConfigurationType> systemConfiguration = null; try { // TODO: use SystemObjectCache instead? systemConfiguration = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result); } catch (ObjectNotFoundException | SchemaException e) { LOGGER.warn("No system configuration: {}", e.getMessage(), e); } return systemConfiguration; }
protected RoleType getRoleSimple(String oid) { try { return getRole(oid).asObjectable(); } catch (CommonException e) { throw new SystemException("Unexpected exception while getting role " + oid + ": " + e.getMessage(), e); } }
public Collection<ObjectDeltaOperation<? extends ObjectType>> applyDelta(ObjectDelta<? extends ObjectType> delta, ModelExecuteOptions options, boolean dryRun, ExecutionContext context, OperationResult result) throws ScriptExecutionException { try { if (dryRun) { modelInteractionService.previewChanges(Collections.singleton(delta), options, context.getTask(), result); return null; } else { return modelService.executeChanges(Collections.singleton(delta), options, context.getTask(), result); } } catch (ObjectAlreadyExistsException|ObjectNotFoundException|SchemaException|ExpressionEvaluationException|CommunicationException|ConfigurationException|PolicyViolationException|SecurityViolationException e) { throw new ScriptExecutionException("Couldn't modify object: " + e.getMessage(), e); } }
protected String getTranslatedMessage(CommonException e) { if (e.getUserFriendlyMessage() != null) { return localizationService.translate(e.getUserFriendlyMessage(), Locale.US); } else { return e.getMessage(); } }
private void authenticateUser(PrismObject<UserType> user, String enteredUsername, ConnectionEnvironment connEnv, ContainerRequestContext requestCtx) { try { securityContextManager.setupPreAuthenticatedSecurityContext(user); } catch (SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) { securityHelper.auditLoginFailure(enteredUsername, user.asObjectable(), connEnv, "Schema error: "+e.getMessage()); requestCtx.abortWith(Response.status(Status.BAD_REQUEST).build()); // return false; } LOGGER.trace("Authenticated to REST service as {}", user); }
<T extends ObjectType> List<T> searchObjects(Class<T> type, ObjectQuery query) { List<T> ret = new ArrayList<>(); Task task = taskManager.createTaskInstance(); try { List<PrismObject<T>> list = model.searchObjects(type, query, null, task, task.getResult()).getList(); for (PrismObject<T> po : list) { ret.add(po.asObjectable()); } } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { LOGGER.error("Could not search objects of type: " + type + " with query " + query + ". Reason: " + e.getMessage()); } return ret; }
<T extends ObjectType> void modifyObjectPreAuthorized(Class<T> objectClass, String oid, Collection<ItemDelta<?,?>> itemDeltas, Task task, OperationResult result) throws ObjectAlreadyExistsException, SchemaException, ObjectNotFoundException { ObjectDelta<T> objectDelta = prismContext.deltaFactory().object().createModifyDelta(oid, itemDeltas, objectClass ); try { ModelExecuteOptions options = ModelExecuteOptions.createRaw().setPreAuthorized(); modelService.executeChanges(Collections.singletonList(objectDelta), options, task, result); } catch (SecurityViolationException|ExpressionEvaluationException|CommunicationException|ConfigurationException|PolicyViolationException e) { throw new SystemException("Unexpected exception when modifying " + objectClass.getSimpleName() + " " + oid + ": " + e.getMessage(), e); } }
public <T extends ObjectType> PrismObject<T> getObject(Class<T> type, String oid, boolean noFetch, ExecutionContext context, OperationResult result) throws ScriptExecutionException, ExpressionEvaluationException { try { return modelService.getObject(type, oid, createGetOptions(null, noFetch), context.getTask(), result); } catch (ConfigurationException|ObjectNotFoundException|SchemaException|CommunicationException|SecurityViolationException e) { throw new ScriptExecutionException("Couldn't get object: " + e.getMessage(), e); } }
public UserType getShadowOwner(String shadowOid) { Task task = taskManager.createTaskInstance(); try { PrismObject<UserType> owner = model.findShadowOwner(shadowOid, task, task.getResult()); return owner.asObjectable(); } catch (ObjectNotFoundException | SecurityViolationException | SchemaException | ConfigurationException | ExpressionEvaluationException | CommunicationException e) { // TODO Auto-generated catch block LOGGER.error("Could not find owner for shadow with oid " + shadowOid + ". Reason: " + e.getMessage()); } return null; }
private <F extends FocusType> PrismObject<ShadowType> loadProjection(LensContext<F> context, LensProjectionContext projContext, Task task, OperationResult result, PrismObject<ShadowType> accountCurrent) throws SchemaException { try { contextLoader.loadFullShadow(context, projContext, "inbound", task, result); accountCurrent = projContext.getObjectCurrent(); } catch (ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { LOGGER.warn("Couldn't load account with shadow OID {} because of {}, setting context as broken and skipping inbound processing on it", projContext.getOid(), e.getMessage()); projContext.setSynchronizationPolicyDecision(SynchronizationPolicyDecision.BROKEN); } return accountCurrent; }
private <T extends ObjectType> List<PrismObject<T>> searchObjects(Class<T> clazz, ObjectQuery query, OperationResult result, boolean preAuthorized) throws SchemaException, SecurityViolationException { if (preAuthorized) { return repositoryService.searchObjects(clazz, query, null, result); } else { try { Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createExecutionPhase()); return modelService.searchObjects(clazz, query, options, getCurrentTask(), result); } catch (ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { throw new SystemException("Couldn't search objects: " + e.getMessage(), e); } } }
@Override protected void rememberSteadyResources() { super.rememberSteadyResources(); OperationResult result = new OperationResult("rememberSteadyResources"); try { lastResourceVersion = repositoryService.getVersion(ResourceType.class, getResourceOid(), result); } catch (ObjectNotFoundException | SchemaException e) { throw new RuntimeException(e.getMessage(), e); } }
public <O extends ObjectType> O resolveObject(Class type, String oid) { Task task = taskManager.createTaskInstance(); OperationResult parentResult = task.getResult(); PrismObject<O> obj; try { obj = model.getObject(type, oid, SelectorOptions.createCollection(GetOperationOptions.createResolveNames()), task, parentResult); return obj.asObjectable(); } catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) { // TODO Auto-generated catch block LOGGER.error("Could not get object with oid " + oid + ". Reason: " + e.getMessage()); } return null; }
private PrismObject<SystemConfigurationType> getSystemConfiguration(OperationResult result) { PrismObject<SystemConfigurationType> systemConfiguration = null; try { // TODO: use SystemObjectCache instead? systemConfiguration = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result); } catch (ObjectNotFoundException | SchemaException e) { LOGGER.warn("No system configuration: {}", e.getMessage(), e); } return systemConfiguration; }
@Override protected void assertSteadyResources() { super.assertSteadyResources(); String currentResourceVersion; try { OperationResult result = new OperationResult("assertSteadyResources"); currentResourceVersion = repositoryService.getVersion(ResourceType.class, getResourceOid(), result); } catch (ObjectNotFoundException | SchemaException e) { throw new RuntimeException(e.getMessage(), e); } assertEquals("Resource version mismatch", lastResourceVersion, currentResourceVersion); }