use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class ShadowIntegrityCheckResultHandler method doFixIntent.
private void doFixIntent(ShadowCheckResult checkResult, PrismObject<ShadowType> fetchedShadow, PrismObject<ShadowType> shadow, PrismObject<ResourceType> resource, Task task, OperationResult result) {
PrismObject<ShadowType> fullShadow;
if (!checkFetch) {
fullShadow = fetchShadow(checkResult, shadow, resource, task, result);
} else {
fullShadow = fetchedShadow;
}
if (fullShadow == null) {
checkResult.recordError(Statistics.CANNOT_APPLY_FIX, new SystemException("Cannot fix missing intent, because the resource object couldn't be fetched"));
return;
}
ObjectSynchronizationType synchronizationPolicy;
try {
synchronizationPolicy = synchronizationService.determineSynchronizationPolicy(resource.asObjectable(), fullShadow, configuration, task, result);
} catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | RuntimeException e) {
checkResult.recordError(Statistics.CANNOT_APPLY_FIX, new SystemException("Couldn't prepare fix for missing intent, because the synchronization policy couldn't be determined", e));
return;
}
if (synchronizationPolicy != null) {
if (synchronizationPolicy.getIntent() != null) {
PropertyDelta delta = PropertyDelta.createReplaceDelta(fullShadow.getDefinition(), ShadowType.F_INTENT, synchronizationPolicy.getIntent());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Intent fix delta (not executed now) = \n{}", delta.debugDump());
}
checkResult.addFixDelta(delta, Statistics.NO_INTENT_SPECIFIED);
} else {
LOGGER.info("Synchronization policy does not contain intent: {}", synchronizationPolicy);
}
} else {
LOGGER.info("Intent couldn't be fixed, because no synchronization policy was found");
}
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class PrismContainer method createNewValue.
public PrismContainerValue<C> createNewValue() {
checkMutability();
PrismContainerValue<C> pValue = new PrismContainerValue<>(prismContext);
try {
// No need to check uniqueness, we know that this value is new and therefore
// it will change anyway and therefore the check is pointless.
// However, the check is expensive (especially if there are many values).
// So we are happy to avoid it.
add(pValue, false);
} catch (SchemaException e) {
// This should not happen
throw new SystemException("Internal Error: " + e.getMessage(), e);
}
return pValue;
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class PrismReferenceValue method asReferencable.
public Referencable asReferencable() {
if (referencable != null) {
return referencable;
}
Itemable parent = getParent();
if (parent != null) {
QName xsdType = parent.getDefinition().getTypeName();
Class clazz = getPrismContext().getSchemaRegistry().getCompileTimeClass(xsdType);
if (clazz != null) {
try {
referencable = (Referencable) clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new SystemException("Couldn't create jaxb object instance of '" + clazz + "': " + e.getMessage(), e);
}
}
referencable.setupReferenceValue(this);
}
// A hack, just to avoid crashes. TODO think about this!
return new Referencable() {
PrismReferenceValue referenceValue = PrismReferenceValue.this;
@Override
public PrismReferenceValue asReferenceValue() {
return referenceValue;
}
@Override
public void setupReferenceValue(PrismReferenceValue value) {
referenceValue = value;
}
@Override
public String getOid() {
return referenceValue.getOid();
}
@Override
public QName getType() {
return referenceValue.getTargetType();
}
@Override
public PolyStringType getTargetName() {
return PrismForJAXBUtil.getReferenceTargetName(referenceValue);
}
@Override
public QName getRelation() {
return referenceValue.getRelation();
}
@Override
public String getDescription() {
return referenceValue.getDescription();
}
@Override
public EvaluationTimeType getResolutionTime() {
return referenceValue.getResolutionTime();
}
@Override
public SearchFilterType getFilter() {
SearchFilterType filter = new SearchFilterType();
filter.setFilterClauseXNode(PrismForJAXBUtil.getReferenceFilterClauseXNode(referenceValue));
return filter;
}
};
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class ProtectorImpl method init.
/**
* @throws SystemException if jceks keystore is not available on {@link ProtectorImpl#getKeyStorePath}
*/
public void init() {
InputStream stream = null;
try {
// Test if use file or classpath resource
File f = new File(getKeyStorePath());
if (f.exists()) {
LOGGER.info("Using file keystore at {}", getKeyStorePath());
if (!f.canRead()) {
LOGGER.error("Provided keystore file {} is unreadable.", getKeyStorePath());
throw new EncryptionException("Provided keystore file " + getKeyStorePath() + " is unreadable.");
}
stream = new FileInputStream(f);
// Use class path keystore
} else {
LOGGER.warn("Using default keystore from classpath ({}).", getKeyStorePath());
// Read from class path
stream = ProtectorImpl.class.getClassLoader().getResourceAsStream(getKeyStorePath());
// class path
if (stream == null) {
stream = ProtectorImpl.class.getClassLoader().getResourceAsStream("com/../../" + getKeyStorePath());
}
}
// Test if we have valid stream
if (stream == null) {
throw new EncryptionException("Couldn't load keystore as resource '" + getKeyStorePath() + "'");
}
// Load keystore
keyStore.load(stream, getKeyStorePassword().toCharArray());
stream.close();
// Initialze trust manager list
TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmFactory.init(keyStore);
trustManagers = new ArrayList<TrustManager>();
for (TrustManager trustManager : tmFactory.getTrustManagers()) {
trustManagers.add(trustManager);
}
//init apache crypto library
Init.init();
} catch (Exception ex) {
LOGGER.error("Unable to work with keystore {}, reason {}.", new Object[] { getKeyStorePath(), ex.getMessage() }, ex);
throw new SystemException(ex.getMessage(), ex);
}
randomNumberGenerator = new SecureRandom();
}
use of com.evolveum.midpoint.util.exception.SystemException in project midpoint by Evolveum.
the class PrismContainerValue method copyDefinition.
// copies the definition from original to aClone (created outside of this method)
// it has to (artifically) create a parent PrismContainer to hold the definition
//
// without having a definition, such containers cannot be serialized using
// PrismJaxbProcessor.marshalContainerableToString (without definition, there is
// no information on corresponding element name)
//
// todo review usefulness and appropriateness of this method and its placement
@Deprecated
public static void copyDefinition(Containerable aClone, Containerable original, PrismContext prismContext) {
try {
Validate.notNull(original.asPrismContainerValue().getParent(), "original PrismContainerValue has no parent");
ComplexTypeDefinition definition = original.asPrismContainerValue().getComplexTypeDefinition();
Validate.notNull(definition, "original PrismContainer definition is null");
PrismContainer<?> aCloneParent = prismContext.getSchemaRegistry().findContainerDefinitionByCompileTimeClass((Class<? extends Containerable>) definition.getCompileTimeClass()).instantiate();
aCloneParent.add(aClone.asPrismContainerValue());
} catch (SchemaException e) {
throw new SystemException("Unexpected SchemaException when copying definition from original object to its clone", e);
}
}
Aggregations