Skip to content

Commit

Permalink
Fixed remaining tests. Adapting for current version of ConnId framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 5, 2014
1 parent e1d0f4f commit cb7e356
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 46 deletions.
Expand Up @@ -405,37 +405,42 @@ public void run() {
auditService.audit(auditRecord, task);
for(ObjectDelta<? extends ObjectType> delta: deltas) {
OperationResult result1 = result.createSubresult(EXECUTE_CHANGE);
if (delta.isAdd()) {
RepoAddOptions repoOptions = new RepoAddOptions();
if (ModelExecuteOptions.isNoCrypt(options)) {
repoOptions.setAllowUnencryptedValues(true);
}
if (ModelExecuteOptions.isOverwrite(options)) {
repoOptions.setOverwrite(true);
}
securityEnforcer.authorize(ModelAuthorizationAction.ADD.getUrl(), null, delta.getObjectToAdd(), null, null, null, result1);
String oid = cacheRepositoryService.addObject(delta.getObjectToAdd(), repoOptions, result1);
delta.setOid(oid);
} else if (delta.isDelete()) {
PrismObject<? extends ObjectType> existingObject = cacheRepositoryService.getObject(delta.getObjectTypeClass(), delta.getOid(), null, result1);
securityEnforcer.authorize(ModelAuthorizationAction.DELETE.getUrl(), null, existingObject, null, null, null, result1);
if (ObjectTypes.isClassManagedByProvisioning(delta.getObjectTypeClass())) {
Utils.clearRequestee(task);
provisioning.deleteObject(delta.getObjectTypeClass(), delta.getOid(),
ProvisioningOperationOptions.createRaw(), null, task, result1);
} else {
cacheRepositoryService.deleteObject(delta.getObjectTypeClass(), delta.getOid(),
result1);
}
} else if (delta.isModify()) {
PrismObject existingObject = cacheRepositoryService.getObject(delta.getObjectTypeClass(), delta.getOid(), null, result1);
securityEnforcer.authorize(ModelAuthorizationAction.MODIFY.getUrl(), null, existingObject, delta, null, null, result1);
cacheRepositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(),
delta.getModifications(), result1);
} else {
throw new IllegalArgumentException("Wrong delta type "+delta.getChangeType()+" in "+delta);
}
result1.computeStatusIfUnknown();
try {
if (delta.isAdd()) {
RepoAddOptions repoOptions = new RepoAddOptions();
if (ModelExecuteOptions.isNoCrypt(options)) {
repoOptions.setAllowUnencryptedValues(true);
}
if (ModelExecuteOptions.isOverwrite(options)) {
repoOptions.setOverwrite(true);
}
securityEnforcer.authorize(ModelAuthorizationAction.ADD.getUrl(), null, delta.getObjectToAdd(), null, null, null, result1);
String oid = cacheRepositoryService.addObject(delta.getObjectToAdd(), repoOptions, result1);
delta.setOid(oid);
} else if (delta.isDelete()) {
PrismObject<? extends ObjectType> existingObject = cacheRepositoryService.getObject(delta.getObjectTypeClass(), delta.getOid(), null, result1);
securityEnforcer.authorize(ModelAuthorizationAction.DELETE.getUrl(), null, existingObject, null, null, null, result1);
if (ObjectTypes.isClassManagedByProvisioning(delta.getObjectTypeClass())) {
Utils.clearRequestee(task);
provisioning.deleteObject(delta.getObjectTypeClass(), delta.getOid(),
ProvisioningOperationOptions.createRaw(), null, task, result1);
} else {
cacheRepositoryService.deleteObject(delta.getObjectTypeClass(), delta.getOid(),
result1);
}
} else if (delta.isModify()) {
PrismObject existingObject = cacheRepositoryService.getObject(delta.getObjectTypeClass(), delta.getOid(), null, result1);
securityEnforcer.authorize(ModelAuthorizationAction.MODIFY.getUrl(), null, existingObject, delta, null, null, result1);
cacheRepositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(),
delta.getModifications(), result1);
} else {
throw new IllegalArgumentException("Wrong delta type "+delta.getChangeType()+" in "+delta);
}
} catch (ObjectAlreadyExistsException|SchemaException|ObjectNotFoundException|ConfigurationException|CommunicationException|SecurityViolationException|RuntimeException e) {
ModelUtils.recordFatalError(result1, e);
throw e;
}
result1.computeStatus();
retval.add(new ObjectDeltaOperation<>(delta, result1));
}
auditRecord.setTimestamp(null);
Expand Down
Expand Up @@ -73,9 +73,21 @@ public void log(Class<?> clazz, String method, Level level, String message, Thro
}
}

@Override
//@Override
// not using override to be able to work with both "old" and current version of connid
public void log(Class<?> clazz, StackTraceElement caller, Level level, String message, Throwable ex) {
log(clazz, caller.getMethodName(), level, message, ex);
}

@Override
public boolean isLoggable(Class<?> clazz, Level level) {
return true;
}

//@Override
// not using override to be able to work with both "old" and current version of connid
public boolean needToInferCaller(Class<?> clazz, Level level) {
return false;
}

}
Expand Up @@ -122,11 +122,9 @@ public static PasswordType createPasswordType(String password) {
}

public static ProtectedStringType createProtectedString(String clearValue) {
ProtectedStringType protectedString = new ProtectedStringType();
// this is a bit of workaround: it should be possible to add clearValue by itself, but there seems to be a parsing bug on the server side that needs to be fixed first (TODO)
protectedString.getContent().add(toJaxbElement(TYPES_CLEAR_VALUE, clearValue));
return protectedString;
}
ProtectedStringType protectedString = new ProtectedStringType();
protectedString.setClearValue(clearValue);
return protectedString; }

public static <T> JAXBElement<T> toJaxbElement(QName name, T value) {
return new JAXBElement<T>(name, (Class<T>) value.getClass(), value);
Expand Down
Expand Up @@ -731,18 +731,19 @@ private void addObjectViaModelWS(ObjectType objectType, ModelExecuteOptionsType
private static ObjectDeltaOperationType getOdoFromDeltaOperationList(ObjectDeltaOperationListType operationListType, ObjectDeltaType originalDelta) {
Validate.notNull(operationListType);
Validate.notNull(originalDelta);
if (originalDelta.getChangeType() != ChangeTypeType.ADD) {
throw new IllegalArgumentException("Original delta is not of ADD type");
}
if (originalDelta.getObjectToAdd() == null) {
throw new IllegalArgumentException("Original delta contains no object-to-be-added");
}
for (ObjectDeltaOperationType operationType : operationListType.getDeltaOperation()) {
ObjectDeltaType objectDeltaType = operationType.getObjectDelta();
if (objectDeltaType.getChangeType() == ChangeTypeType.ADD &&
if (originalDelta.getChangeType() == ChangeTypeType.ADD) {
if (objectDeltaType.getChangeType() == originalDelta.getChangeType() &&
objectDeltaType.getObjectToAdd() != null) {
ObjectType objectAdded = (ObjectType) objectDeltaType.getObjectToAdd();
if (objectAdded.getClass().equals(originalDelta.getObjectToAdd().getClass())) {
ObjectType objectAdded = (ObjectType) objectDeltaType.getObjectToAdd();
if (objectAdded.getClass().equals(originalDelta.getObjectToAdd().getClass())) {
return operationType;
}
}
} else {
if (objectDeltaType.getChangeType() == originalDelta.getChangeType() &&
originalDelta.getOid().equals(objectDeltaType.getOid())) {
return operationType;
}
}
Expand Down

0 comments on commit cb7e356

Please sign in to comment.