public void setOid(String oid) { taskPrism.setOid(oid); }
public void setOid(String oid) { checkMutability(); this.oid = oid; if (objectToAdd != null) { objectToAdd.setOid(oid); } }
public void setOid(String value) { asPrismContainer().setOid(value); }
/** * Sets oid to the field but also to the deltas (if applicable). */ public void setOid(String oid) { this.oid = oid; if (primaryDelta != null && !primaryDelta.isImmutable()) { primaryDelta.setOid(oid); } if (objectNew != null) { objectNew.setOid(oid); } }
private <C extends Containerable> void parseContainerValueToContainer(PrismContainer<C> container, XNodeImpl node, @NotNull ParsingContext pc) throws SchemaException { container.add(parseContainerValue(node, container.getDefinition(), pc)); if (node instanceof MapXNodeImpl && container instanceof PrismObject) { MapXNodeImpl map = (MapXNodeImpl) node; PrismObject object = (PrismObject) container; object.setOid(getOid(map)); object.setVersion(getVersion(map)); } }
public void generateFocusOidIfNeeded(ModelContext<?> modelContext, ObjectDelta<? extends ObjectType> change) { if (modelContext.getFocusContext().getOid() != null) { return; } String newOid = OidUtil.generateOid(); LOGGER.trace("This is ADD operation with no focus OID provided. Generated new OID to be used: {}", newOid); if (change.getChangeType() != ADD) { throw new IllegalStateException("Change type is not ADD for no-oid focus situation: " + change); } else if (change.getObjectToAdd() == null) { throw new IllegalStateException("Object to add is null for change: " + change); } else if (change.getObjectToAdd().getOid() != null) { throw new IllegalStateException("Object to add has already an OID present: " + change); } change.getObjectToAdd().setOid(newOid); ((LensFocusContext<?>) modelContext.getFocusContext()).setOid(newOid); }
@Override public <T extends ObjectType> String addObject(PrismObject<T> newObject, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { ObjectDelta<T> delta = DeltaFactory.Object.createAddDelta(newObject); Collection<ObjectDelta<? extends ObjectType>> deltaCollection = MiscSchemaUtil.createCollection(delta); Collection<ObjectDeltaOperation<? extends ObjectType>> executedChanges = modelService.executeChanges(deltaCollection, options, getCurrentTask(), getCurrentResult()); String oid = ObjectDeltaOperation.findAddDeltaOid(executedChanges, newObject); newObject.setOid(oid); return oid; }
protected <O extends ObjectType> String addObject(PrismObject<O> object, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { ObjectDelta<O> addDelta = object.createAddDelta(); assertFalse("Immutable object provided?",addDelta.getObjectToAdd().isImmutable()); Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = executeChanges(addDelta, options, task, result); object.setOid(ObjectDeltaOperation.findFocusDeltaOidInCollection(executedDeltas)); return object.getOid(); }
private <T extends ObjectType> void generateObjectOidIfNeeded(ObjectDelta<T> focusDelta, ModelContext<T> modelContext) { if (focusDelta.isAdd()) { if (focusDelta.getObjectToAdd().getOid() == null) { String newOid = OidUtil.generateOid(); focusDelta.getObjectToAdd().setOid(newOid); ((LensFocusContext<?>) modelContext.getFocusContext()).setOid(newOid); } } }
@Test public void test108AddTableOverwriteExisting() throws Exception { PrismObject<LookupTableType> table = prismContext.parseObject(new File(TEST_DIR, "table-1.xml")); OperationResult result = new OperationResult("test108AddTableOverwriteExisting"); table.setOid(tableOid); // doesn't work without specifying OID tableOid = repositoryService.addObject(table, RepoAddOptions.createOverwrite(), result); // rereading, as repo strips cases from the campaign (!) PrismObject<LookupTableType> expected = prismContext.parseObject(new File(TEST_DIR, "table-1.xml")); checkTable(tableOid, expected, result); }
protected PrismObject<ResourceType> addResourceFromFile(File file, String connectorType, boolean overwrite, OperationResult result) throws JAXBException, SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { LOGGER.trace("addObjectFromFile: {}, connector type {}", file, connectorType); PrismObject<ResourceType> resource = prismContext.parseObject(file); fillInConnectorRef(resource, connectorType, result); CryptoUtil.encryptValues(protector, resource); display("Adding resource ", resource); RepoAddOptions options = null; if (overwrite){ options = RepoAddOptions.createOverwrite(); } String oid = repositoryService.addObject(resource, options, result); resource.setOid(oid); return resource; }
private void checkTable(String tableOid, PrismObject<LookupTableType> expectedObject, OperationResult result) throws SchemaException, ObjectNotFoundException { SelectorOptions<GetOperationOptions> retrieve = SelectorOptions.create(prismContext.toUniformPath(F_ROW), GetOperationOptions.createRetrieve(INCLUDE)); PrismObject<LookupTableType> table = repositoryService.getObject(LookupTableType.class, tableOid, Arrays.asList(retrieve), result); expectedObject.setOid(tableOid); PrismAsserts.assertEquivalent("Table is not as expected", expectedObject, table); }
@Test public void test108AddCampaignOverwriteExisting() throws Exception { PrismObject<AccessCertificationCampaignType> campaign = prismContext.parseObject(CAMPAIGN_1_FILE); OperationResult result = new OperationResult("test108AddCampaignOverwriteExisting"); campaign.setOid(campaign1Oid); // doesn't work without specifying OID campaign1Oid = repositoryService.addObject(campaign, RepoAddOptions.createOverwrite(), result); checkCampaign(campaign1Oid, result, prismContext.parseObject(CAMPAIGN_1_FILE), null, null); checksCountsStandard(result); }
public PrismObject<ShadowType> addDiscoveredRepositoryShadow(ProvisioningContext ctx, PrismObject<ShadowType> resourceShadow, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, EncryptionException { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Adding new shadow from resource object: {}", resourceShadow.debugDump()); } PrismObject<ShadowType> repoShadow = createRepositoryShadow(ctx, resourceShadow); ConstraintsChecker.onShadowAddOperation(repoShadow.asObjectable()); String oid = repositoryService.addObject(repoShadow, null, parentResult); repoShadow.setOid(oid); LOGGER.debug("Added new shadow (from resource object): {}", repoShadow); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Added new shadow (from resource object):\n{}", repoShadow.debugDump()); } return repoShadow; }
private void checkCampaign(String campaignOid, OperationResult result, PrismObject<AccessCertificationCampaignType> expectedObject, List<ItemDelta> modifications, Integer expectedVersion) throws SchemaException, ObjectNotFoundException, IOException { expectedObject.setOid(campaignOid); if (modifications != null) { ItemDeltaCollectionsUtil.applyTo(modifications, expectedObject); } LOGGER.trace("Expected object = \n{}", expectedObject.debugDump()); PrismObject<AccessCertificationCampaignType> campaign = getFullCampaign(campaignOid, result); LOGGER.trace("Actual object from repo = \n{}", campaign.debugDump()); PrismAsserts.assertEquivalent("Campaign is not as expected", expectedObject, campaign); if (expectedVersion != null) { AssertJUnit.assertEquals("Incorrect version", (int) expectedVersion, Integer.parseInt(campaign.getVersion())); } }
protected PrismObject<ResourceType> addResource(OperationResult result) throws JAXBException, SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { PrismObject<ResourceType> resource = prismContext.parseObject(getResourceFile()); fillInConnectorRef(resource, MANUAL_CONNECTOR_TYPE, result); fillInAdditionalConnectorRef(resource, "csv", CSV_CONNECTOR_TYPE, result); CryptoUtil.encryptValues(protector, resource); display("Adding resource ", resource); String oid = repositoryService.addObject(resource, null, result); resource.setOid(oid); return resource; }
protected PrismObject<UserType> createUserFoo() throws SchemaException { PrismObjectDefinition<UserType> userDef = getUserTypeDefinition(); PrismObject<UserType> user = userDef.instantiate(); user.setOid(USER_FOO_OID); user.setPropertyRealValue(UserType.F_NAME, createPolyString("foo")); PrismProperty<PolyString> anamesProp = user.findOrCreateProperty(UserType.F_ADDITIONAL_NAMES); anamesProp.addRealValue(createPolyString("foobar")); return user; }
@Test public void test700PrepareForQueryCases() throws Exception { OperationResult result = new OperationResult("test700PrepareForQueryCases"); // overwrite the campaign PrismObject<AccessCertificationCampaignType> campaign = prismContext.parseObject(CAMPAIGN_1_FILE); campaign.setOid(campaign1Oid); // doesn't work without specifying OID campaign1Oid = repositoryService.addObject(campaign, RepoAddOptions.createOverwrite(), result); checkCampaign(campaign1Oid, result, prismContext.parseObject(CAMPAIGN_1_FILE), null, null); PrismObject<AccessCertificationCampaignType> campaign2 = prismContext.parseObject(CAMPAIGN_2_FILE); campaign2Oid = repositoryService.addObject(campaign2, null, result); checkCampaign(campaign2Oid, result, prismContext.parseObject(CAMPAIGN_2_FILE), null, null); }
private void setCommonEventProperties(PrismObject<?> object, Task task, ModelContext<?> modelContext, Event event) { if (task.getOwner() != null) { event.setRequester(new SimpleObjectRefImpl(notificationsUtil, task.getOwner().asObjectable())); } else { LOGGER.debug("No owner for task " + task + ", therefore no requester will be set for event " + event.getId()); } // if no OID in object (occurs in 'add' operation), we artificially insert it into the object) if (object.getOid() == null && modelContext.getFocusContext() != null && modelContext.getFocusContext().getOid() != null) { object = object.clone(); object.setOid(modelContext.getFocusContext().getOid()); } event.setRequestee(new SimpleObjectRefImpl(notificationsUtil, (ObjectType) object.asObjectable())); } }
private void addTask(String oid, String name, String ownerOid, String handlerUri, Task execTask, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { PrismObject<TaskType> task = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class).instantiate(); task.setOid(oid); TaskType taskType = task.asObjectable(); taskType.setName(createPolyStringType(name)); if (ownerOid != null) { ObjectReferenceType ownerRef = new ObjectReferenceType(); ownerRef.setOid(ownerOid); taskType.setOwnerRef(ownerRef); } taskType.setHandlerUri(handlerUri); modelService.executeChanges(MiscSchemaUtil.createCollection(task.createAddDelta()), null, execTask, result); }