public void record(PrismObject<ObjectType> object) { String key = object.asObjectable().getClass().getName(); ObjectTypeStatistics typeStatistics = statisticsMap.computeIfAbsent(key, (k) -> new ObjectTypeStatistics()); typeStatistics.register(object); }
@SuppressWarnings("unused") private void validateIfRequested(PrismObject<?> object, List<String> options, ResponseBuilder builder, Task task, OperationResult parentResult) { if (options != null && options.contains(VALIDATE) && object.asObjectable() instanceof ResourceType) { ValidationResult validationResult = resourceValidator .validate((PrismObject<ResourceType>) object, Scope.THOROUGH, null, task, parentResult); builder.entity(validationResult.toValidationResultType()); // TODO move to parentResult, and return the result! } }
public static <F extends FocusType> void assertNoAssignments(PrismObject<F> user) { F userType = user.asObjectable(); List<AssignmentType> assignments = userType.getAssignment(); assertTrue(user + " does have assignments "+assignments+" while not expecting it", assignments.isEmpty()); }
private MergeConfigurationType selectConfiguration( PrismObject<SystemConfigurationType> systemConfiguration, String mergeConfigurationName) throws ConfigurationException { if (StringUtils.isBlank(mergeConfigurationName)) { throw new IllegalArgumentException("Merge configuration name not specified"); } for (MergeConfigurationType mergeConfiguration: systemConfiguration.asObjectable().getMergeConfiguration()) { if (mergeConfigurationName.equals(mergeConfiguration.getName())) { return mergeConfiguration; } } throw new ConfigurationException("Merge configuration with name '"+mergeConfigurationName+"' was not found"); }
private String getNewObjectLifecycleState(LensFocusContext<AH> focusContext) { PrismObject<AH> focusNew = focusContext.getObjectNew(); AH focusTypeNew = focusNew.asObjectable(); return focusTypeNew.getLifecycleState(); }
private static <O extends ObjectType> boolean isItemLoadable(PrismObject<O> object, ItemPath path) { if (!(object.asObjectable() instanceof ShadowType)) { return false; } return path.startsWithName(ShadowType.F_ATTRIBUTES) || path.startsWithName(ShadowType.F_ASSOCIATION); }
@Override public DeploymentInformationType getDeploymentInformationConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); if (systemConfiguration == null) { return null; } return systemConfiguration.asObjectable().getDeploymentInformation(); }
@Override public List<MergeConfigurationType> getMergeConfiguration(OperationResult parentResult) throws ObjectNotFoundException, SchemaException { PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(parentResult); if (systemConfiguration == null) { return null; } return systemConfiguration.asObjectable().getMergeConfiguration(); }
public static <R extends AbstractRoleType> void assertInducements(PrismObject<R> role, int expectedNumber) { R roleType = role.asObjectable(); assertEquals("Unexepected number of inducements in "+role+": "+roleType.getInducement(), expectedNumber, roleType.getInducement().size()); }
public static <O extends ObjectType> void assertHasOrg(PrismObject<O> object, String orgOid) { for (ObjectReferenceType orgRef: object.asObjectable().getParentOrgRef()) { if (orgOid.equals(orgRef.getOid())) { return; } } AssertJUnit.fail(object + " does not have org " + orgOid); }
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; } }
public static <O extends ObjectType> boolean hasOrg(PrismObject<O> user, String orgOid, QName relation) { for (ObjectReferenceType orgRef: user.asObjectable().getParentOrgRef()) { if (orgOid.equals(orgRef.getOid()) && getPrismContext().relationMatches(relation, orgRef.getRelation())) { return true; } } return false; }
@Test public void testUnmarshallResource() throws Exception { System.out.println("===[ testUnmarshallResource ]==="); // WHEN ResourceType resourceType = (ResourceType) PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml")).asObjectable(); // THEN assertCapabilities(resourceType); }
@SuppressWarnings("unchecked") public static void mockGetSystemConfiguration(RepositoryService repository, File file) throws JAXBException, ObjectNotFoundException, SchemaException, IOException { SystemConfigurationType systemConfiguration = (SystemConfigurationType) PrismTestUtil.parseObject(file).asObjectable(); when( repository.getObject(eq(SystemConfigurationType.class), eq(SystemObjectsType.SYSTEM_CONFIGURATION.value()), any(Collection.class), any(OperationResult.class))).thenReturn( systemConfiguration.asPrismObject()); }
@Override public MidPointUserProfilePrincipal getPrincipal(PrismObject<UserType> user, AuthorizationTransformer authorizationTransformer, OperationResult result) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { if (user == null) { return null; } PrismObject<SystemConfigurationType> systemConfiguration = getSystemConfiguration(result); LifecycleStateModelType lifecycleModel = getLifecycleModel(user, systemConfiguration); userComputer.recompute(user, lifecycleModel); MidPointUserProfilePrincipal principal = new MidPointUserProfilePrincipal(user.asObjectable()); initializePrincipalFromAssignments(principal, systemConfiguration, authorizationTransformer); return principal; }
@Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); certificationDefinition = repoAddObjectFromFile(CERT_DEF_USER_ASSIGNMENT_BASIC_FILE, AccessCertificationDefinitionType.class, initResult).asObjectable(); // to test MID-3838 assignFocus(UserType.class, USER_JACK_OID, UserType.COMPLEX_TYPE, USER_GUYBRUSH_OID, SchemaConstants.ORG_DEPUTY, null, initTask, initResult); }
private static PropertyDelta<SynchronizationSituationType> createSynchronizationSituationDelta( PrismObject<ShadowType> shadow, SynchronizationSituationType situation, PrismContext prismContext) { if (situation == null) { SynchronizationSituationType oldValue = shadow.asObjectable().getSynchronizationSituation(); return prismContext.deltaFactory().property().createModificationDeleteProperty(ShadowType.F_SYNCHRONIZATION_SITUATION, shadow.getDefinition(), oldValue); } return prismContext.deltaFactory().property().createModificationReplaceProperty(ShadowType.F_SYNCHRONIZATION_SITUATION, shadow.getDefinition(), situation); }
protected void waitForCampaignTasks(String campaignOid, int timeout, OperationResult result) throws CommonException { ObjectQuery query = prismContext.queryFor(TaskType.class) .item(TaskType.F_OBJECT_REF).ref(campaignOid) .build(); SearchResultList<PrismObject<TaskType>> campaignTasks = repositoryService.searchObjects(TaskType.class, query, null, result); for (PrismObject<TaskType> campaignTask : campaignTasks) { if (campaignTask.asObjectable().getExecutionStatus() != TaskExecutionStatusType.CLOSED && campaignTask.asObjectable().getExecutionStatus() != TaskExecutionStatusType.SUSPENDED) { waitForTaskFinish(campaignTask.getOid(), false, timeout); } } }
protected void checkAllCases(Collection<AccessCertificationCaseType> caseList) throws ConfigurationException, ObjectNotFoundException, SchemaException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { assertEquals("Wrong number of certification cases", 5, caseList.size()); UserType jack = getUser(USER_JACK_OID).asObjectable(); checkCaseSanity(caseList, USER_JACK_OID, roleATest2aOid, jack); checkCaseSanity(caseList, USER_JACK_OID, roleATest2bOid, jack); checkCaseSanity(caseList, USER_JACK_OID, roleATest2cOid, jack); checkCaseSanity(caseList, USER_JACK_OID, roleATest3aOid, jack); checkCaseSanity(caseList, USER_JACK_OID, roleATest3bOid, jack); }
private void assertValidityTimestamp(PrismObject<UserType> user, long lowerBound, long upperBound) { ActivationType activation = user.asObjectable().getActivation(); assertNotNull("No activation in "+user, activation); XMLGregorianCalendar validityChangeTimestamp = activation.getValidityChangeTimestamp(); assertNotNull("No validityChangeTimestamp in "+user, validityChangeTimestamp); long validityMillis = XmlTypeConverter.toMillis(validityChangeTimestamp); if (validityMillis >= lowerBound && validityMillis <= upperBound) { return; } AssertJUnit.fail("Expected validityChangeTimestamp to be between "+lowerBound+" and "+upperBound+", but it was "+validityMillis); }