use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class UserProfileServiceMock method getPrincipal.
@Override
public MidPointPrincipal getPrincipal(String username) throws ObjectNotFoundException {
OperationResult result = new OperationResult(OPERATION_GET_PRINCIPAL);
PrismObject<UserType> user = null;
try {
user = findByUsername(username, result);
} catch (ObjectNotFoundException ex) {
LOGGER.trace("Couldn't find user with name '{}', reason: {}.", new Object[] { username, ex.getMessage(), ex });
throw ex;
} catch (Exception ex) {
LOGGER.warn("Error getting user with name '{}', reason: {}.", new Object[] { username, ex.getMessage(), ex });
throw new SystemException(ex.getMessage(), ex);
}
return createPrincipal(user, result);
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class AuditFactory method init.
public void init() {
Configuration config = getCurrentConfiguration();
//TODO FIX CONFIGURATION, CLEANUP REALLY NEEDED
List<SubnodeConfiguration> auditServices = ((XMLConfiguration) ((CompositeConfiguration) ((SubsetConfiguration) config).getParent()).getConfiguration(0)).configurationsAt(AUDIT_CONFIGURATION + "." + CONF_AUDIT_SERVICE);
for (SubnodeConfiguration serviceConfig : auditServices) {
try {
String factoryClass = getFactoryClassName(serviceConfig);
Class<AuditServiceFactory> clazz = (Class<AuditServiceFactory>) Class.forName(factoryClass);
AuditServiceFactory factory = getFactory(clazz);
factory.init(serviceConfig);
serviceFactories.add(factory);
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "AuditServiceFactory implementation class {} failed to " + "initialize.", ex, getFactoryClassName(serviceConfig));
throw new SystemException("AuditServiceFactory implementation class " + getFactoryClassName(serviceConfig) + " failed to initialize: " + ex.getMessage(), ex);
}
}
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class AbstractLdapHierarchyTest method reconcileAllOrgs.
protected void reconcileAllOrgs() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
final Task task = createTask("reconcileAllOrgs");
OperationResult result = task.getResult();
ResultHandler<OrgType> handler = new ResultHandler<OrgType>() {
@Override
public boolean handle(PrismObject<OrgType> object, OperationResult parentResult) {
try {
display("reconciling " + object);
reconcileOrg(object.getOid(), task, parentResult);
} catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException | ConfigurationException | SecurityViolationException e) {
throw new SystemException(e.getMessage(), e);
}
return true;
}
};
display("Reconciling all orgs");
modelService.searchObjectsIterative(OrgType.class, null, handler, null, task, result);
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class ResourceManager method applyConnectorSchemaToResource.
/**
* Apply proper definition (connector schema) to the resource.
*/
private void applyConnectorSchemaToResource(ConnectorSpec connectorSpec, PrismObjectDefinition<ResourceType> resourceDefinition, PrismObject<ResourceType> resource, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
ConnectorType connectorType = connectorManager.getConnectorTypeReadOnly(connectorSpec, result);
PrismSchema connectorSchema = connectorManager.getConnectorSchema(connectorType);
if (connectorSchema == null) {
throw new SchemaException("No connector schema in " + connectorType);
}
PrismContainerDefinition<ConnectorConfigurationType> configurationContainerDefinition = ConnectorTypeUtil.findConfigurationContainerDefinition(connectorType, connectorSchema);
if (configurationContainerDefinition == null) {
throw new SchemaException("No configuration container definition in schema of " + connectorType);
}
configurationContainerDefinition = configurationContainerDefinition.clone();
PrismContainer<ConnectorConfigurationType> configurationContainer = connectorSpec.getConnectorConfiguration();
// the element is global in the connector schema. therefore it does not have correct maxOccurs
if (configurationContainer != null) {
configurationContainerDefinition.adoptElementDefinitionFrom(configurationContainer.getDefinition());
configurationContainer.applyDefinition(configurationContainerDefinition, true);
try {
configurationContainer.accept(visitable -> {
if ((visitable instanceof PrismProperty<?>)) {
try {
evaluateExpression((PrismProperty<?>) visitable, resource, task, result);
} catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException e) {
throw new TunnelException(e);
}
}
});
} catch (TunnelException te) {
Throwable e = te.getCause();
if (e instanceof SchemaException) {
throw (SchemaException) e;
} else if (e instanceof ObjectNotFoundException) {
throw (ObjectNotFoundException) e;
} else if (e instanceof ExpressionEvaluationException) {
throw (ExpressionEvaluationException) e;
} else if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else if (e instanceof Error) {
throw (Error) e;
} else {
throw new SystemException(e);
}
}
} else {
configurationContainerDefinition.adoptElementDefinitionFrom(resourceDefinition.findContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION));
}
if (connectorSpec.getConnectorName() == null) {
// Default connector, for compatibility
// It does not make sense to update this for any other connectors.
// We cannot have one definition for addiitionalConnector[1]/connectorConfiguraiton and
// different definition for addiitionalConnector[2]/connectorConfiguraiton in the object definition.
// The way to go is to set up definitions on the container level.
resourceDefinition.replaceDefinition(ResourceType.F_CONNECTOR_CONFIGURATION, configurationContainerDefinition);
}
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class ProvisioningServiceImpl method synchronize.
@SuppressWarnings("rawtypes")
@Override
public int synchronize(ResourceShadowDiscriminator shadowCoordinates, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
Validate.notNull(shadowCoordinates, "Coordinates oid must not be null.");
String resourceOid = shadowCoordinates.getResourceOid();
Validate.notNull(resourceOid, "Resource oid must not be null.");
Validate.notNull(task, "Task must not be null.");
Validate.notNull(parentResult, "Operation result must not be null.");
OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".synchronize");
result.addParam(OperationResult.PARAM_OID, resourceOid);
result.addParam(OperationResult.PARAM_TASK, task.toString());
int processedChanges = 0;
try {
// Resolve resource
PrismObject<ResourceType> resource = getObject(ResourceType.class, resourceOid, null, task, result);
ResourceType resourceType = resource.asObjectable();
LOGGER.trace("**PROVISIONING: Start synchronization of resource {} ", resourceType);
// getting token form task
PrismProperty tokenProperty = getTokenProperty(shadowCoordinates, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("**PROVISIONING: Got token property: {} from the task extension.", SchemaDebugUtil.prettyPrint(tokenProperty));
}
processedChanges = getShadowCache(Mode.STANDARD).synchronize(shadowCoordinates, tokenProperty, task, result);
LOGGER.debug("Synchronization of {} done, token {}, {} changes", resource, tokenProperty, processedChanges);
} catch (ObjectNotFoundException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: object not found: " + e.getMessage(), e);
throw e;
} catch (CommunicationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: communication problem: " + e.getMessage(), e);
throw e;
} catch (ObjectAlreadyExistsException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: object already exists problem: " + e.getMessage(), e);
throw new SystemException(e);
} catch (GenericFrameworkException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: generic connector framework error: " + e.getMessage(), e);
throw new GenericConnectorException(e.getMessage(), e);
} catch (SchemaException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: schema problem: " + e.getMessage(), e);
throw e;
} catch (SecurityViolationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: security violation: " + e.getMessage(), e);
throw e;
} catch (ConfigurationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: configuration problem: " + e.getMessage(), e);
throw e;
} catch (RuntimeException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: unexpected problem: " + e.getMessage(), e);
throw e;
} catch (ExpressionEvaluationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: expression error: " + e.getMessage(), e);
throw e;
}
result.recordSuccess();
result.cleanupResult();
return processedChanges;
}
Aggregations