public static ObjectReferenceType createObjectRef(ObjectType objectType, QName relation) { if (objectType == null) { return null; } return createObjectRef(objectType.asPrismObject(), relation); }
@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); } } }
public List<TriggerType> createTriggerList() { PrismForJAXBUtil.createContainer(asPrismContainerValue(), F_TRIGGER); return getTrigger(); }
public List<ObjectReferenceType> createParentOrgRefList() { PrismForJAXBUtil.createReference(asPrismContainerValue(), F_PARENT_ORG_REF); return getParentOrgRef(); }
repo.setOid(jaxb.getOid()); repo.setName(RPolyString.copyFromJAXB(jaxb.getName())); repo.setLifecycleState(jaxb.getLifecycleState()); repo.setSubtype(RUtil.listToSet(jaxb.getSubtype())); String strVersion = jaxb.getVersion(); int version = StringUtils.isNotEmpty(strVersion) && strVersion.matches("[0-9]*") ? Integer.parseInt(jaxb .getVersion()) : 0; repo.setVersion(version); repo.getParentOrgRef().addAll(RUtil.safeListReferenceToSet(jaxb.getParentOrgRef(), repo, RReferenceOwner.OBJECT_PARENT_ORG, repositoryContext.relationRegistry)); for (TriggerType trigger : jaxb.getTrigger()) { RTrigger rTrigger = new RTrigger(null); RTrigger.fromJaxb(trigger, rTrigger, jaxb, repositoryContext, generatorResult); MetadataFactory.fromJAXB(jaxb.getMetadata(), repo, repositoryContext.prismContext, repositoryContext.relationRegistry); repo.setTenantRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getTenantRef(), repositoryContext.relationRegistry)); if (jaxb.getExtension() != null) { copyExtensionOrAttributesFromJAXB(jaxb.getExtension().asPrismContainerValue(), repo, repositoryContext, RObjectExtensionType.EXTENSION, generatorResult); for (OperationExecutionType opExec : jaxb.getOperationExecution()) { ROperationExecution rOpExec = new ROperationExecution(repo); ROperationExecution.fromJaxb(opExec, rOpExec, jaxb, repositoryContext, generatorResult);
public PolyStringType getRequesteeName() { if (requestee == null) { return null; } ObjectType requesteeObject = getRequesteeObject(); return requesteeObject != null ? requesteeObject.getName() : null; }
public SimpleObjectRefImpl(NotificationFunctionsImpl functions, ObjectType objectType) { this.oid = objectType.getOid(); this.objectType = objectType; this.functions = functions; }
private void addObjectViaModelWS(ObjectType objectType, ModelExecuteOptionsType options, Holder<String> oidHolder, Holder<OperationResultType> resultHolder) throws FaultMessage { ObjectDeltaListType deltaList = new ObjectDeltaListType(); ObjectDeltaType objectDelta = new ObjectDeltaType(); objectDelta.setObjectToAdd(objectType); QName type = objectType.asPrismObject().getDefinition().getTypeName(); objectDelta.setObjectType(type); objectDelta.setChangeType(ChangeTypeType.ADD); deltaList.getDelta().add(objectDelta); ObjectDeltaOperationListType objectDeltaOperationListType = modelWeb.executeChanges(deltaList, options); ObjectDeltaOperationType objectDeltaOperationType = getOdoFromDeltaOperationList(objectDeltaOperationListType, objectDelta); resultHolder.value = objectDeltaOperationType.getExecutionResult(); oidHolder.value = ((ObjectType) objectDeltaOperationType.getObjectDelta().getObjectToAdd()).getOid(); }
protected void removeObjectParent(ObjectType object, ObjectReferenceType parentOrgRef, boolean useReplace, OperationResult opResult) throws Exception { List<ItemDelta> modifications = new ArrayList<>(); if (!useReplace) { // standard case PrismReferenceValue existingValue = parentOrgRef.asReferenceValue(); ItemDelta removeParent = prismContext.deltaFactory().reference().createModificationDelete(object.getClass(), OrgType.F_PARENT_ORG_REF, existingValue.clone()); modifications.add(removeParent); } else { // using REPLACE modification List<PrismReferenceValue> newValues = new ArrayList<>(); for (ObjectReferenceType ort : object.getParentOrgRef()) { if (!ort.getOid().equals(parentOrgRef.getOid())) { newValues.add(ort.asReferenceValue().clone()); } } PrismObjectDefinition objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(object.getClass()); ItemDelta replaceParent = prismContext.deltaFactory().reference().createModificationReplace(OrgType.F_PARENT_ORG_REF, objectDefinition, newValues); modifications.add(replaceParent); } repositoryService.modifyObject(object.getClass(), object.getOid(), modifications, opResult); if (object instanceof OrgType) { orgGraph.removeEdge(object.getOid(), parentOrgRef.getOid()); } }
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; } }
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)); }
public ObjectType parentOrgRef(ObjectReferenceType value) { getParentOrgRef().add(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); */ }
public static <O extends ObjectType> XMLGregorianCalendar getLastTouchTimestamp(PrismObject<O> object) { if (object == null) { return null; } MetadataType metadata = object.asObjectable().getMetadata(); if (metadata == null) { return null; } XMLGregorianCalendar modifyTimestamp = metadata.getModifyTimestamp(); if (modifyTimestamp != null) { return modifyTimestamp; } return metadata.getCreateTimestamp(); }
public ObjectType trigger(TriggerType value) { getTrigger().add(value); return this; }
public <T extends ObjectType, F extends ObjectType> void applyMetadataAdd(LensContext<F> context, PrismObject<T> objectToAdd, XMLGregorianCalendar now, Task task, OperationResult result) throws SchemaException { T objectType = objectToAdd.asObjectable(); MetadataType metadataType = objectType.getMetadata(); if (metadataType == null) { metadataType = new MetadataType(); objectType.setMetadata(metadataType); } transplantRequestMetadata(context, metadataType); applyCreateMetadata(context, metadataType, now, task); if (workflowManager != null) { metadataType.getCreateApproverRef().addAll(workflowManager.getApprovedBy(task, result)); metadataType.getCreateApprovalComment().addAll(workflowManager.getApproverComments(task, result)); } if (objectToAdd.canRepresent(FocusType.class)) { applyAssignmentMetadataObject((LensContext<? extends FocusType>) context, objectToAdd, now, task, result); } }
public ObjectType oid(String value) { setOid(value); return this; }
public PrismObjectAsserter<O,RA> assertTenantRef(String expectedOid) { ObjectReferenceType tenantRef = getObject().asObjectable().getTenantRef(); if (tenantRef == null && expectedOid == null) { return this; } assertNotNull("No tenantRef in "+desc(), tenantRef); assertEquals("Wrong tenantRef OID in "+desc(), expectedOid, tenantRef.getOid()); return this; }