public ObjectType oid(String value) { setOid(value); return this; }
void addObjectPreAuthorized(ObjectType objectType, Task task, OperationResult result) throws ObjectAlreadyExistsException, SchemaException, ObjectNotFoundException { ObjectDelta<? extends ObjectType> objectDelta = DeltaFactory.Object.createAddDelta(objectType.asPrismObject()); Collection<ObjectDeltaOperation<? extends ObjectType>> ops; try { ops = modelService.executeChanges( singleton(objectDelta), ModelExecuteOptions.createRaw().setPreAuthorized(), task, result); } catch (ExpressionEvaluationException|CommunicationException|ConfigurationException|PolicyViolationException|SecurityViolationException e) { throw new SystemException("Unexpected exception when adding object: " + e.getMessage(), e); } ObjectDeltaOperation odo = ops.iterator().next(); objectType.setOid(odo.getObjectDelta().getOid()); /* ALTERNATIVELY, we can go directly into the repository. (No audit there.) String oid = repositoryService.addObject(objectType.asPrismObject(), null, result); objectType.setOid(oid); */ }
@Deprecated protected static <T extends ObjectType> void copyToJAXB(RObject<T> repo, ObjectType jaxb, PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) { Validate.notNull(repo, "Repo object must not be null."); Validate.notNull(jaxb, "JAXB object must not be null."); jaxb.setName(RPolyString.copyToJAXB(repo.getName())); jaxb.setOid(repo.getOid()); jaxb.setVersion(Integer.toString(repo.getVersion())); jaxb.setLifecycleState(repo.getLifecycleState()); if (repo.getSubtype() != null) { jaxb.getSubtype().addAll(repo.getSubtype()); } if (SelectorOptions.hasToLoadPath(ObjectType.F_PARENT_ORG_REF, options)) { List orgRefs = RUtil.safeSetReferencesToList(repo.getParentOrgRef(), prismContext); if (!orgRefs.isEmpty()) { jaxb.getParentOrgRef().addAll(orgRefs); } } }
private List<ApprovalRequest<T>> getApprovalRequests(ModelContext<?> modelContext, PcpAspectConfigurationType config, ObjectDelta<? extends ObjectType> change, Task taskFromModel, OperationResult result) { if (change.getChangeType() != ChangeType.ADD) { return null; } T objectType = (T) change.getObjectToAdd().asObjectable().clone(); if (objectType.getOid() == null) { String newOid = OidUtil.generateOid(); objectType.setOid(newOid); ((LensFocusContext<?>) modelContext.getFocusContext()).setOid(newOid); } change.setObjectToAdd(null); // make the change empty return Arrays.asList(createApprovalRequest(config, objectType, modelContext, taskFromModel, result)); }
private ObjectType convert(Class clazz, PrismObject<? extends ObjectType> o, OperationResultType result) { ObjectType objType = null; try { objType = (ObjectType) prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(clazz).instantiate().asObjectable(); objType.setOid(o.getOid()); objType.setName(o.asObjectable().getName()); return objType; } catch (SchemaException e) { // TODO Auto-generated catch block return objType; } }