private ObjectType asObjectType(PrismValue value) { return (ObjectType) ((PrismObjectValue) value).asObjectable(); }
public PrismContainer<?> createExtension() throws SchemaException { PrismObjectDefinition<O> objeDef = getDefinition(); PrismContainerDefinition<Containerable> extensionDef = objeDef.findContainerDefinition(getExtensionContainerElementName()); PrismContainer<?> extensionContainer = extensionDef.instantiate(); getValue().add(extensionContainer); return extensionContainer; }
PrismObjectValue objectValue = (PrismObjectValue) value; ObjectReferenceType ref = new ObjectReferenceType(); ref.setType(objectValue.asPrismObject().getDefinition().getTypeName()); // todo check the definition is present ref.setOid(objectValue.getOid()); // todo check if oid is present retval.add(ref); } else if (value instanceof PrismPropertyValue) {
@Override public boolean add(@NotNull PrismContainerValue newValue, boolean checkUniqueness) throws SchemaException { if (!(newValue instanceof PrismObjectValue)) { throw new IllegalArgumentException("Couldn't add non-PrismObjectValue to a PrismObject: value = " + newValue + ", object = " + this); } if (values.size() > 1) { throw new IllegalStateException("PrismObject with more than one value: " + this); } else if (values.size() == 1) { PrismObjectValue<O> value = (PrismObjectValue<O>) values.get(0); if (value.isEmpty() && value.getOid() == null) { clear(); } else { throw new IllegalStateException("PrismObject cannot have more than one value. New value = " + newValue + ", object = " + this); } } return super.add(newValue, checkUniqueness); }
OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult); context.checkTaskStop(); if (value instanceof PrismObjectValue && ((PrismObjectValue) value).asObjectable() instanceof ResourceType) { PrismObject<ResourceType> resourceTypePrismObject = ((PrismObjectValue) value).asPrismObject(); ResourceType resourceType = resourceTypePrismObject.asObjectable(); long started = operationsHelper.recordStart(context, resourceType);
OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult); context.checkTaskStop(); if (value instanceof PrismObjectValue && FocusType.class.isAssignableFrom(((PrismObjectValue) value).asPrismObject().getCompileTimeClass())) { PrismObject<FocusType> focalPrismObject = ((PrismObjectValue) value).asPrismObject(); FocusType focusType = focalPrismObject.asObjectable(); long started = operationsHelper.recordStart(context, focusType);
if (objectVal.getOid() != null) { xmap.put(XNodeImpl.KEY_OID, createPrimitiveXNodeStringAttr(objectVal.getOid())); if (objectVal.getVersion() != null) { xmap.put(XNodeImpl.KEY_VERSION, createPrimitiveXNodeStringAttr(objectVal.getVersion()));
@Test public void testPrismConsistency() throws Exception { System.out.println("===[ testPrismConsistency ]==="); // GIVEN PrismContext ctx = getPrismContext(); PrismObjectDefinition<UserType> userDefinition = ctx.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); // WHEN PrismObject<UserType> user = userDefinition.instantiate(); user.setOid("12345"); // THEN System.out.println("User:"); System.out.println(user.debugDump()); System.out.println("Checking consistency, 1st time."); user.checkConsistence(); UserType userType = user.getValue().getValue(); System.out.println("Checking consistency, 2nd time - after getValue().getValue()."); user.checkConsistence(); System.out.println("OK."); }
/** * Returns Object ID (OID). * * May return null if the object does not have an OID. * * @return Object ID (OID) */ public String getOid() { return getValue().getOid(); }
private <O extends ObjectType> void applySchemasAndSecurityPhase(PrismObject<O> object, ObjectSecurityConstraints securityConstraints, PrismObjectDefinition<O> objectDefinition, GetOperationOptions rootOptions, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { Validate.notNull(phase); try { AuthorizationDecisionType globalReadDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_GET, phase); if (globalReadDecision == AuthorizationDecisionType.DENY) { // shortcut SecurityUtil.logSecurityDeny(object, "because the authorization denies access"); throw new AuthorizationException("Access denied"); } AuthorizationDecisionType globalAddDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.ADD.getUrl(), phase); AuthorizationDecisionType globalModifyDecision = securityConstraints.findAllItemsDecision(ModelAuthorizationAction.MODIFY.getUrl(), phase); applySecurityConstraints(object.getValue().getItems(), securityConstraints, globalReadDecision, globalAddDecision, globalModifyDecision, phase); if (object.isEmpty()) { // let's make it explicit SecurityUtil.logSecurityDeny(object, "because the subject has not access to any item"); throw new AuthorizationException("Access denied"); } applySecurityConstraintsItemDef(objectDefinition, new IdentityHashMap<>(), ItemPath.EMPTY_PATH, securityConstraints, globalReadDecision, globalAddDecision, globalModifyDecision, phase); } catch (SecurityViolationException | RuntimeException e) { result.recordFatalError(e); throw e; } }
private <T extends ObjectType> void removeOperationalItems(PrismObject<T> object) { if (object != null) { object.getValue().removeOperationalItems(); } }
OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult); context.checkTaskStop(); if (value instanceof PrismObjectValue && ((PrismObjectValue) value).asObjectable() instanceof ConnectorHostType) { PrismObject<ConnectorHostType> connectorHostTypePrismObject = ((PrismObjectValue) value).asPrismObject(); Set<ConnectorType> newConnectors; long started = operationsHelper.recordStart(context, connectorHostTypePrismObject.asObjectable());
if (value instanceof PrismObjectValue) { @SuppressWarnings({"unchecked", "raw"}) PrismObject<? extends ObjectType> prismObject = ((PrismObjectValue) value).asPrismObject(); ObjectType objectBean = prismObject.asObjectable(); long started = operationsHelper.recordStart(context, objectBean);
@Test public void test010CycleCronLoose() throws Exception { final String TEST_NAME = "test010CycleCronLoose"; final OperationResult result = createResult(TEST_NAME, LOGGER); addObjectFromFile(taskFilename(TEST_NAME)); waitForTaskProgress(taskOid(TEST_NAME), result, 15000, 2000, 2); // Check task status Task task = getTask(taskOid(TEST_NAME), result); AssertJUnit.assertNotNull(task); System.out.println(task.debugDump()); TaskType t = repositoryService.getObject(TaskType.class, taskOid(TEST_NAME), null, result).getValue().getValue(); System.out.println(ObjectTypeUtil.dump(t)); AssertJUnit.assertEquals(TaskExecutionStatus.RUNNABLE, task.getExecutionStatus()); // .. and last run should not be zero AssertJUnit.assertNotNull(task.getLastRunStartTimestamp()); assertFalse(task.getLastRunStartTimestamp() == 0); AssertJUnit.assertNotNull(task.getLastRunFinishTimestamp()); assertFalse(task.getLastRunFinishTimestamp() == 0); // The progress should be at least 2 as the task has run at least twice AssertJUnit.assertTrue("Task has not been executed at least twice", task.getProgress() >= 2); // Test for presence of a result. It should be there and it should // indicate success assertSuccessOrInProgress(task); // Suspend the task (in order to keep logs clean), without much waiting taskManager.suspendTaskQuietly(task, 100, result); }
private SceneImpl visualize(PrismObject<? extends ObjectType> object, SceneImpl owner, VisualizationContext context, Task task, OperationResult result) { SceneImpl scene = new SceneImpl(owner); scene.setChangeType(null); scene.setName(createSceneName(object)); scene.setSourceRelPath(EMPTY_PATH); scene.setSourceAbsPath(EMPTY_PATH); scene.setSourceDefinition(object.getDefinition()); scene.setSourceValue(object.getValue()); scene.setSourceDelta(null); visualizeItems(scene, object.getValue().getItems(), false, context, task, result); return scene; }
@Test public void removeOperationalItems() throws Exception { System.out.println("===[ removeOperationalItems ]==="); PrismObject<RoleType> role = getPrismContext().parseObject(FILE_ROLE_REMOVE_ITEMS); AtomicInteger propertyValuesBefore = new AtomicInteger(0); role.accept(o -> { if (o instanceof PrismPropertyValue) { propertyValuesBefore.incrementAndGet(); System.out.println(((PrismPropertyValue) o).getPath() + ": " + ((PrismPropertyValue) o).getValue()); } }); System.out.println("Property values before: " + propertyValuesBefore); role.getValue().removeOperationalItems(); System.out.println("After operational items removal:\n" + getPrismContext().xmlSerializer().serialize(role)); AtomicInteger propertyValuesAfter = new AtomicInteger(0); role.accept(o -> { if (o instanceof PrismPropertyValue) { propertyValuesAfter.incrementAndGet(); System.out.println(((PrismPropertyValue) o).getPath() + ": " + ((PrismPropertyValue) o).getValue()); } }); System.out.println("Property values after: " + propertyValuesAfter); assertNull("metadata container present", role.findContainer(RoleType.F_METADATA)); assertNull("effectiveStatus present", role.findProperty(ItemPath.create(RoleType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS))); assertNull("assignment[1]/activation/effectiveStatus present", role.findProperty(ItemPath.create(RoleType.F_ASSIGNMENT, 1L, AssignmentType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS))); assertEquals("Wrong property values after", propertyValuesBefore.intValue()-6, propertyValuesAfter.intValue()); }
OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult); context.checkTaskStop(); if (value instanceof PrismObjectValue && ((PrismObjectValue) value).asObjectable() instanceof ResourceType) { PrismObject<ResourceType> resourceTypePrismObject = ((PrismObjectValue) value).asPrismObject(); ResourceType resourceType = resourceTypePrismObject.asObjectable(); long started = operationsHelper.recordStart(context, resourceType);
@NotNull public O asObjectable() { return getValue().asObjectable(); }