From 0f0a11f58e8a877384da83a4e4cd2e23126a54a6 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Tue, 7 Apr 2015 23:43:42 +0200 Subject: [PATCH] Refactoring Item, ItemDelta and some other: adding definition to as a type parameter. Also fixing parts of refined schema (MID-2285) --- .../component/wizard/resource/NameStep.java | 8 +- .../page/admin/resources/PageResources.java | 7 +- .../dto/AccountContentDataProvider.java | 4 +- .../web/page/admin/server/PageTaskEdit.java | 2 +- .../midpoint/common/StaticExpressionUtil.java | 10 +- .../midpoint/common/crypto/CryptoUtil.java | 2 +- .../LayerRefinedAttributeDefinition.java | 5 +- .../common/refinery/TestRefinedSchema.java | 2 +- .../midpoint/prism/ComplexTypeDefinition.java | 4 +- .../com/evolveum/midpoint/prism/Item.java | 44 +-- .../midpoint/prism/ItemDefinition.java | 16 +- .../midpoint/prism/PartiallyResolvedItem.java | 10 +- .../midpoint/prism/PrismContainer.java | 160 +++++----- .../prism/PrismContainerDefinition.java | 62 ++-- .../midpoint/prism/PrismContainerValue.java | 284 ++++++++++-------- .../evolveum/midpoint/prism/PrismObject.java | 70 +++-- .../midpoint/prism/PrismProperty.java | 16 +- .../prism/PrismPropertyDefinition.java | 2 +- .../midpoint/prism/PrismPropertyValue.java | 2 +- .../midpoint/prism/PrismReference.java | 10 +- .../prism/PrismReferenceDefinition.java | 4 +- .../midpoint/prism/PrismReferenceValue.java | 10 +- .../evolveum/midpoint/prism/PrismValue.java | 2 +- .../midpoint/prism/delta/ContainerDelta.java | 14 +- .../midpoint/prism/delta/ItemDelta.java | 96 +++--- .../midpoint/prism/delta/ObjectDelta.java | 65 ++-- .../prism/delta/PartiallyResolvedDelta.java | 13 +- .../midpoint/prism/delta/PropertyDelta.java | 26 +- .../midpoint/prism/delta/ReferenceDelta.java | 22 +- .../prism/json/PrismJasonProcessor.java | 36 ++- .../midpoint/prism/parser/JaxbDomHack.java | 12 +- .../midpoint/prism/parser/QueryConvertor.java | 6 +- .../midpoint/prism/parser/XNodeProcessor.java | 16 +- .../prism/parser/XNodeSerializer.java | 12 +- .../midpoint/prism/schema/SchemaRegistry.java | 10 +- .../midpoint/prism/util/CloneUtil.java | 10 +- .../midpoint/prism/util/PrismAsserts.java | 22 +- .../midpoint/prism/util/RawTypeUtil.java | 38 ++- .../midpoint/prism/xjc/AnyArrayList.java | 8 +- .../prism/xml/ns/_public/types_3/RawType.java | 24 +- .../evolveum/midpoint/prism/TestDelta.java | 8 +- .../midpoint/schema/DeltaConvertor.java | 14 +- .../processor/ResourceAttributeContainer.java | 4 +- .../midpoint/schema/util/MiscSchemaUtil.java | 2 +- .../midpoint/schema/util/ReportTypeUtil.java | 2 +- .../schema/util/ResourceTypeUtil.java | 7 +- .../midpoint/schema/util/ShadowUtil.java | 4 +- .../midpoint/schema/TestDeltaConverter.java | 6 +- .../schema/TestParseGenericObject.java | 4 +- .../midpoint/schema/TestParseResource.java | 6 +- .../midpoint/schema/TestParseUser.java | 2 +- .../com/evolveum/midpoint/util/Validator.java | 35 +++ .../midpoint/model/api/ModelService.java | 6 +- .../model/api/expr/MidpointFunctions.java | 4 +- .../model/common/expression/Expression.java | 22 +- .../ExpressionEvaluationContext.java | 16 +- .../expression/ExpressionEvaluator.java | 4 +- .../ExpressionEvaluatorFactory.java | 6 +- .../common/expression/ExpressionFactory.java | 16 +- .../common/expression/ExpressionUtil.java | 56 ++-- .../expression/ExpressionVariables.java | 10 +- .../common/expression/ItemDeltaItem.java | 92 +++--- .../common/expression/ObjectDeltaObject.java | 65 ++-- .../model/common/expression/Source.java | 10 +- .../model/common/expression/SourceTriple.java | 15 +- .../AbstractSearchExpressionEvaluator.java | 24 +- ...alueTransformationExpressionEvaluator.java | 49 +-- .../evaluator/AsIsExpressionEvaluator.java | 14 +- .../AsIsExpressionEvaluatorFactory.java | 8 +- ...gnmentTargetSearchExpressionEvaluator.java | 6 +- ...argetSearchExpressionEvaluatorFactory.java | 10 +- ...ssociationFromLinkExpressionEvaluator.java | 5 +- ...ionFromLinkExpressionEvaluatorFactory.java | 6 +- ...iationTargetSearchExpressionEvaluator.java | 8 +- ...argetSearchExpressionEvaluatorFactory.java | 13 +- .../GenerateExpressionEvaluator.java | 10 +- .../GenerateExpressionEvaluatorFactory.java | 8 +- .../evaluator/LiteralExpressionEvaluator.java | 2 +- .../LiteralExpressionEvaluatorFactory.java | 8 +- .../evaluator/PathExpressionEvaluator.java | 16 +- .../PathExpressionEvaluatorFactory.java | 6 +- .../script/ScriptExpressionEvaluator.java | 7 +- .../ScriptExpressionEvaluatorFactory.java | 6 +- .../model/common/mapping/Mapping.java | 88 +++--- .../model/common/mapping/MappingFactory.java | 6 +- .../common/expression/TestExpression.java | 4 +- .../common/expression/TestExpressionUtil.java | 11 +- .../common/mapping/MappingTestEvaluator.java | 45 +-- .../common/mapping/TestMappingComplex.java | 15 +- .../mapping/TestMappingDynamicSimple.java | 38 +-- .../mapping/TestMappingDynamicSysVar.java | 45 +-- .../model/common/mapping/TestMappingTime.java | 20 +- .../midpoint/model/impl/ModelCrudService.java | 2 +- .../model/impl/ModelObjectResolver.java | 6 +- .../midpoint/model/impl/ModelRestService.java | 2 + .../impl/controller/ModelController.java | 270 +++++++++++------ .../model/impl/expr/ExpressionHandler.java | 10 +- .../impl/expr/MidpointFunctionsImpl.java | 2 +- .../model/impl/importer/ObjectImporter.java | 6 +- .../model/impl/lens/AssignmentEvaluator.java | 21 +- .../model/impl/lens/AssignmentPath.java | 5 +- .../impl/lens/AssignmentPathSegment.java | 11 +- .../impl/lens/AssignmentPathVariables.java | 27 +- .../model/impl/lens/ChangeExecutor.java | 6 +- .../midpoint/model/impl/lens/Clockwork.java | 2 +- .../model/impl/lens/Construction.java | 52 ++-- .../impl/lens/EvaluatedAssignmentImpl.java | 16 +- .../model/impl/lens/ItemValueWithOrigin.java | 33 +- .../model/impl/lens/LensDebugListener.java | 4 +- .../model/impl/lens/LensElementContext.java | 6 +- .../model/impl/lens/LensFocusContext.java | 12 +- .../impl/lens/LensProjectionContext.java | 26 +- .../midpoint/model/impl/lens/LensUtil.java | 126 ++++---- .../lens/projector/ActivationProcessor.java | 68 ++--- .../lens/projector/AssignmentProcessor.java | 31 +- .../projector/ConsolidationProcessor.java | 156 +++++----- .../lens/projector/CredentialsProcessor.java | 8 +- .../impl/lens/projector/InboundProcessor.java | 18 +- .../projector/MappingEvaluationHelper.java | 28 +- .../MappingEvaluatorHelperParams.java | 16 +- .../impl/lens/projector/MappingExtractor.java | 7 +- .../lens/projector/MappingInitializer.java | 7 +- .../projector/ObjectTemplateProcessor.java | 31 +- .../lens/projector/OutboundProcessor.java | 17 +- .../projector/PasswordPolicyProcessor.java | 6 +- .../projector/ProjectionValuesProcessor.java | 4 +- .../projector/ReconciliationProcessor.java | 56 ++-- .../actions/DiscoverConnectorsExecutor.java | 6 +- .../impl/security/UserProfileServiceImpl.java | 5 +- .../CorrelationConfirmationEvaluator.java | 6 +- .../midpoint/model/impl/util/Utils.java | 10 +- .../impl/lens/TestAssignmentEvaluator.java | 28 +- .../impl/lens/TestAssignmentProcessor.java | 17 +- .../impl/util/mock/MockLensDebugListener.java | 5 +- .../model/intest/TestModelCrudService.java | 8 +- .../midpoint/model/intest/TestOrgStruct.java | 24 +- .../model/intest/TestOrgStructMeta.java | 4 +- .../midpoint/model/intest/TestRbac.java | 2 +- .../midpoint/model/intest/TestResources.java | 4 +- .../model/intest/gensync/TestEditSchema.java | 94 +++++- .../util/ProfilingLensDebugListener.java | 18 +- .../test/AbstractModelIntegrationTest.java | 12 +- .../api/transports/SimpleSmsTransport.java | 6 +- .../impl/handlers/BaseHandler.java | 10 +- .../impl/helpers/BaseHelper.java | 10 +- .../impl/notifiers/GeneralNotifier.java | 2 +- .../midpoint/report/impl/ReportFunctions.java | 18 +- .../report/impl/ReportManagerImpl.java | 5 +- .../midpoint/report/impl/ReportUtils.java | 28 +- ...InitializeLoopThroughApproversInLevel.java | 10 +- .../general/GcpExpressionHelper.java | 6 +- .../assignments/AddAssignmentAspect.java | 2 +- .../wf/impl/TestUserChangeApproval.java | 8 +- .../provisioning/impl/ResourceManager.java | 71 +++-- .../provisioning/impl/ShadowCache.java | 43 +-- .../provisioning/impl/ShadowManager.java | 8 +- .../provisioning/ProvisioningTestUtil.java | 4 +- .../provisioning/test/ucf/TestUcfDummy.java | 6 +- .../midpoint/repo/sql/testing/CarefulAnt.java | 4 +- .../sql/testing/ResourceCarefulAntUtil.java | 8 +- .../midpoint/repo/sql/ResourceModifyTest.java | 6 +- .../repo/sql/util/SimpleTaskAdapter.java | 11 +- .../src/test/resources/logback-test.xml | 6 +- .../src/test/resources/logging.properties | 4 + .../repo/sql/SqlRepositoryServiceImpl.java | 31 +- .../repo/sql/data/common/RObject.java | 4 +- .../sql/data/common/any/RAnyConverter.java | 4 +- .../data/common/any/RAssignmentExtension.java | 4 +- .../test/AbstractIntegrationTest.java | 2 +- .../security/impl/SecurityEnforcerImpl.java | 6 +- .../midpoint/init/RepositoryFactory.java | 13 +- .../com/evolveum/midpoint/task/api/Task.java | 10 +- .../task/quartzimpl/TaskQuartzImpl.java | 64 ++-- .../quartzimpl/MockSingleTaskHandler.java | 4 +- .../TestQuartzTaskManagerContract.java | 4 +- .../testing/consistency/ConsistencyTest.java | 2 +- .../midpoint/testing/sanity/TestSanity.java | 2 +- 177 files changed, 2106 insertions(+), 1721 deletions(-) create mode 100644 infra/util/src/main/java/com/evolveum/midpoint/util/Validator.java create mode 100644 repo/repo-sql-impl-test/src/test/resources/logging.properties diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/NameStep.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/NameStep.java index 83ad87582a2..e5641bc0126 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/NameStep.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/NameStep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.logging.LoggingUtils; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -372,10 +373,11 @@ private void discoverConnectorsPerformed(AjaxRequestTarget target) { private void discoverConnectors(ConnectorHostType host) { PageBase page = (PageBase) getPage(); - OperationResult result = new OperationResult(OPERATION_DISCOVER_CONNECTORS); + Task task = page.createSimpleTask(OPERATION_DISCOVER_CONNECTORS); + OperationResult result = task.getResult(); try { ModelService model = page.getModelService(); - model.discoverConnectors(host, result); + model.discoverConnectors(host, task, result); } catch (Exception ex) { LoggingUtils.logException(LOGGER, "Couldn't discover connectors", ex); } finally { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java index 56e6ad00800..49721acdc50 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/PageResources.java @@ -49,6 +49,7 @@ import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem; import com.evolveum.midpoint.web.component.util.LoadableModel; import com.evolveum.midpoint.web.component.util.SelectableBean; +import com.evolveum.midpoint.web.page.PageBase; import com.evolveum.midpoint.web.page.admin.configuration.PageDebugView; import com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction; import com.evolveum.midpoint.web.page.admin.resources.component.ContentPanel; @@ -592,7 +593,9 @@ private void deleteResourceConfirmedPerformed(AjaxRequestTarget target) { private void discoveryRemotePerformed(AjaxRequestTarget target) { target.add(getFeedbackPanel()); - OperationResult result = new OperationResult(OPERATION_CONNECTOR_DISCOVERY); + PageBase page = (PageBase) getPage(); + Task task = page.createSimpleTask(OPERATION_CONNECTOR_DISCOVERY); + OperationResult result = task.getResult(); List> selected = WebMiscUtil.getSelectedData(getConnectorHostTable()); if (selected.isEmpty()) { warn(getString("pageResources.message.noHostSelected")); @@ -602,7 +605,7 @@ private void discoveryRemotePerformed(AjaxRequestTarget target) { for (SelectableBean bean : selected) { ConnectorHostType host = bean.getValue(); try { - getModelService().discoverConnectors(host, result); + getModelService().discoverConnectors(host, task, result); } catch (Exception ex) { result.recordFatalError("Fail to discover connectors on host '" + host.getHostname() + ":" + host.getPort() + "'", ex); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/dto/AccountContentDataProvider.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/dto/AccountContentDataProvider.java index 5d5cc982d8e..b742d35874f 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/dto/AccountContentDataProvider.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/dto/AccountContentDataProvider.java @@ -195,7 +195,7 @@ protected int internalSize() { } private AccountContentDto createAccountContentDto(PrismObject object, OperationResult result) - throws SchemaException, SecurityViolationException { + throws SchemaException, SecurityViolationException, ConfigurationException { AccountContentDto dto = new AccountContentDto(); dto.setAccountName(WebMiscUtil.getName(object)); @@ -231,7 +231,7 @@ protected void addInlineMenuToDto(AccountContentDto dto) { } private PrismObject loadOwner(String accountOid, OperationResult result) - throws SecurityViolationException, SchemaException { + throws SecurityViolationException, SchemaException, ConfigurationException { Task task = getPage().createSimpleTask(OPERATION_LOAD_OWNER); try { diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTaskEdit.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTaskEdit.java index cdd03359086..eae4d4c455b 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTaskEdit.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTaskEdit.java @@ -926,7 +926,7 @@ private void savePerformed(AjaxRequestTarget target) { } private List> prepareChanges(Task updatedTask) { - Collection> modifications = updatedTask.getPendingModifications(); + Collection> modifications = updatedTask.getPendingModifications(); List> retval = new ArrayList>(); retval.add(ObjectDelta.createModifyDelta(updatedTask.getOid(), modifications, TaskType.class, getPrismContext())); return retval; diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/StaticExpressionUtil.java b/infra/common/src/main/java/com/evolveum/midpoint/common/StaticExpressionUtil.java index e968db45a30..967debb1b5d 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/StaticExpressionUtil.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/StaticExpressionUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,10 +94,10 @@ public static Collection getPropertyStaticRealValues(ExpressionType expre } - public static Item parseValueElements(Collection valueElements, ItemDefinition outputDefinition, + public static Item parseValueElements(Collection valueElements, ID outputDefinition, String contextDescription, PrismContext prismContext) throws SchemaException { - Item output = null; + Item output = null; XNodeProcessor xnodeProcessor = prismContext.getXnodeProcessor(); for (Object valueElement: valueElements) { @@ -120,7 +120,7 @@ public static Item parseValueElements(Collection va RawType rawType = (RawType)jaxbElement.getValue(); //Item elementItem = xnodeProcessor.parseItem(rawType.getXnode(), outputDefinition.getName(), outputDefinition); - Item elementItem = rawType.getParsedItem(outputDefinition); + Item elementItem = rawType.getParsedItem(outputDefinition); if (output == null) { output = elementItem; } else { @@ -130,7 +130,7 @@ public static Item parseValueElements(Collection va return output; } - public static List> serializeValueElements(Item item, String contextDescription) throws SchemaException { + public static List> serializeValueElements(Item item, String contextDescription) throws SchemaException { if (item == null) { return null; } diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/crypto/CryptoUtil.java b/infra/common/src/main/java/com/evolveum/midpoint/common/crypto/CryptoUtil.java index fc936053a2f..b9471b4a53c 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/crypto/CryptoUtil.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/crypto/CryptoUtil.java @@ -237,7 +237,7 @@ public void visit(Visitable visitable){ checkEncrypted(pval); } }; - for (ItemDelta delta: modifications) { + for (ItemDelta delta: modifications) { try { delta.accept(visitor); } catch (IllegalStateException e) { diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedAttributeDefinition.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedAttributeDefinition.java index c747574b0f1..47f8dc85403 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedAttributeDefinition.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedAttributeDefinition.java @@ -23,6 +23,7 @@ import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; import com.evolveum.midpoint.prism.path.ItemPath; @@ -349,12 +350,12 @@ public void setDynamic(boolean dynamic) { } @Override - public boolean isValidFor(QName elementQName, Class clazz) { + public boolean isValidFor(QName elementQName, Class clazz) { return isValidFor(elementQName, clazz, false); } @Override - public boolean isValidFor(QName elementQName, Class clazz, boolean caseInsensitive) { + public boolean isValidFor(QName elementQName, Class clazz, boolean caseInsensitive) { return refinedAttributeDefinition.isValidFor(elementQName, clazz, caseInsensitive); } diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java b/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java index 4954e5f471f..c4627f943a7 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java @@ -311,7 +311,7 @@ public void testApplyAttributeDefinition() throws JAXBException, SchemaException System.out.println(attributesContainer.debugDump()); // WHEN - attributesContainer.applyDefinition(defaultAccountDefinition.toResourceAttributeContainerDefinition(), true); + attributesContainer.applyDefinition((PrismContainerDefinition)defaultAccountDefinition.toResourceAttributeContainerDefinition(), true); // THEN System.out.println("Parsed account:"); diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/ComplexTypeDefinition.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/ComplexTypeDefinition.java index 3428207004b..5f8ce8c93b6 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/ComplexTypeDefinition.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/ComplexTypeDefinition.java @@ -217,7 +217,7 @@ public T findItemDefinition(QName name, Class claz return null; } - public T findItemDefinition(ItemPath path, Class clazz) { + public ID findItemDefinition(ItemPath path, Class clazz) { while (!path.isEmpty() && !(path.first() instanceof NameItemPathSegment)) { path = path.rest(); } @@ -227,7 +227,7 @@ public T findItemDefinition(ItemPath path, Class c QName firstName = ((NameItemPathSegment)path.first()).getName(); for (ItemDefinition def : getDefinitions()) { if (firstName.equals(def.getName())) { - return def.findItemDefinition(path.rest(), clazz); + return (ID) def.findItemDefinition(path.rest(), clazz); } } return null; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/Item.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/Item.java index 80b37100906..36f4eb7d1ff 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/Item.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/Item.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ * * @author Radovan Semancik */ -public abstract class Item implements Itemable, DebugDumpable, Visitable, PathVisitable, Serializable, Revivable { +public abstract class Item implements Itemable, DebugDumpable, Visitable, PathVisitable, Serializable, Revivable { private static final long serialVersionUID = 510000191615288733L; @@ -57,7 +57,7 @@ public abstract class Item implements Itemable, DebugDumpa // It may not work perfectly, but basic things should work protected QName elementName; protected PrismValue parent; - protected ItemDefinition definition; + protected D definition; private List values = new ArrayList(); private transient Map userData = new HashMap<>();; @@ -85,7 +85,7 @@ public abstract class Item implements Itemable, DebugDumpa * The constructors should be used only occasionally (if used at all). * Use the factory methods in the ResourceObjectDefintion instead. */ - Item(QName elementName, ItemDefinition definition, PrismContext prismContext) { + Item(QName elementName, D definition, PrismContext prismContext) { super(); this.elementName = elementName; this.definition = definition; @@ -100,7 +100,7 @@ public abstract class Item implements Itemable, DebugDumpa * * @return applicable property definition */ - public ItemDefinition getDefinition() { + public D getDefinition() { return definition; } @@ -145,7 +145,7 @@ public void setElementName(QName elementName) { * * @param definition the definition to set */ - public void setDefinition(ItemDefinition definition) { + public void setDefinition(D definition) { checkDefinition(definition); this.definition = definition; } @@ -433,7 +433,7 @@ public void normalize() { /** * Merge all the values of other item to this item. */ - public void merge(Item otherItem) throws SchemaException { + public void merge(Item otherItem) throws SchemaException { for (V otherValue: otherItem.getValues()) { if (!contains(otherValue)) { add((V) otherValue.clone()); @@ -443,19 +443,19 @@ public void merge(Item otherItem) throws SchemaException { public abstract Object find(ItemPath path); - public abstract PartiallyResolvedItem findPartial(ItemPath path); + public abstract PartiallyResolvedItem findPartial(ItemPath path); - public Collection diff(Item other) { + public Collection diff(Item other) { return diff(other, true, false); } - public Collection diff(Item other, boolean ignoreMetadata, boolean isLiteral) { + public Collection diff(Item other, boolean ignoreMetadata, boolean isLiteral) { Collection itemDeltas = new ArrayList(); diffInternal(other, itemDeltas, ignoreMetadata, isLiteral); return itemDeltas; } - protected void diffInternal(Item other, Collection deltas, + protected void diffInternal(Item other, Collection deltas, boolean ignoreMetadata, boolean isLiteral) { ItemDelta delta = createDelta(); if (other == null) { @@ -508,7 +508,7 @@ protected void diffInternal(Item other, Collection delta } } - protected ItemDelta fixupDelta(ItemDelta delta, Item other, + protected ItemDelta fixupDelta(ItemDelta delta, Item other, boolean ignoreMetadata) { return delta; } @@ -517,9 +517,9 @@ protected ItemDelta fixupDelta(ItemDelta delta, Item other, * Creates specific subclass of ItemDelta appropriate for type of item that this definition * represents (e.g. PropertyDelta, ContainerDelta, ...) */ - public abstract ItemDelta createDelta(); + public abstract ItemDelta createDelta(); - public abstract ItemDelta createDelta(ItemPath path); + public abstract ItemDelta createDelta(ItemPath path); @Override public void accept(Visitor visitor) { @@ -540,11 +540,11 @@ public void accept(Visitor visitor, ItemPath path, boolean recursive) { } } - public void applyDefinition(ItemDefinition definition) throws SchemaException { + public void applyDefinition(D definition) throws SchemaException { applyDefinition(definition, true); } - public void applyDefinition(ItemDefinition definition, boolean force) throws SchemaException { + public void applyDefinition(D definition, boolean force) throws SchemaException { if (definition != null) { checkDefinition(definition); } @@ -584,6 +584,10 @@ protected void copyValues(Item clone) { clone.userData = MiscUtil.cloneMap(this.userData); } + protected void propagateDeepCloneDefinition(boolean ultraDeep, D clonedDefinition) { + // nothing to do by default + } + public static Collection cloneCollection(Collection items) { Collection clones = new ArrayList(items.size()); for (T item: items) { @@ -669,7 +673,7 @@ public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitio } } - protected abstract void checkDefinition(ItemDefinition def); + protected abstract void checkDefinition(D def); public void assertDefinitions() throws SchemaException { assertDefinitions(""); @@ -732,7 +736,7 @@ public boolean equalsRealValue(Object obj) { return false; if (getClass() != obj.getClass()) return false; - Item other = (Item) obj; + Item other = (Item) obj; if (elementName == null) { if (other.elementName != null) return false; @@ -787,7 +791,7 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - Item other = (Item) obj; + Item other = (Item) obj; if (definition == null) { if (other.definition != null) return false; @@ -814,7 +818,7 @@ public boolean match(Object obj) { return false; if (getClass() != obj.getClass()) return false; - Item other = (Item) obj; + Item other = (Item) obj; if (definition == null) { if (other.definition != null) return false; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/ItemDefinition.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/ItemDefinition.java index 9554a1b4c89..ff763072020 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/ItemDefinition.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/ItemDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ * @author Radovan Semancik * */ -public abstract class ItemDefinition extends Definition implements Serializable { +public abstract class ItemDefinition extends Definition implements Serializable { private static final long serialVersionUID = -2643332934312107274L; protected QName name; @@ -287,14 +287,14 @@ public void adoptElementDefinitionFrom(ItemDefinition otherDef) { * used as an element name for the instance. The instance will otherwise be empty. * @return created item instance */ - abstract public Item instantiate(); + abstract public I instantiate(); /** * Create an item instance. Definition name will use provided name. * for the instance. The instance will otherwise be empty. * @return created item instance */ - abstract public Item instantiate(QName name); + abstract public I instantiate(QName name); // add namespace from the definition if it's safe to do so protected QName addNamespaceIfApplicable(QName name) { @@ -320,9 +320,9 @@ T findItemDefinition(ItemPath path, Class clazz) { abstract public ItemDelta createEmptyDelta(ItemPath path); - abstract public ItemDefinition clone(); + abstract public ItemDefinition clone(); - protected void copyDefinitionData(ItemDefinition clone) { + protected void copyDefinitionData(ItemDefinition clone) { super.copyDefinitionData(clone); clone.name = this.name; clone.minOccurs = this.minOccurs; @@ -341,7 +341,7 @@ protected void copyDefinitionData(ItemDefinition clone) { * cloned as separate instances in the clone. * */ - public ItemDefinition deepClone(boolean ultraDeep) { + public ItemDefinition deepClone(boolean ultraDeep) { if (ultraDeep) { return deepClone(null); } else { @@ -349,7 +349,7 @@ public ItemDefinition deepClone(boolean ultraDeep) { } } - ItemDefinition deepClone(Map ctdMap) { + ItemDefinition deepClone(Map ctdMap) { return clone(); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedItem.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedItem.java index c8d426fbaf3..ad1388658c8 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedItem.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedItem.java @@ -21,22 +21,22 @@ * @author semancik * */ -public class PartiallyResolvedItem { +public class PartiallyResolvedItem { - private Item item; + private Item item; private ItemPath residualPath; - public PartiallyResolvedItem(Item item, ItemPath residualPath) { + public PartiallyResolvedItem(Item item, ItemPath residualPath) { super(); this.item = item; this.residualPath = residualPath; } - public Item getItem() { + public Item getItem() { return item; } - public void setItem(Item item) { + public void setItem(Item item) { this.item = item; } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainer.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainer.java index 68b167597f2..96b12b1cade 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainer.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainer.java @@ -54,12 +54,12 @@ * * @author Radovan Semancik */ -public class PrismContainer extends Item> implements PrismContainerable { +public class PrismContainer extends Item,PrismContainerDefinition> implements PrismContainerable { private static final long serialVersionUID = 5206821250098051028L; private static final Trace LOGGER = TraceManager.getTrace(PrismContainer.class); - protected Class compileTimeClass; + protected Class compileTimeClass; public PrismContainer(QName name) { super(name); @@ -69,7 +69,7 @@ public PrismContainer(QName name, PrismContext prismContext) { super(name, prismContext); } - public PrismContainer(QName name, Class compileTimeClass) { + public PrismContainer(QName name, Class compileTimeClass) { super(name); if (Modifier.isAbstract(compileTimeClass.getModifiers())) { throw new IllegalArgumentException("Can't use class '" + compileTimeClass.getSimpleName() + "' as compile-time class for "+name+"; the class is abstract."); @@ -77,17 +77,17 @@ public PrismContainer(QName name, Class compileTimeClass) { this.compileTimeClass = compileTimeClass; } - public PrismContainer(QName name, Class compileTimeClass, PrismContext prismContext) { + public PrismContainer(QName name, Class compileTimeClass, PrismContext prismContext) { this(name, compileTimeClass); this.prismContext = prismContext; } - protected PrismContainer(QName name, PrismContainerDefinition definition, PrismContext prismContext) { + protected PrismContainer(QName name, PrismContainerDefinition definition, PrismContext prismContext) { super(name, definition, prismContext); } - public Class getCompileTimeClass() { + public Class getCompileTimeClass() { if (this.compileTimeClass != null) { return compileTimeClass; } @@ -107,11 +107,11 @@ public boolean canRepresent(Class compileTimeClass) { } @Override - public List> getValues() { - return (List>) super.getValues(); + public List> getValues() { + return (List>) super.getValues(); } - public PrismContainerValue getValue() { + public PrismContainerValue getValue() { if (getValues().size() == 1) { return getValues().get(0); } @@ -123,7 +123,7 @@ public PrismContainerValue getValue() { if (getDefinition().isSingleValue()) { // Insert first empty value. This simulates empty single-valued container. It the container exists // it is clear that it has at least one value (and that value is empty). - PrismContainerValue pValue = new PrismContainerValue(null, null, this, null, null, prismContext); + PrismContainerValue pValue = new PrismContainerValue(null, null, this, null, null, prismContext); try { add(pValue); } catch (SchemaException e) { @@ -137,7 +137,7 @@ public PrismContainerValue getValue() { } else { // Insert first empty value. This simulates empty single-valued container. It the container exists // it is clear that it has at least one value (and that value is empty). - PrismContainerValue pValue = new PrismContainerValue(null, null, this, null, null, prismContext); + PrismContainerValue pValue = new PrismContainerValue(null, null, this, null, null, prismContext); try { add(pValue); } catch (SchemaException e) { @@ -148,7 +148,7 @@ public PrismContainerValue getValue() { } } - public void setValue(PrismContainerValue value) throws SchemaException { + public void setValue(PrismContainerValue value) throws SchemaException { if (getDefinition() != null) { if (getDefinition().isSingleValue()) { clear(); @@ -179,13 +179,13 @@ public boolean add(PrismContainerValue newValue) throws SchemaException { } @Override - public PrismContainerValue getPreviousValue(PrismValue value) { - return (PrismContainerValue) super.getPreviousValue(value); + public PrismContainerValue getPreviousValue(PrismValue value) { + return (PrismContainerValue) super.getPreviousValue(value); } @Override - public PrismContainerValue getNextValue(PrismValue value) { - return (PrismContainerValue) super.getNextValue(value); + public PrismContainerValue getNextValue(PrismValue value) { + return (PrismContainerValue) super.getNextValue(value); } private boolean canAssumeSingleValue() { @@ -200,8 +200,8 @@ private boolean canAssumeSingleValue() { } } - public PrismContainerValue getValue(Long id) { - for (PrismContainerValue pval: getValues()) { + public PrismContainerValue getValue(Long id) { + for (PrismContainerValue pval: getValues()) { if ((id == null && pval.getId() == null) || id.equals(pval.getId())) { return pval; @@ -226,12 +226,12 @@ public T getPropertyRealValue(QName propertyName, Class type) { /** * Convenience method. Works only on single-valued containers. */ - public void add(Item item) throws SchemaException { + public void add(Item item) throws SchemaException { getValue().add(item); } - public PrismContainerValue createNewValue() { - PrismContainerValue pValue = new PrismContainerValue(prismContext); + public PrismContainerValue createNewValue() { + PrismContainerValue pValue = new PrismContainerValue(prismContext); try { add(pValue); } catch (SchemaException e) { @@ -241,20 +241,20 @@ public PrismContainerValue createNewValue() { return pValue; } - public void mergeValues(PrismContainer other) throws SchemaException { + public void mergeValues(PrismContainer other) throws SchemaException { mergeValues(other.getValues()); } - public void mergeValues(Collection> otherValues) throws SchemaException { - for (PrismContainerValue otherValue : otherValues) { + public void mergeValues(Collection> otherValues) throws SchemaException { + for (PrismContainerValue otherValue : otherValues) { mergeValue(otherValue); } } - public void mergeValue(PrismContainerValue otherValue) throws SchemaException { - Iterator> iterator = getValues().iterator(); + public void mergeValue(PrismContainerValue otherValue) throws SchemaException { + Iterator> iterator = getValues().iterator(); while (iterator.hasNext()) { - PrismContainerValue thisValue = iterator.next(); + PrismContainerValue thisValue = iterator.next(); if (thisValue.equals(otherValue)) { // Same values, nothing to merge return; @@ -264,7 +264,7 @@ public void mergeValue(PrismContainerValue otherValue) throws SchemaException iterator.remove(); } } - PrismContainerValue clonedOtherValue = otherValue.clone(); + PrismContainerValue clonedOtherValue = otherValue.clone(); if (getDefinition() != null) { clonedOtherValue.applyDefinition(getDefinition()); } @@ -275,9 +275,9 @@ public void mergeValue(PrismContainerValue otherValue) throws SchemaException * Remove all empty values */ public void trim() { - Iterator> iterator = getValues().iterator(); + Iterator> iterator = getValues().iterator(); while (iterator.hasNext()) { - PrismContainerValue pval = iterator.next(); + PrismContainerValue pval = iterator.next(); if (pval.isEmpty()) { iterator.remove(); } @@ -292,8 +292,8 @@ public void trim() { * * @return applicable property container definition */ - public PrismContainerDefinition getDefinition() { - return (PrismContainerDefinition) definition; + public PrismContainerDefinition getDefinition() { + return (PrismContainerDefinition) definition; } /** @@ -301,23 +301,23 @@ public PrismContainerDefinition getDefinition() { * * @param definition the definition to set */ - public void setDefinition(PrismContainerDefinition definition) { + public void setDefinition(PrismContainerDefinition definition) { this.definition = definition; } @Override - public void applyDefinition(ItemDefinition definition) throws SchemaException { + public void applyDefinition(PrismContainerDefinition definition) throws SchemaException { if (definition == null) { return; } if (!(definition instanceof PrismContainerDefinition)) { throw new IllegalArgumentException("Cannot apply "+definition+" to container " + this); } - this.compileTimeClass = ((PrismContainerDefinition)definition).getCompileTimeClass(); + this.compileTimeClass = ((PrismContainerDefinition)definition).getCompileTimeClass(); super.applyDefinition(definition); } - public > I findItem(QName itemQName, Class type) { + public > I findItem(QName itemQName, Class type) { try { return findCreateItem(itemQName, type, false); } catch (SchemaException e) { @@ -334,7 +334,7 @@ public boolean hasCompleteDefinition() { if (getDefinition() == null) { return false; } - for (PrismContainerValue cval: getValues()) { + for (PrismContainerValue cval: getValues()) { if (!cval.hasCompleteDefinition()) { return false; } @@ -349,7 +349,7 @@ public Object find(ItemPath path) { } IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(path); - PrismContainerValue cval = findValue(idSegment); + PrismContainerValue cval = findValue(idSegment); if (cval == null) { return null; } @@ -359,13 +359,13 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedItem findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { - return new PartiallyResolvedItem((Item)this, null); + return new PartiallyResolvedItem((Item) this, null); } IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(path); - PrismContainerValue cval = findValue(idSegment); + PrismContainerValue cval = findValue(idSegment); if (cval == null) { return null; } @@ -374,7 +374,7 @@ public PartiallyResolvedItem findPartial(ItemPath path return cval.findPartial(rest); } - public Item findItem(QName itemQName) { + public Item findItem(QName itemQName) { try { return findCreateItem(itemQName, Item.class, false); } catch (SchemaException e) { @@ -383,11 +383,11 @@ public Item findItem(QName itemQName) { } } - > I findCreateItem(QName itemQName, Class type, boolean create) throws SchemaException { + > I findCreateItem(QName itemQName, Class type, boolean create) throws SchemaException { return getValue().findCreateItem(itemQName, type, null, create); } - public > I findItem(ItemPath propPath, Class type) { + public > I findItem(ItemPath propPath, Class type) { try { return findCreateItem(propPath, type, null, false); } catch (SchemaException e) { @@ -396,7 +396,7 @@ public > I findItem(ItemPath propPath, Class type) { } } - public Item findItem(ItemPath propPath) { + public Item findItem(ItemPath propPath) { try { return findCreateItem(propPath, Item.class, null, false); } catch (SchemaException e) { @@ -405,7 +405,7 @@ public Item findItem(ItemPath propPath) { } } - > I findCreateItem(ItemPath itemPath, Class type, ItemDefinition itemDefinition, boolean create) throws SchemaException { + > I findCreateItem(ItemPath itemPath, Class type, ID itemDefinition, boolean create) throws SchemaException { if (itemPath == null || itemPath.isEmpty()) { throw new IllegalArgumentException("Empty path specified"); } @@ -425,7 +425,7 @@ > I findCreateItem(ItemPath itemPath, Class type, ItemDefin } IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(itemPath); - PrismContainerValue cval = findValue(idSegment); + PrismContainerValue cval = findValue(idSegment); if (cval == null) { return null; } @@ -434,8 +434,8 @@ > I findCreateItem(ItemPath itemPath, Class type, ItemDefin return cval.findCreateItem(rest, type, itemDefinition, create); } - public PrismContainerValue findValue(long id) { - for (PrismContainerValue pval : getValues()) { + public PrismContainerValue findValue(long id) { + for (PrismContainerValue pval : getValues()) { if (id == pval.getId()) { return pval; } @@ -443,7 +443,7 @@ public PrismContainerValue findValue(long id) { return null; } - private PrismContainerValue findValue(IdItemPathSegment idSegment) { + private PrismContainerValue findValue(IdItemPathSegment idSegment) { Long id = null; if (idSegment != null) { id = idSegment.getId(); @@ -456,7 +456,7 @@ private PrismContainerValue findValue(IdItemPathSegment idSegment) { throw new IllegalArgumentException("Attempt to get segment without an ID from a multi-valued container "+ getElementName()); } } else { - for (PrismContainerValue pval : getValues()) { + for (PrismContainerValue pval : getValues()) { if (id.equals(pval.getId())) { return pval; } @@ -493,13 +493,13 @@ public PrismReference findReferenceByCompositeObjectElementName(QName elementNam return getValue().findReferenceByCompositeObjectElementName(elementName); } - public > T findOrCreateItem(ItemPath containerPath, Class type) throws SchemaException { + public > I findOrCreateItem(ItemPath containerPath, Class type) throws SchemaException { return findCreateItem(containerPath, type, null, true); } // The "definition" parameter provides definition of item to create, in case that the container does not have // the definition (e.g. in case of "extension" containers) - public > T findOrCreateItem(ItemPath containerPath, Class type, ItemDefinition definition) throws SchemaException { + public > I findOrCreateItem(ItemPath containerPath, Class type, ID definition) throws SchemaException { if (PrismObject.class.isAssignableFrom(type)) { throw new IllegalArgumentException("It makes no sense to find object in a container (class)"); } @@ -536,7 +536,7 @@ public PrismReference findOrCreateReference(QName propertyName) throws SchemaExc /** * Convenience method. Works only on single-valued containers. */ - public void remove(Item item) { + public void remove(Item item) { getValue().remove(item); } @@ -564,9 +564,9 @@ public void removeReference(ItemPath path) { removeItem(path, PrismReference.class); } - public > void removeItem(ItemPath path, Class itemType) { + public > void removeItem(ItemPath path, Class itemType) { IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(path); - PrismContainerValue cval = findValue(idSegment); + PrismContainerValue cval = findValue(idSegment); if (cval == null) { return; } @@ -595,17 +595,17 @@ public > void removeItem(ItemPath path, Class itemType) { // } @Override - public ContainerDelta createDelta() { - return new ContainerDelta(getPath(), getDefinition(), getPrismContext()); + public ContainerDelta createDelta() { + return new ContainerDelta(getPath(), getDefinition(), getPrismContext()); } @Override - public ContainerDelta createDelta(ItemPath path) { - return new ContainerDelta(path, getDefinition(), getPrismContext()); + public ContainerDelta createDelta(ItemPath path) { + return new ContainerDelta(path, getDefinition(), getPrismContext()); } public boolean isEmpty() { - for(PrismContainerValue pval : getValues()) { + for(PrismContainerValue pval : getValues()) { if (!pval.isEmpty()) { return false; } @@ -614,7 +614,7 @@ public boolean isEmpty() { } @Override - protected void checkDefinition(ItemDefinition def) { + protected void checkDefinition(PrismContainerDefinition def) { if (!(def instanceof PrismContainerDefinition)) { throw new IllegalArgumentException("Definition "+def+" cannot be applied to container "+this); } @@ -652,22 +652,22 @@ private void checkIds() { @Override public void assertDefinitions(boolean tolarateRaw, String sourceDescription) throws SchemaException { super.assertDefinitions(tolarateRaw, sourceDescription); - for (PrismContainerValue val: getValues()) { + for (PrismContainerValue val: getValues()) { val.assertDefinitions(tolarateRaw, this.toString()+" in "+sourceDescription); } } @Override - public PrismContainer clone() { - PrismContainer clone = new PrismContainer(getElementName(), getDefinition(), prismContext); + public PrismContainer clone() { + PrismContainer clone = new PrismContainer(getElementName(), getDefinition(), prismContext); copyValues(clone); return clone; } - protected void copyValues(PrismContainer clone) { + protected void copyValues(PrismContainer clone) { super.copyValues(clone); clone.compileTimeClass = this.compileTimeClass; - for (PrismContainerValue pval : getValues()) { + for (PrismContainerValue pval : getValues()) { try { clone.add(pval.clone()); } catch (SchemaException e) { @@ -676,9 +676,23 @@ protected void copyValues(PrismContainer clone) { } } } + + public PrismContainerDefinition deepCloneDefinition(boolean ultraDeep) { + PrismContainerDefinition clonedDef = (PrismContainerDefinition) getDefinition().deepClone(ultraDeep); + propagateDeepCloneDefinition(ultraDeep, clonedDef); + setDefinition(clonedDef); + return clonedDef; + } + + @Override + protected void propagateDeepCloneDefinition(boolean ultraDeep, PrismContainerDefinition clonedDef) { + for(PrismContainerValue cval: getValues()) { + cval.deepCloneDefinition(ultraDeep, clonedDef); + } + } @Override - public boolean containsEquivalentValue(PrismContainerValue value) { + public boolean containsEquivalentValue(PrismContainerValue value) { if (value.getId() == null) { return super.contains(value, true); } else { @@ -700,11 +714,11 @@ public void accept(Visitor visitor, ItemPath path, boolean recursive) { ItemPath rest = ItemPath.pathRestStartingWithName(path); if (idSegment == null || idSegment.isWildcard()) { // visit all values - for (PrismContainerValue cval: getValues()) { + for (PrismContainerValue cval: getValues()) { cval.accept(visitor, rest, recursive); } } else { - PrismContainerValue cval = findValue(idSegment); + PrismContainerValue cval = findValue(idSegment); if (cval != null) { cval.accept(visitor, rest, recursive); } @@ -765,7 +779,7 @@ public String debugDump(int indent) { sb.append(DebugUtil.formatElementName(getElementName())); sb.append(": "); sb.append(additionalDumpDescription()); - PrismContainerDefinition def = getDefinition(); + PrismContainerDefinition def = getDefinition(); if (DebugUtil.isDetailedDebugDump()) { if (def != null) { sb.append(" def("); @@ -779,12 +793,12 @@ public String debugDump(int indent) { sb.append(")"); } } - Iterator> i = getValues().iterator(); + Iterator> i = getValues().iterator(); if (i.hasNext()) { sb.append("\n"); } while (i.hasNext()) { - PrismContainerValue pval = i.next(); + PrismContainerValue pval = i.next(); sb.append(pval.debugDump(indent + 1)); if (i.hasNext()) { sb.append("\n"); diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java index fb034feadd9..ddf323e91d5 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,12 +54,12 @@ * * @author Radovan Semancik */ -public class PrismContainerDefinition extends ItemDefinition { +public class PrismContainerDefinition extends ItemDefinition> { private static final long serialVersionUID = -5068923696147960699L; protected ComplexTypeDefinition complexTypeDefinition; - protected Class compileTimeClass; + protected Class compileTimeClass; /** * The constructors should be used only occasionally (if used at all). @@ -70,7 +70,7 @@ public PrismContainerDefinition(QName name, ComplexTypeDefinition complexTypeDef } public PrismContainerDefinition(QName name, ComplexTypeDefinition complexTypeDefinition, PrismContext prismContext, - Class compileTimeClass) { + Class compileTimeClass) { super(name, determineTypeName(complexTypeDefinition), prismContext); this.complexTypeDefinition = complexTypeDefinition; if (complexTypeDefinition == null) { @@ -92,17 +92,17 @@ private static QName determineTypeName(ComplexTypeDefinition complexTypeDefiniti return complexTypeDefinition.getTypeName(); } - public Class getCompileTimeClass() { + public Class getCompileTimeClass() { if (compileTimeClass != null) { return compileTimeClass; } if (complexTypeDefinition == null) { return null; } - return (Class) complexTypeDefinition.getCompileTimeClass(); + return (Class) complexTypeDefinition.getCompileTimeClass(); } - public void setCompileTimeClass(Class compileTimeClass) { + public void setCompileTimeClass(Class compileTimeClass) { this.compileTimeClass = compileTimeClass; } @@ -174,12 +174,12 @@ public D findItemDefinition(QName name, Class claz return complexTypeDefinition.findItemDefinition(name, clazz, caseInsensitive); } - public T findItemDefinition(ItemPath path, Class clazz) { + public ID findItemDefinition(ItemPath path, Class clazz) { while (!path.isEmpty() && !(path.first() instanceof NameItemPathSegment)) { path = path.rest(); } if (path.isEmpty()) { - return (T) this; + return (ID) this; } QName firstName = ((NameItemPathSegment)path.first()).getName(); @@ -190,25 +190,25 @@ public T findItemDefinition(ItemPath path, Class c if (StringUtils.isEmpty(firstName.getNamespaceURI())) { for (ItemDefinition def : getDefinitions()){ if (QNameUtil.match(firstName, def.getName())){ - return def.findItemDefinition(path.rest(), clazz); + return (ID) def.findItemDefinition(path.rest(), clazz); } } } for (ItemDefinition def : getDefinitions()) { if (firstName.equals(def.getName())) { - return def.findItemDefinition(path.rest(), clazz); + return (ID) def.findItemDefinition(path.rest(), clazz); } } return null; } - public ItemDefinition findItemDefinition(QName name) { - return findItemDefinition(name, ItemDefinition.class); + public ID findItemDefinition(QName name) { + return (ID)findItemDefinition(name, ItemDefinition.class); } - public ItemDefinition findItemDefinition(ItemPath path) { - return findItemDefinition(path, ItemDefinition.class); + public ID findItemDefinition(ItemPath path) { + return (ID)findItemDefinition(path, ItemDefinition.class); } /** @@ -219,11 +219,11 @@ public ItemDefinition findItemDefinition(ItemPath path) { * @param name property definition name * @return found property definition or null */ - public PrismPropertyDefinition findPropertyDefinition(QName name) { + public PrismPropertyDefinition findPropertyDefinition(QName name) { return findItemDefinition(name, PrismPropertyDefinition.class); } - public PrismPropertyDefinition findPropertyDefinition(ItemPath path) { + public PrismPropertyDefinition findPropertyDefinition(ItemPath path) { while (!path.isEmpty() && !(path.first() instanceof NameItemPathSegment)) { path = path.rest(); } @@ -319,7 +319,7 @@ public List getPropertyDefinitions() { * This is a preferred way how to create property container. */ @Override - public PrismContainer instantiate() { + public PrismContainer instantiate() { return instantiate(getName()); } @@ -329,13 +329,13 @@ public PrismContainer instantiate() { * This is a preferred way how to create property container. */ @Override - public PrismContainer instantiate(QName elementName) { + public PrismContainer instantiate(QName elementName) { elementName = addNamespaceIfApplicable(elementName); - return new PrismContainer(elementName, this, prismContext); + return new PrismContainer(elementName, this, prismContext); } @Override - public ContainerDelta createEmptyDelta(ItemPath path) { + public ContainerDelta createEmptyDelta(ItemPath path) { return new ContainerDelta(path, this, prismContext); } @@ -343,13 +343,13 @@ public ContainerDelta createEmptyDelta(ItemPath path) { * Shallow clone */ @Override - public PrismContainerDefinition clone() { - PrismContainerDefinition clone = new PrismContainerDefinition(name, complexTypeDefinition, prismContext, compileTimeClass); + public PrismContainerDefinition clone() { + PrismContainerDefinition clone = new PrismContainerDefinition(name, complexTypeDefinition, prismContext, compileTimeClass); copyDefinitionData(clone); return clone; } - protected void copyDefinitionData(PrismContainerDefinition clone) { + protected void copyDefinitionData(PrismContainerDefinition clone) { super.copyDefinitionData(clone); clone.complexTypeDefinition = this.complexTypeDefinition; clone.isRuntimeSchema = this.isRuntimeSchema; @@ -358,7 +358,7 @@ protected void copyDefinitionData(PrismContainerDefinition clone) { @Override ItemDefinition deepClone(Map ctdMap) { - PrismContainerDefinition clone = clone(); + PrismContainerDefinition clone = clone(); ComplexTypeDefinition ctd = getComplexTypeDefinition(); if (ctd != null) { ctd = ctd.deepClone(ctdMap); @@ -367,8 +367,8 @@ ItemDefinition deepClone(Map ctdMap) { return clone; } - public PrismContainerDefinition cloneWithReplacedDefinition(QName itemName, ItemDefinition newDefinition) { - PrismContainerDefinition clone = clone(); + public PrismContainerDefinition cloneWithReplacedDefinition(QName itemName, ItemDefinition newDefinition) { + PrismContainerDefinition clone = clone(); ComplexTypeDefinition originalComplexTypeDefinition = getComplexTypeDefinition(); ComplexTypeDefinition cloneComplexTypeDefinition = originalComplexTypeDefinition.clone(); clone.setComplexTypeDefinition(cloneComplexTypeDefinition); @@ -491,17 +491,17 @@ public PrismContainerDefinition createContainerDefinition(QName name, QName type return createContainerDefinition(name, typeDefinition, minOccurs, maxOccurs); } - public PrismContainerDefinition createContainerDefinition(QName name, ComplexTypeDefinition complexTypeDefinition, + public PrismContainerDefinition createContainerDefinition(QName name, ComplexTypeDefinition complexTypeDefinition, int minOccurs, int maxOccurs) { - PrismContainerDefinition def = new PrismContainerDefinition(name, complexTypeDefinition, prismContext); + PrismContainerDefinition def = new PrismContainerDefinition(name, complexTypeDefinition, prismContext); def.setMinOccurs(minOccurs); def.setMaxOccurs(maxOccurs); addDefinition(def); return def; } - public PrismContainerValue createValue() { - return new PrismContainerValue(prismContext); + public PrismContainerValue createValue() { + return new PrismContainerValue(prismContext); } @Override diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java index 3fde43b5bdf..cc35f184be4 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,13 +51,13 @@ * @author semancik * */ -public class PrismContainerValue extends PrismValue implements DebugDumpable { +public class PrismContainerValue extends PrismValue implements DebugDumpable { private static final Trace LOGGER = TraceManager.getTrace(PrismContainerValue.class); // This is list. We need to maintain the order internally to provide consistent // output in DOM and other ordering-sensitive representations - private List> items = null; + private List> items = null; private Long id; // XNode map of all sub-elements in this container value. @@ -68,7 +68,7 @@ public class PrismContainerValue extends PrismValue imp // So we store the raw elements here and process them later (e.g. during applyDefinition). private List rawElements = null; - private T containerable = null; + private C containerable = null; /** * Concrete type of the containerable value. It is the declared container type or any of its subtypes. @@ -106,12 +106,12 @@ private void setPrismContext(PrismContext prismContext) { this.prismContext = prismContext; } - private PrismContainerValue(T containerable) { + private PrismContainerValue(C containerable) { super(); this.containerable = containerable; } - public PrismContainerValue(T containerable, PrismContext prismContext) { + public PrismContainerValue(C containerable, PrismContext prismContext) { this(containerable); this.prismContext = prismContext; } @@ -149,17 +149,17 @@ public PrismContext getPrismContext() { * @return set of items that the property container contains. */ - public List> getItems() { + public List> getItems() { return items; } - public Item getNextItem(Item referenceItem) { + public Item getNextItem(Item referenceItem) { if (items == null){ return null; } - Iterator> iterator = items.iterator(); + Iterator> iterator = items.iterator(); while (iterator.hasNext()) { - Item item = iterator.next(); + Item item = iterator.next(); if (item == referenceItem) { if (iterator.hasNext()) { return iterator.next(); @@ -171,14 +171,14 @@ public Item getNextItem(Item referenceItem) { throw new IllegalArgumentException("Item "+referenceItem+" is not part of "+this); } - public Item getPreviousItem(Item referenceItem) { + public Item getPreviousItem(Item referenceItem) { if (items == null){ return null; } - Item lastItem = null; - Iterator> iterator = items.iterator(); + Item lastItem = null; + Iterator> iterator = items.iterator(); while (iterator.hasNext()) { - Item item = iterator.next(); + Item item = iterator.next(); if (item == referenceItem) { return lastItem; } @@ -201,7 +201,7 @@ public Item getPreviousItem(Item referenceItem) { public Set> getProperties() { Set> properties = new HashSet>(); if (items != null) { - for (Item item : getItems()) { + for (Item item : getItems()) { if (item instanceof PrismProperty) { properties.add((PrismProperty) item); } @@ -219,7 +219,7 @@ public void setId(Long id) { } @SuppressWarnings("unchecked") - public PrismContainerable getParent() { + public PrismContainerable getParent() { Itemable parent = super.getParent(); if (parent == null) { return null; @@ -228,7 +228,7 @@ public PrismContainerable getParent() { throw new IllegalStateException("Expected that parent of "+PrismContainerValue.class.getName()+" will be "+ PrismContainerable.class.getName()+", but it is "+parent.getClass().getName()); } - return (PrismContainerable)parent; + return (PrismContainerable)parent; } void setParent(PrismContainerable container) { @@ -236,7 +236,7 @@ void setParent(PrismContainerable container) { } @SuppressWarnings("unchecked") - public PrismContainer getContainer() { + public PrismContainer getContainer() { Itemable parent = super.getParent(); if (parent == null) { return null; @@ -245,10 +245,10 @@ public PrismContainer getContainer() { throw new IllegalStateException("Expected that parent of "+PrismContainerValue.class.getName()+" will be "+ PrismContainer.class.getName()+", but it is "+parent.getClass().getName()); } - return (PrismContainer)super.getParent(); + return (PrismContainer)super.getParent(); } - void setParent(PrismContainer container) { + void setParent(PrismContainer container) { super.setParent(container); } @@ -266,7 +266,7 @@ public ItemPath getPath() { } // For compatibility with other PrismValue types - public T getValue() { + public C getValue() { return asContainerable(); } @@ -274,13 +274,13 @@ private List createElement() { return new ArrayList(); } - public T asContainerable() { + public C asContainerable() { PrismContainerable parent = getParent(); if (parent == null) { throw new IllegalStateException("Cannot represent container value without a parent as containerable; value: "+this); } - Class clazz = null; + Class clazz = null; if (concreteType != null) { clazz = resolveConcreteClass(parent); } @@ -296,8 +296,8 @@ public T asContainerable() { return asContainerableInternal(clazz); } - private Class resolveConcreteClass(PrismContainerable parent) { - Class clazz; + private Class resolveConcreteClass(PrismContainerable parent) { + Class clazz; PrismContainerDefinition containerDefinition = parent.getPrismContext().getSchemaRegistry().findContainerDefinitionByType(concreteType); if (containerDefinition == null) { throw new IllegalStateException("A definition for an explicit type " + concreteType + " of a container " + parent.getElementName() + " value couldn't be found"); @@ -309,8 +309,8 @@ private Class resolveConcreteClass(PrismContainerable parent) { return clazz; } - public T asContainerable(Class defaultClazz) { - Class clazz = defaultClazz; + public C asContainerable(Class defaultClazz) { + Class clazz = defaultClazz; if (concreteType != null) { PrismContainerable parent = getParent(); if (parent != null) { @@ -322,7 +322,7 @@ public T asContainerable(Class defaultClazz) { return asContainerableInternal(clazz); } - private T asContainerableInternal(Class clazz) { + private C asContainerableInternal(Class clazz) { if (containerable != null) { return containerable ; } @@ -352,7 +352,7 @@ public Collection getPropertyNames() { * @throws SchemaException * @throws IllegalArgumentException an attempt to add value that already exists */ - public boolean add(Item item) throws SchemaException { + public boolean add(Item item) throws SchemaException { if (item.getElementName() == null) { throw new IllegalArgumentException("Cannot add item without a name to value of container "+getParent()); } @@ -365,10 +365,10 @@ public boolean add(Item item) throws SchemaException { item.setPrismContext(prismContext); } if (getActualDefinition() != null && item.getDefinition() == null) { - item.applyDefinition(determineItemDefinition(item.getElementName(), getActualDefinition()), false); + item.applyDefinition((ID)determineItemDefinition(item.getElementName(), getActualDefinition()), false); } if (items == null) { - items = new ArrayList>(); + items = new ArrayList>(); } return items.add(item); } @@ -377,14 +377,14 @@ public boolean add(Item item) throws SchemaException { * Merges the provided item into this item. The values are joined together. * Returns true if new item or value was added. */ - public boolean merge(Item item) throws SchemaException { - Item exisingItem = findItem(item.getElementName(), Item.class); + public boolean merge(Item item) throws SchemaException { + Item exisingItem = findItem(item.getElementName(), Item.class); if (exisingItem == null) { return add(item); } else { boolean changed = false; - for (V newVal: item.getValues()) { - if (exisingItem.add((V) newVal.clone())) { + for (IV newVal: item.getValues()) { + if (exisingItem.add((IV) newVal.clone())) { changed = true; } } @@ -397,13 +397,13 @@ public boolean merge(Item item) throws SchemaException * from this item. * Returns true if this item was changed. */ - public boolean substract(Item item) throws SchemaException { - Item exisingItem = findItem(item.getElementName(), Item.class); + public boolean substract(Item item) throws SchemaException { + Item exisingItem = findItem(item.getElementName(), Item.class); if (exisingItem == null) { return false; } else { boolean changed = false; - for (V newVal: item.getValues()) { + for (IV newVal: item.getValues()) { if (exisingItem.remove(newVal)) { changed = true; } @@ -417,11 +417,11 @@ public boolean substract(Item item) throws SchemaExcep * * @param item item to add. */ - public void addReplaceExisting(Item item) throws SchemaException { + public void addReplaceExisting(Item item) throws SchemaException { if (item == null){ return; } - Item existingItem = findItem(item.getElementName(), Item.class); + Item existingItem = findItem(item.getElementName(), Item.class); if (existingItem != null && items != null) { items.remove(existingItem); existingItem.setParent(null); @@ -429,10 +429,10 @@ public void addReplaceExisting(Item item) throws SchemaException { add(item); } - public void remove(Item item) { + public void remove(Item item) { Validate.notNull(item, "Item must not be null."); - Item existingItem = findItem(item.getElementName(), Item.class); + Item existingItem = findItem(item.getElementName(), Item.class); if (existingItem != null && items != null) { items.remove(existingItem); existingItem.setParent(null); @@ -443,9 +443,9 @@ public void removeAll() { if (items == null){ return; } - Iterator> iterator = items.iterator(); + Iterator> iterator = items.iterator(); while (iterator.hasNext()) { - Item item = iterator.next(); + Item item = iterator.next(); item.setParent(null); iterator.remove(); } @@ -457,8 +457,8 @@ public void removeAll() { * @param itemsToAdd items to add * @throws IllegalArgumentException an attempt to add value that already exists */ - public void addAll(Collection> itemsToAdd) throws SchemaException { - for (Item item : itemsToAdd) { + public void addAll(Collection> itemsToAdd) throws SchemaException { + for (Item item : itemsToAdd) { add(item); } } @@ -468,10 +468,10 @@ public void addAll(Collection> itemsToAdd) throws SchemaExcept * * @param itemsToAdd items to add */ - public void addAllReplaceExisting(Collection> itemsToAdd) throws SchemaException { + public void addAllReplaceExisting(Collection> itemsToAdd) throws SchemaException { // Check for conflicts, remove conflicting values - for (Item item : itemsToAdd) { - Item existingItem = findItem(item.getElementName(), Item.class); + for (Item item : itemsToAdd) { + Item existingItem = findItem(item.getElementName(), Item.class); if (existingItem != null && items != null) { items.remove(existingItem); } @@ -479,7 +479,7 @@ public void addAllReplaceExisting(Collection> itemsToAdd) thro addAll(itemsToAdd); } - public void replace(Item oldItem, Item newItem) throws SchemaException { + public void replace(Item oldItem, Item newItem) throws SchemaException { remove(oldItem); add(newItem); } @@ -523,7 +523,7 @@ public Object find(ItemPath path) { } QName subName = ((NameItemPathSegment)first).getName(); ItemPath rest = path.rest(); - Item subItem = findItem(subName); + Item subItem = findItem(subName); if (subItem == null) { return null; } @@ -531,7 +531,7 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedItem findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { // Incomplete path return null; @@ -542,7 +542,7 @@ public PartiallyResolvedItem findPartial(ItemPath path } QName subName = ((NameItemPathSegment)first).getName(); ItemPath rest = path.rest(); - Item subItem = findItem(subName); + Item subItem = findItem(subName); if (subItem == null) { return null; } @@ -555,7 +555,7 @@ public PrismProperty findProperty(QName propertyQName) { } public PrismProperty findProperty(ItemPath propertyPath) { - return (PrismProperty) findItem(propertyPath); + return (PrismProperty) findItem(propertyPath); } /** @@ -566,7 +566,7 @@ public PrismProperty findProperty(ItemPath propertyPath) { * @param propertyDefinition property definition to find. * @return found property or null */ - public PrismProperty findProperty(PrismPropertyDefinition propertyDefinition) { + public PrismProperty findProperty(PrismPropertyDefinition propertyDefinition) { if (propertyDefinition == null) { throw new IllegalArgumentException("No property definition"); } @@ -599,7 +599,7 @@ public PrismReference findReferenceByCompositeObjectElementName(QName elementNam return null; } - public > I findItem(QName itemName, Class type) { + public > I findItem(QName itemName, Class type) { try { return findCreateItem(itemName, type, null, false); } catch (SchemaException e) { @@ -608,7 +608,7 @@ public > I findItem(QName itemName, Class type) { } } - public Item findItem(QName itemName) { + public Item findItem(QName itemName) { try { return findCreateItem(itemName, Item.class, null, false); } catch (SchemaException e) { @@ -617,7 +617,7 @@ public Item findItem(QName itemName) { } } - public Item findItem(ItemPath itemPath) { + public Item findItem(ItemPath itemPath) { try { return findCreateItem(itemPath, Item.class, null, false); } catch (SchemaException e) { @@ -627,11 +627,11 @@ public Item findItem(ItemPath itemPath) { } @SuppressWarnings("unchecked") - > I findCreateItem(QName itemName, Class type, ItemDefinition itemDefinition, boolean create) throws SchemaException { - Item item = findItemByQName(itemName); + > I findCreateItem(QName itemName, Class type, ID itemDefinition, boolean create) throws SchemaException { + Item item = findItemByQName(itemName); if (item != null) { if (type.isAssignableFrom(item.getClass())) { - return (I)item; + return (I) item; } else { if (create) { throw new IllegalStateException("The " + type.getSimpleName() + " cannot be created because " @@ -648,7 +648,7 @@ > I findCreateItem(QName itemName, Class type, ItemDefiniti } } - public > I findItem(ItemDefinition itemDefinition, Class type) { + public > I findItem(ItemDefinition itemDefinition, Class type) { if (itemDefinition == null) { throw new IllegalArgumentException("No item definition"); } @@ -658,14 +658,14 @@ public > I findItem(ItemDefinition itemDefinition, Class ty // Expects that "self" path is NOT present in propPath @SuppressWarnings("unchecked") - > I findCreateItem(ItemPath propPath, Class type, ItemDefinition itemDefinition, boolean create) throws SchemaException { + > I findCreateItem(ItemPath propPath, Class type, ID itemDefinition, boolean create) throws SchemaException { ItemPathSegment first = propPath.first(); if (!(first instanceof NameItemPathSegment)) { throw new IllegalArgumentException("Attempt to lookup item using a non-name path "+propPath+" in "+this); } QName subName = ((NameItemPathSegment)first).getName(); ItemPath rest = propPath.rest(); - Item item = findItemByQName(subName); + I item = (I) findItemByQName(subName); if (item != null) { if (rest.isEmpty()) { if (type.isAssignableFrom(item.getClass())) { @@ -691,7 +691,7 @@ > I findCreateItem(ItemPath propPath, Class type, ItemDefin // FIXME: This is not the best solution but it is needed to be able to look inside properties // such as PolyString if (type.isAssignableFrom(item.getClass())) { - return (I)item; + return item; } else { return null; } @@ -713,28 +713,27 @@ > I findCreateItem(ItemPath propPath, Class type, ItemDefin } } - private Item findItemByQName(QName subName) throws SchemaException { + private Item findItemByQName(QName subName) throws SchemaException { if (items == null) { return null; } - Item matching = null; - for (Item item : items) { + Item matching = null; + for (Item item : items) { if (QNameUtil.match(subName, item.getElementName())) { if (matching != null) { String containerName = getParent() != null ? DebugUtil.formatElementName(getParent().getElementName()) : ""; throw new SchemaException("More than one items matching " + subName + " in container " + containerName); } else { - matching = item; + matching = (Item) item; } } } return matching; } - @SuppressWarnings("unchecked") - private > I createSubItem(QName name, Class type, ItemDefinition itemDefinition) throws SchemaException { + private > I createSubItem(QName name, Class type, ID itemDefinition) throws SchemaException { // the item with specified name does not exist, create it now - Item newItem = null; + I newItem = null; if (itemDefinition == null && getActualDefinition() != null) { itemDefinition = determineItemDefinition(name, getActualDefinition()); @@ -745,10 +744,10 @@ private > I createSubItem(QName name, Class type, ItemDefin if (itemDefinition != null) { if (StringUtils.isNotBlank(name.getNamespaceURI())){ - newItem = itemDefinition.instantiate(name); + newItem = (I) itemDefinition.instantiate(name); } else { QName computed = new QName(itemDefinition.getNamespace(), name.getLocalPart()); - newItem = itemDefinition.instantiate(computed); + newItem = (I) itemDefinition.instantiate(computed); } if (newItem instanceof PrismObject) { throw new IllegalStateException("PrismObject instantiated as a subItem in "+this+" from definition "+itemDefinition); @@ -762,7 +761,7 @@ private > I createSubItem(QName name, Class type, ItemDefin if (type.isAssignableFrom(newItem.getClass())) { add(newItem); - return (I)newItem; + return newItem; } else { throw new IllegalStateException("The " + type.getSimpleName() + " cannot be created because the item should be of type " + newItem.getClass().getSimpleName() + " ("+newItem.getElementName()+")"); @@ -777,15 +776,15 @@ public PrismReference findOrCreateReference(QName referenceName) throws SchemaEx return findCreateItem(referenceName, PrismReference.class, null, true); } - public Item findOrCreateItem(QName containerName) throws SchemaException { + public Item findOrCreateItem(QName containerName) throws SchemaException { return findCreateItem(containerName, Item.class, null, true); } - public X findOrCreateItem(QName containerName, Class type) throws SchemaException { + public > I findOrCreateItem(QName containerName, Class type) throws SchemaException { return findCreateItem(containerName, type, null, true); } - public X findOrCreateItem(ItemPath path, Class type, ItemDefinition definition) throws SchemaException { + public > I findOrCreateItem(ItemPath path, Class type, ID definition) throws SchemaException { return findCreateItem(path, type, definition, true); } @@ -875,7 +874,7 @@ public void removeContainer(ItemPath itemPath) { } // Expects that "self" path is NOT present in propPath - > void removeItem(ItemPath propPath, Class itemType) { + > void removeItem(ItemPath propPath, Class itemType) { if (items == null){ return; } @@ -885,9 +884,9 @@ > void removeItem(ItemPath propPath, Class itemType) { } QName subName = ((NameItemPathSegment)first).getName(); ItemPath rest = propPath.rest(); - Iterator> itemsIterator = items.iterator(); + Iterator> itemsIterator = items.iterator(); while(itemsIterator.hasNext()) { - Item item = itemsIterator.next(); + Item item = itemsIterator.next(); if (subName.equals(item.getElementName())) { if (!rest.isEmpty() && item instanceof PrismContainer) { ((PrismContainer)item).removeItem(propPath, itemType); @@ -929,7 +928,7 @@ public void recompute(PrismContext prismContext) { public void accept(Visitor visitor) { super.accept(visitor); if (items != null) { - for (Item item : getItems()) { + for (Item item : getItems()) { item.accept(visitor); } } @@ -952,7 +951,7 @@ public void accept(Visitor visitor, ItemPath path, boolean recursive) { QName subName = ((NameItemPathSegment)first).getName(); ItemPath rest = path.rest(); if (items != null) { - for (Item item : items) { // todo unqualified names! + for (Item item : items) { // todo unqualified names! if (first.isWildcard() || subName.equals(item.getElementName())) { item.accept(visitor, rest, recursive); } @@ -963,7 +962,7 @@ public void accept(Visitor visitor, ItemPath path, boolean recursive) { public boolean hasCompleteDefinition() { if (items != null) { - for (Item item : getItems()) { + for (Item item : getItems()) { if (!item.hasCompleteDefinition()) { return false; } @@ -975,13 +974,13 @@ public boolean hasCompleteDefinition() { @Override public boolean representsSameValue(PrismValue other) { if (other instanceof PrismContainerValue) { - return representsSameValue((PrismContainerValue)other); + return representsSameValue((PrismContainerValue)other); } else { return false; } } - public boolean representsSameValue(PrismContainerValue other) { + public boolean representsSameValue(PrismContainerValue other) { if (getParent() != null) { PrismContainerDefinition definition = getActualDefinition(); if (definition != null) { @@ -1017,9 +1016,9 @@ void diffMatchingRepresentation(PrismValue otherValue, } } - void diffRepresentation(PrismContainerValue otherValue, + void diffRepresentation(PrismContainerValue otherValue, Collection deltas, boolean ignoreMetadata, boolean isLiteral) { - PrismContainerValue thisValue = this; + PrismContainerValue thisValue = this; if (this.isRaw() || otherValue.isRaw()) { try { if (this.isRaw()) { @@ -1050,7 +1049,7 @@ public List getRawElements() { } public boolean addRawElement(Object element) throws SchemaException { - PrismContainerDefinition definition = getDefinition(); + PrismContainerDefinition definition = getDefinition(); if (definition == null) { // We cannot do much better. We do not even have prism context here. if (rawElements == null) { @@ -1062,13 +1061,13 @@ public boolean addRawElement(Object element) throws SchemaException { return rawElements.add(element); } else { // We have definition here, we can parse it right now - Item subitem = parseRawElement(element, definition); + Item subitem = parseRawElement(element, definition); return merge(subitem); } } public boolean deleteRawElement(Object element) throws SchemaException { - PrismContainerDefinition definition = getDefinition(); + PrismContainerDefinition definition = getDefinition(); if (definition == null) { // We cannot do much better. We do not even have prism context here. if (rawElements == null) { @@ -1077,7 +1076,7 @@ public boolean deleteRawElement(Object element) throws SchemaException { return rawElements.add(element); } else { // We have definition here, we can parse it right now - Item subitem = parseRawElement(element, definition); + Item subitem = parseRawElement(element, definition); return substract(subitem); } } @@ -1087,30 +1086,30 @@ public boolean removeRawElement(Object element) { return rawElements.remove(element); } - private Item parseRawElement(Object element, PrismContainerDefinition definition) throws SchemaException { + private Item parseRawElement(Object element, PrismContainerDefinition definition) throws SchemaException { JaxbDomHack jaxbDomHack = definition.getPrismContext().getJaxbDomHack(); return jaxbDomHack.parseRawElement(element, definition); } - private PrismContainerValue parseRawElementsToNewValue(PrismContainerValue origCVal, PrismContainerValue definitionSource) throws SchemaException { + private PrismContainerValue parseRawElementsToNewValue(PrismContainerValue origCVal, PrismContainerValue definitionSource) throws SchemaException { if (definitionSource.getParent() == null || definitionSource.getActualDefinition() == null) { throw new IllegalArgumentException("Attempt to use container " + origCVal.getParent() + " values in a raw parsing state (raw elements) with parsed value that has no definition"); } - PrismContainerDefinition definition = definitionSource.getActualDefinition(); + PrismContainerDefinition definition = definitionSource.getActualDefinition(); XNode origRawXnode = origCVal.rawXNode; if (origRawXnode != null) { XNodeProcessor xnodeProcessor = definition.getPrismContext().getXnodeProcessor(); - PrismContainerValue newCVal = xnodeProcessor.parsePrismContainerValue(origRawXnode, definition); + PrismContainerValue newCVal = xnodeProcessor.parsePrismContainerValue(origRawXnode, definition); return newCVal; } List origRawElements = origCVal.rawElements; if (origRawElements != null) { - PrismContainerValue newCVal = new PrismContainerValue(prismContext); + PrismContainerValue newCVal = new PrismContainerValue(prismContext); for (Object rawElement: origRawElements) { - Item subitem = parseRawElement(rawElement, definition); + Item subitem = parseRawElement(rawElement, definition); newCVal.merge(subitem); } return newCVal; @@ -1120,11 +1119,11 @@ private PrismContainerValue parseRawElementsToNewValue(PrismContainerValue } @SuppressWarnings({ "rawtypes", "unchecked" }) - void diffItems(PrismContainerValue thisValue, PrismContainerValue other, + void diffItems(PrismContainerValue thisValue, PrismContainerValue other, Collection deltas, boolean ignoreMetadata, boolean isLiteral) { if (thisValue.getItems() != null) { - for (Item thisItem: thisValue.getItems()) { + for (Item thisItem: thisValue.getItems()) { Item otherItem = other.findItem(thisItem.getElementName()); // The "delete" delta will also result from the following diff thisItem.diffInternal(otherItem, deltas, ignoreMetadata, isLiteral); @@ -1147,8 +1146,8 @@ void diffItems(PrismContainerValue thisValue, PrismContainerValue other, } @Override - protected PrismContainerDefinition getDefinition() { - return (PrismContainerDefinition) super.getDefinition(); + protected PrismContainerDefinition getDefinition() { + return (PrismContainerDefinition) super.getDefinition(); } @Override @@ -1156,35 +1155,35 @@ public void applyDefinition(ItemDefinition definition, boolean force) throws Sch if (!(definition instanceof PrismContainerDefinition)) { throw new IllegalArgumentException("Cannot apply "+definition+" to container " + this); } - applyDefinition((PrismContainerDefinition)definition, force); + applyDefinition((PrismContainerDefinition)definition, force); } - public void applyDefinition(PrismContainerDefinition definition, boolean force) throws SchemaException { - if (definition.isWildcard()) { + public void applyDefinition(PrismContainerDefinition containerDef, boolean force) throws SchemaException { + if (containerDef.isWildcard()) { // No point in aplying this. Nothing will change and there may be phantom errors. return; } if (rawElements != null) { for (Object rawElement: rawElements) { - Item subitem = parseRawElement(rawElement, definition); + Item subitem = parseRawElement(rawElement, containerDef); merge(subitem); } rawElements = null; } if (rawXNode != null) { - XNodeProcessor xnodeProcessor = definition.getPrismContext().getXnodeProcessor(); - PrismContainerValue newCVal = xnodeProcessor.parsePrismContainerValue(rawXNode, definition); + XNodeProcessor xnodeProcessor = containerDef.getPrismContext().getXnodeProcessor(); + PrismContainerValue newCVal = xnodeProcessor.parsePrismContainerValue(rawXNode, containerDef); // Maybe we need to manually reset parent on items? addAll(newCVal.getItems()); rawXNode = null; } if (items != null) { - for (Item item: items) { + for (Item item: items) { if (item.getDefinition() != null && !force) { // Item has a definition already, no need to apply it continue; } - ItemDefinition itemDefinition = determineItemDefinition(item.getElementName(), definition); + ItemDefinition itemDefinition = determineItemDefinition(item.getElementName(), containerDef); if (itemDefinition == null && item.getDefinition() != null && item.getDefinition().isDynamic()) { // We will not apply the null definition here. The item has a dynamic definition that we don't // want to destroy as it cannot be reconstructed later. @@ -1199,15 +1198,15 @@ public void applyDefinition(PrismContainerDefinition definition, boolean forc * This method can both return null and throws exception. It returns null in case there is no definition * but it is OK (e.g. runtime schema). It throws exception if there is no definition and it is not OK. */ - private ItemDefinition determineItemDefinition(QName itemName, PrismContainerDefinition containerDefinition) throws SchemaException { - ItemDefinition itemDefinition = containerDefinition.findItemDefinition(itemName); + private ID determineItemDefinition(QName itemName, PrismContainerDefinition containerDefinition) throws SchemaException { + ID itemDefinition = containerDefinition.findItemDefinition(itemName); if (itemDefinition == null) { if (containerDefinition.isRuntimeSchema()) { // If we have prism context, try to locate global definition. But even if that is not // found it is still OK. This is runtime container. We tolerate quite a lot here. PrismContext prismContext = getPrismContext(); if (prismContext != null) { - itemDefinition = prismContext.getSchemaRegistry().resolveGlobalItemDefinition(itemName); + itemDefinition = (ID) prismContext.getSchemaRegistry().resolveGlobalItemDefinition(itemName); } } else { throw new SchemaException("No definition for item " + itemName + " in " + getParent()); @@ -1223,7 +1222,7 @@ public void revive(PrismContext prismContext) throws SchemaException { } super.revive(prismContext); if (items != null) { - for (Item item: items) { + for (Item item: items) { item.revive(prismContext); } } @@ -1243,9 +1242,9 @@ public boolean isEmpty() { @Override public void normalize() { if (items != null) { - Iterator> iterator = items.iterator(); + Iterator> iterator = items.iterator(); while (iterator.hasNext()) { - Item item = iterator.next(); + Item item = iterator.next(); item.normalize(); if (item.isEmpty()) { iterator.remove(); @@ -1270,7 +1269,7 @@ public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitio } } if (items != null) { - for (Item item: items) { + for (Item item: items) { if (scope.isThorough()) { if (item == null) { throw new IllegalStateException("Null item in container value "+this+" ("+myPath+" in "+rootItem+")"); @@ -1296,23 +1295,23 @@ public void assertDefinitions(boolean tolerateRaw, String sourceDescription) thr if (getItems() == null){ return; } - for (Item item: getItems()) { + for (Item item: getItems()) { item.assertDefinitions(tolerateRaw, "value("+getId()+") in "+sourceDescription); } } - public PrismContainerValue clone() { - PrismContainerValue clone = new PrismContainerValue(getOriginType(), getOriginObject(), getParent(), getId(), this.concreteType, this.prismContext); + public PrismContainerValue clone() { + PrismContainerValue clone = new PrismContainerValue(getOriginType(), getOriginObject(), getParent(), getId(), this.concreteType, this.prismContext); copyValues(clone); return clone; } - protected void copyValues(PrismContainerValue clone) { + protected void copyValues(PrismContainerValue clone) { super.copyValues(clone); clone.id = this.id; if (this.items != null) { - for (Item item : this.items) { - Item clonedItem = item.clone(); + for (Item item : this.items) { + Item clonedItem = item.clone(); clonedItem.setParent(clone); if (clone.items == null) { clone.items = new ArrayList<>(this.items.size()); @@ -1325,6 +1324,27 @@ protected void copyValues(PrismContainerValue clone) { clone.rawElements = this.rawElements; } + protected void deepCloneDefinition(boolean ultraDeep, PrismContainerDefinition clonedContainerDef) { + for (Item item: items) { + deepCloneDefinitionItem(item, ultraDeep, clonedContainerDef); + } + } + + private > void deepCloneDefinitionItem(I item, boolean ultraDeep, PrismContainerDefinition clonedContainerDef) { + PrismContainerDefinition oldContainerDef = getDefinition(); + QName itemName = item.getElementName(); + ID oldItemDefFromContainer = oldContainerDef.findItemDefinition(itemName); + ID oldItemDef = item.getDefinition(); + ID clonedItemDef; + if (oldItemDefFromContainer == oldItemDef) { + clonedItemDef = clonedContainerDef.findItemDefinition(itemName); + } else { + clonedItemDef = (ID) oldItemDef.deepClone(ultraDeep); + } + item.propagateDeepCloneDefinition(ultraDeep, clonedItemDef); + item.setDefinition(clonedItemDef); + } + @Override public boolean equalsComplex(PrismValue other, boolean ignoreMetadata, boolean isLiteral) { if (other == null || !(other instanceof PrismContainerValue)) { @@ -1347,19 +1367,19 @@ public boolean equalsComplex(PrismContainerValue other, boolean ignoreMetadat if (this.items == null) { if (other.items != null) return false; - } else if (!this.equalsItems(this, (PrismContainerValue) other, ignoreMetadata, isLiteral)) { + } else if (!this.equalsItems(this, (PrismContainerValue) other, ignoreMetadata, isLiteral)) { return false; } return true; } - boolean equalsItems(PrismContainerValue other, boolean ignoreMetadata, boolean isLiteral) { + boolean equalsItems(PrismContainerValue other, boolean ignoreMetadata, boolean isLiteral) { return equalsItems(this, other, ignoreMetadata, isLiteral); } - boolean equalsItems(PrismContainerValue thisValue, PrismContainerValue other, + boolean equalsItems(PrismContainerValue thisValue, PrismContainerValue other, boolean ignoreMetadata, boolean isLiteral) { - Collection> deltas = new ArrayList>(); + Collection> deltas = new ArrayList>(); // The EMPTY_PATH is a lie. We don't really care if the returned deltas have correct path or not // we only care whether some deltas are returned or not. diffItems(thisValue, other, deltas, ignoreMetadata, isLiteral); @@ -1419,7 +1439,7 @@ public String debugDump(int indent) { sb.append("PCV").append(": "); } boolean multivalue = true; - PrismContainerable parent = getParent(); + PrismContainerable parent = getParent(); if (parent != null && parent.getDefinition() != null) { multivalue = parent.getDefinition().isMultiValue(); } @@ -1432,14 +1452,14 @@ public String debugDump(int indent) { sb.append("id=").append(PrettyPrinter.prettyPrint(getId())); } appendOriginDump(sb); - List> items = getItems(); + List> items = getItems(); if (items != null) { - Iterator> i = getItems().iterator(); + Iterator> i = getItems().iterator(); if (wasIndent && i.hasNext()) { sb.append("\n"); } while (i.hasNext()) { - Item item = i.next(); + Item item = i.next(); sb.append(item.debugDump(indent + 1)); if (i.hasNext()) { sb.append("\n"); @@ -1522,7 +1542,7 @@ private PrismContainerDefinition getConcreteTypeDefinition() { return concreteTypeDefinition; // may still be null at this moment } - private PrismContainerDefinition getActualDefinition() { + private PrismContainerDefinition getActualDefinition() { if (getParent() != null) { PrismContainerDefinition concreteDef = getConcreteTypeDefinition(); if (concreteDef != null) { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismObject.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismObject.java index 20a3777f602..3e895e00076 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismObject.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismObject.java @@ -49,23 +49,23 @@ * @author Radovan Semancik * */ -public class PrismObject extends PrismContainer { +public class PrismObject extends PrismContainer { private static final long serialVersionUID = 7321429132391159949L; protected String oid; protected String version; - private T objectable = null; + private O objectable = null; - public PrismObject(QName name, Class compileTimeClass) { + public PrismObject(QName name, Class compileTimeClass) { super(name, compileTimeClass); } - public PrismObject(QName name, Class compileTimeClass, PrismContext prismContext) { + public PrismObject(QName name, Class compileTimeClass, PrismContext prismContext) { super(name, compileTimeClass, prismContext); } - public PrismObject(QName name, PrismObjectDefinition definition, PrismContext prismContext) { + public PrismObject(QName name, PrismObjectDefinition definition, PrismContext prismContext) { super(name, definition, prismContext); } @@ -93,15 +93,15 @@ public void setVersion(String version) { } @Override - public PrismObjectDefinition getDefinition() { - return (PrismObjectDefinition) super.getDefinition(); + public PrismObjectDefinition getDefinition() { + return (PrismObjectDefinition) super.getDefinition(); } - public T asObjectable() { + public O asObjectable() { if (objectable != null) { return objectable; } - Class clazz = getCompileTimeClass(); + Class clazz = getCompileTimeClass(); if (clazz == null) { throw new SystemException("Unknown compile time class of this prism object '" + getElementName() + "'."); } @@ -111,7 +111,7 @@ public T asObjectable() { try { objectable = clazz.newInstance(); objectable.setupContainer(this); - return (T) objectable; + return (O) objectable; } catch (SystemException ex) { throw ex; } catch (Exception ex) { @@ -140,7 +140,7 @@ public void addExtensionItem(I item) throws SchemaException { } public PrismContainer createExtension() throws SchemaException { - PrismObjectDefinition objeDef = getDefinition(); + PrismObjectDefinition objeDef = getDefinition(); PrismContainerDefinition extensionDef = objeDef.findContainerDefinition(getExtensionContainerElementName()); PrismContainer extensionContainer = extensionDef.instantiate(); getValue().add(extensionContainer); @@ -152,7 +152,7 @@ private QName getExtensionContainerElementName() { } @Override - public void applyDefinition(ItemDefinition definition) throws SchemaException { + public void applyDefinition(PrismContainerDefinition definition) throws SchemaException { if (!(definition instanceof PrismObjectDefinition)) { throw new IllegalArgumentException("Cannot apply "+definition+" to object"); } @@ -160,7 +160,7 @@ public void applyDefinition(ItemDefinition definition) throws SchemaException { } @Override - public > I findItem(ItemPath path, Class type) { + public > I findItem(ItemPath path, Class type) { try { return findCreateItem(path, type, null, false); } catch (SchemaException e) { @@ -170,7 +170,7 @@ public > I findItem(ItemPath path, Class type) { } @Override - public Item findItem(ItemPath path) { + public Item findItem(ItemPath path) { try { return findCreateItem(path, Item.class, null, false); } catch (SchemaException e) { @@ -180,41 +180,45 @@ public Item findItem(ItemPath path) { } @Override - public > void removeItem(ItemPath path, Class itemType) { + public > void removeItem(ItemPath path, Class itemType) { // Objects are only a single-valued containers. The path of the object itself is "empty". // Fix this special behavior here. getValue().removeItem(path, itemType); } - public void addReplaceExisting(Item item) throws SchemaException { + public void addReplaceExisting(Item item) throws SchemaException { getValue().addReplaceExisting(item); } @Override - public PrismObject clone() { - PrismObject clone = new PrismObject(getElementName(), getDefinition(), prismContext); + public PrismObject clone() { + PrismObject clone = new PrismObject(getElementName(), getDefinition(), prismContext); copyValues(clone); return clone; } - protected void copyValues(PrismObject clone) { + protected void copyValues(PrismObject clone) { super.copyValues(clone); clone.oid = this.oid; clone.version = this.version; } + + public PrismObjectDefinition deepCloneDefinition(boolean ultraDeep) { + return (PrismObjectDefinition) super.deepCloneDefinition(ultraDeep); + } - public ObjectDelta diff(PrismObject other) { + public ObjectDelta diff(PrismObject other) { return diff(other, true, false); } - public ObjectDelta diff(PrismObject other, boolean ignoreMetadata, boolean isLiteral) { + public ObjectDelta diff(PrismObject other, boolean ignoreMetadata, boolean isLiteral) { if (other == null) { - ObjectDelta objectDelta = new ObjectDelta(getCompileTimeClass(), ChangeType.DELETE, getPrismContext()); + ObjectDelta objectDelta = new ObjectDelta(getCompileTimeClass(), ChangeType.DELETE, getPrismContext()); objectDelta.setOid(getOid()); return objectDelta; } // This must be a modify - ObjectDelta objectDelta = new ObjectDelta(getCompileTimeClass(), ChangeType.MODIFY, getPrismContext()); + ObjectDelta objectDelta = new ObjectDelta(getCompileTimeClass(), ChangeType.MODIFY, getPrismContext()); objectDelta.setOid(getOid()); Collection itemDeltas = new ArrayList(); @@ -224,27 +228,27 @@ public ObjectDelta diff(PrismObject other, boolean ignoreMetadata, boolean return objectDelta; } - public ObjectDelta createDelta(ChangeType changeType) { - ObjectDelta delta = new ObjectDelta(getCompileTimeClass(), changeType, getPrismContext()); + public ObjectDelta createDelta(ChangeType changeType) { + ObjectDelta delta = new ObjectDelta(getCompileTimeClass(), changeType, getPrismContext()); delta.setOid(getOid()); return delta; } - public ObjectDelta createAddDelta() { - ObjectDelta delta = createDelta(ChangeType.ADD); + public ObjectDelta createAddDelta() { + ObjectDelta delta = createDelta(ChangeType.ADD); // TODO: clone? delta.setObjectToAdd(this); return delta; } - public ObjectDelta createModifyDelta() { - ObjectDelta delta = createDelta(ChangeType.MODIFY); + public ObjectDelta createModifyDelta() { + ObjectDelta delta = createDelta(ChangeType.MODIFY); delta.setOid(this.getOid()); return delta; } - public ObjectDelta createDeleteDelta() { - ObjectDelta delta = createDelta(ChangeType.DELETE); + public ObjectDelta createDeleteDelta() { + ObjectDelta delta = createDelta(ChangeType.DELETE); delta.setOid(this.getOid()); return delta; } @@ -314,7 +318,7 @@ public boolean equivalent(Object obj) { return false; } else if (!oid.equals(other.oid)) return false; - ObjectDelta delta = diff(other, true, false); + ObjectDelta delta = diff(other, true, false); return delta.isEmpty(); } @@ -381,7 +385,7 @@ protected String additionalDumpDescription() { if (getVersion() != null) { sb.append(", v").append(getVersion()); } - PrismObjectDefinition def = getDefinition(); + PrismObjectDefinition def = getDefinition(); if (def != null) { sb.append(", ").append(DebugUtil.formatElementName(def.getTypeName())); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismProperty.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismProperty.java index c1de1129170..d5324f5139d 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismProperty.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ * * @author Radovan Semancik */ -public class PrismProperty extends Item> { +public class PrismProperty extends Item,PrismPropertyDefinition> { private static final long serialVersionUID = 6843901365945935660L; @@ -85,7 +85,7 @@ protected PrismProperty(QName name, PrismPropertyDefinition definition, Prism * @return applicable property definition */ public PrismPropertyDefinition getDefinition() { - return (PrismPropertyDefinition) definition; + return definition; } /** @@ -363,9 +363,9 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedItem findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { - return new PartiallyResolvedItem((Item)this, null); + return new PartiallyResolvedItem((Item)this, null); } for (PrismPropertyValue pvalue: getValues()) { T value = pvalue.getValue(); @@ -373,7 +373,7 @@ public PartiallyResolvedItem findPartial(ItemPath path throw new IllegalArgumentException("Attempt to resolve sub-path '"+path+"' on non-structured property value "+pvalue); } } - return new PartiallyResolvedItem((Item)this, path); + return new PartiallyResolvedItem((Item)this, path); } public PropertyDelta diff(PrismProperty other) { @@ -393,7 +393,7 @@ public PropertyDelta diff(PrismProperty other, boolean ignoreMetadata, boo } @Override - protected void checkDefinition(ItemDefinition def) { + protected void checkDefinition(PrismPropertyDefinition def) { if (!(def instanceof PrismPropertyDefinition)) { throw new IllegalArgumentException("Definition "+def+" cannot be applied to property "+this); } @@ -413,7 +413,7 @@ protected void copyValues(PrismProperty clone) { } } - @Override + @Override public int hashCode() { int result = super.hashCode(); return result; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyDefinition.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyDefinition.java index 4246498d69f..a865f3f6d18 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyDefinition.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyDefinition.java @@ -53,7 +53,7 @@ * * @author Radovan Semancik */ -public class PrismPropertyDefinition extends ItemDefinition { +public class PrismPropertyDefinition extends ItemDefinition> { private static final long serialVersionUID = 7259761997904371009L; private QName valueType; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyValue.java index 35e39a763c6..72b2a7cac81 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyValue.java @@ -213,7 +213,7 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedItem findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { throw new UnsupportedOperationException("Attempt to invoke findPartialItem on a property value"); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReference.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReference.java index 3361507ab54..1641ef6673c 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReference.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ * @author semancik * */ -public class PrismReference extends Item { +public class PrismReference extends Item { private static final long serialVersionUID = 1872343401395762657L; public PrismReference(QName name) { @@ -175,9 +175,9 @@ public Object find(ItemPath path) { @Override - public PartiallyResolvedItem findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { - return new PartiallyResolvedItem((Item)this, null); + return new PartiallyResolvedItem((Item)this, null); } if (!isSingleValue()) { throw new IllegalStateException("Attempt to resolve sub-path '"+path+"' on multi-value reference " + getElementName()); @@ -197,7 +197,7 @@ public ReferenceDelta createDelta(ItemPath path) { } @Override - protected void checkDefinition(ItemDefinition def) { + protected void checkDefinition(PrismReferenceDefinition def) { if (!(def instanceof PrismReferenceDefinition)) { throw new IllegalArgumentException("Cannot apply definition "+def+" to reference "+this); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceDefinition.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceDefinition.java index 223035cf101..0d1ff7a1399 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceDefinition.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ * @author Radovan Semancik * */ -public class PrismReferenceDefinition extends ItemDefinition { +public class PrismReferenceDefinition extends ItemDefinition { private static final long serialVersionUID = 2427488779612517600L; private QName targetTypeName; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceValue.java index f0e572be8de..d6b7b6253b3 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -198,11 +198,11 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedItem findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { - return new PartiallyResolvedItem((Item)getParent(), null); + return new PartiallyResolvedItem((Item)getParent(), null); } - return new PartiallyResolvedItem((Item)getParent(), path); + return new PartiallyResolvedItem((Item)getParent(), path); } private boolean compareLocalPart(QName a, QName b) { @@ -247,7 +247,7 @@ public void applyDefinition(PrismReferenceDefinition definition, boolean force) +": no definition for object type "+targetTypeName); } // this should do it - object.applyDefinition(objectDefinition, force); + object.applyDefinition((PrismObjectDefinition)objectDefinition, force); } @Override diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismValue.java index 888be064c0c..9fe3d0f8157 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismValue.java @@ -252,7 +252,7 @@ public static Collection resetParentCollection(Collect public abstract Object find(ItemPath path); - public abstract PartiallyResolvedItem findPartial(ItemPath path); + public abstract PartiallyResolvedItem findPartial(ItemPath path); @Override public int hashCode() { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ContainerDelta.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ContainerDelta.java index c2f71ef4235..5fa8476c964 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ContainerDelta.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ContainerDelta.java @@ -25,7 +25,7 @@ import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.SchemaException; -public class ContainerDelta extends ItemDelta> implements PrismContainerable { +public class ContainerDelta extends ItemDelta,PrismContainerDefinition> implements PrismContainerable { public ContainerDelta(PrismContainerDefinition itemDefinition, PrismContext prismContext) { super(itemDefinition, prismContext); @@ -74,7 +74,7 @@ public PrismContainerDefinition getDefinition() { } @Override - public void setDefinition(ItemDefinition definition) { + public void setDefinition(PrismContainerDefinition definition) { if (!(definition instanceof PrismContainerDefinition)) { throw new IllegalArgumentException("Cannot apply "+definition+" to container delta"); } @@ -86,7 +86,7 @@ public void setDefinition(ItemDefinition definition) { } @Override - public void applyDefinition(ItemDefinition definition) throws SchemaException { + public void applyDefinition(PrismContainerDefinition definition) throws SchemaException { if (!(definition instanceof PrismContainerDefinition)) { throw new IllegalArgumentException("Cannot apply definition "+definition+" to container delta "+this); } @@ -136,12 +136,12 @@ protected boolean isApplicableToType(Item item) { } @Override - public ItemDelta getSubDelta(ItemPath path) { + public ItemDelta getSubDelta(ItemPath path) { if (path.isEmpty()) { return this; } ItemDefinition itemDefinition = getDefinition().findItemDefinition(path); - ItemDelta itemDelta = itemDefinition.createEmptyDelta(getPath().subPath(path)); + ItemDelta itemDelta = itemDefinition.createEmptyDelta(getPath().subPath(path)); itemDelta.addValuesToAdd(findItemValues(path, getValuesToAdd())); itemDelta.addValuesToDelete(findItemValues(path, getValuesToDelete())); itemDelta.setValuesToReplace(findItemValues(path, getValuesToReplace())); @@ -157,7 +157,7 @@ private Collection findItemValues(ItemPath path, Collection subValues = new ArrayList(); for (PrismContainerValue cvalue: cvalues) { - Item item = cvalue.findItem(path); + Item item = cvalue.findItem(path); if (item != null) { subValues.addAll(item.getValues()); } @@ -189,7 +189,7 @@ public void expand(PrismObject object) throws SchemaEx if (container != null) { PrismContainerValue containerCVal = container.findValue(id); if (containerCVal != null) { - for (Item containerItem: containerCVal.getItems()) { + for (Item containerItem: containerCVal.getItems()) { deltaCVal.add(containerItem.clone()); } continue; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ItemDelta.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ItemDelta.java index 6bbee477953..ab1e0cd5730 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ItemDelta.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ItemDelta.java @@ -40,7 +40,7 @@ * @author Radovan Semancik * */ -public abstract class ItemDelta implements Itemable, DebugDumpable, Visitable, PathVisitable, Serializable { +public abstract class ItemDelta implements Itemable, DebugDumpable, Visitable, PathVisitable, Serializable { /** * Name of the property @@ -50,7 +50,7 @@ public abstract class ItemDelta implements Itemable, Debug * Parent path of the property (path to the property container) */ protected ItemPath parentPath; - protected ItemDefinition definition; + protected D definition; protected Collection valuesToReplace = null; protected Collection valuesToAdd = null; @@ -58,7 +58,7 @@ public abstract class ItemDelta implements Itemable, Debug transient private PrismContext prismContext; - protected ItemDelta(ItemDefinition itemDefinition, PrismContext prismContext) { + protected ItemDelta(D itemDefinition, PrismContext prismContext) { if (itemDefinition == null) { throw new IllegalArgumentException("Attempt to create item delta without a definition"); } @@ -69,7 +69,7 @@ protected ItemDelta(ItemDefinition itemDefinition, PrismContext prismContext) { this.definition = itemDefinition; } - protected ItemDelta(QName elementName, ItemDefinition itemDefinition, PrismContext prismContext) { + protected ItemDelta(QName elementName, D itemDefinition, PrismContext prismContext) { //checkPrismContext(prismContext, itemDefinition); this.prismContext = prismContext; this.elementName = elementName; @@ -77,7 +77,7 @@ protected ItemDelta(QName elementName, ItemDefinition itemDefinition, PrismConte this.definition = itemDefinition; } - protected ItemDelta(ItemPath parentPath, QName elementName, ItemDefinition itemDefinition, PrismContext prismContext) { + protected ItemDelta(ItemPath parentPath, QName elementName, D itemDefinition, PrismContext prismContext) { //checkPrismContext(prismContext, itemDefinition); this.prismContext = prismContext; this.elementName = elementName; @@ -85,7 +85,7 @@ protected ItemDelta(ItemPath parentPath, QName elementName, ItemDefinition itemD this.definition = itemDefinition; } - protected ItemDelta(ItemPath path, ItemDefinition itemDefinition, PrismContext prismContext) { + protected ItemDelta(ItemPath path, D itemDefinition, PrismContext prismContext) { //checkPrismContext(prismContext, itemDefinition); this.prismContext = prismContext; @@ -133,11 +133,11 @@ public ItemPath getPath() { return getParentPath().subPath(elementName); } - public ItemDefinition getDefinition() { + public D getDefinition() { return definition; } - public void setDefinition(ItemDefinition definition) { + public void setDefinition(D definition) { this.definition = definition; } @@ -214,7 +214,7 @@ private void acceptSet(Collection set, Long id, Visitor visitor, ItemPath res } } - public void applyDefinition(ItemDefinition definition) throws SchemaException { + public void applyDefinition(D definition) throws SchemaException { this.definition = definition; if (getValuesToAdd() != null) { for (V pval : getValuesToAdd()) { @@ -235,7 +235,7 @@ public void applyDefinition(ItemDefinition definition) throws SchemaException { public static void applyDefinition(Collection deltas, PrismObjectDefinition definition) throws SchemaException { - for (ItemDelta itemDelta : deltas) { + for (ItemDelta itemDelta : deltas) { ItemPath path = itemDelta.getPath(); ItemDefinition itemDefinition = definition.findItemDefinition(path, ItemDefinition.class); if (itemDefinition == null) { @@ -643,15 +643,15 @@ public void clear() { valuesToDelete = null; } - public static PropertyDelta findPropertyDelta(Collection deltas, QName propertyName) { + public static PropertyDelta findPropertyDelta(Collection deltas, QName propertyName) { return findPropertyDelta(deltas, new ItemPath(propertyName)); } - public static PropertyDelta findPropertyDelta(Collection deltas, ItemPath parentPath, QName propertyName) { + public static PropertyDelta findPropertyDelta(Collection deltas, ItemPath parentPath, QName propertyName) { return findPropertyDelta(deltas, new ItemPath(parentPath, propertyName)); } - public static PropertyDelta findPropertyDelta(Collection deltas, ItemPath propertyPath) { + public static PropertyDelta findPropertyDelta(Collection deltas, ItemPath propertyPath) { return findItemDelta(deltas, propertyPath, PropertyDelta.class); } @@ -663,24 +663,24 @@ public static ContainerDelta findContainerDelta(Col return findContainerDelta(deltas, new ItemPath(name)); } - public static D findItemDelta(Collection deltas, ItemPath propertyPath, Class deltaType) { + public static
DD findItemDelta(Collection deltas, ItemPath propertyPath, Class
deltaType) { if (deltas == null) { return null; } - for (ItemDelta delta : deltas) { + for (ItemDelta delta : deltas) { if (deltaType.isAssignableFrom(delta.getClass()) && delta.getPath().equivalent(propertyPath)) { - return (D) delta; + return (DD) delta; } } return null; } - public static Collection> findItemDeltasSubPath(Collection> deltas, ItemPath itemPath) { - Collection> foundDeltas = new ArrayList>(); + public static Collection> findItemDeltasSubPath(Collection> deltas, ItemPath itemPath) { + Collection> foundDeltas = new ArrayList>(); if (deltas == null) { return foundDeltas; } - for (ItemDelta delta : deltas) { + for (ItemDelta delta : deltas) { if (itemPath.isSubPath(delta.getPath())) { foundDeltas.add(delta); } @@ -702,7 +702,7 @@ public static void removeItemDelta(Collection deltasIterator = deltas.iterator(); while (deltasIterator.hasNext()) { - ItemDelta delta = deltasIterator.next(); + ItemDelta delta = deltasIterator.next(); if (deltaType.isAssignableFrom(delta.getClass()) && delta.getPath().equivalent(propertyPath)) { deltasIterator.remove(); } @@ -713,18 +713,18 @@ public static void removeItemDelta(Collection narrow(PrismObject object) { + public ItemDelta narrow(PrismObject object) { return narrow(object, null); } /** * Filters out all delta values that are meaningless to apply. E.g. removes all values to add that the property already has, * removes all values to delete that the property does not have, etc. */ - public ItemDelta narrow(PrismObject object, Comparator comparator) { - Item currentItem = (Item) object.findItem(getPath()); + public ItemDelta narrow(PrismObject object, Comparator comparator) { + Item currentItem = (Item) object.findItem(getPath()); if (currentItem == null) { if (valuesToDelete != null) { - ItemDelta clone = clone(); + ItemDelta clone = clone(); clone.valuesToDelete = null; return clone; } else { @@ -732,7 +732,7 @@ public ItemDelta narrow(PrismObject object, Comparator< return this; } } else { - ItemDelta clone = clone(); + ItemDelta clone = clone(); if (clone.valuesToDelete != null) { Iterator iterator = clone.valuesToDelete.iterator(); while (iterator.hasNext()) { @@ -790,7 +790,7 @@ public static void checkConsistence(Collection deltas, Cons } public static void checkConsistence(Collection deltas, boolean requireDefinition, boolean prohibitRaw, ConsistencyCheckScope scope) { - for (ItemDelta delta : deltas) { + for (ItemDelta delta : deltas) { delta.checkConsistence(requireDefinition, prohibitRaw, scope); } } @@ -879,7 +879,7 @@ private boolean isIn(Collection values, V val) { * Merge specified delta to this delta. This delta is assumed to be * chronologically earlier, delta provided in the parameter is chronilogically later. */ - public void merge(ItemDelta deltaToMerge) { + public void merge(ItemDelta deltaToMerge) { if (deltaToMerge.isEmpty()) { return; } @@ -926,7 +926,7 @@ public void simplify() { } } - private void cleanupAllTheWayUp(Item item) { + private void cleanupAllTheWayUp(Item item) { if (item.isEmpty()) { PrismValue itemParent = item.getParent(); if (itemParent != null) { @@ -935,8 +935,8 @@ private void cleanupAllTheWayUp(Item item) { if (itemParent.isEmpty()) { Itemable itemGrandparent = itemParent.getParent(); if (itemGrandparent != null) { - if (itemGrandparent instanceof Item) { - cleanupAllTheWayUp((Item)itemGrandparent); + if (itemGrandparent instanceof Item) { + cleanupAllTheWayUp((Item)itemGrandparent); } } } @@ -1018,7 +1018,7 @@ public void applyToMatchingPath(Item item) throws SchemaException { cleanupAllTheWayUp(item); } - public ItemDelta getSubDelta(ItemPath path) { + public ItemDelta getSubDelta(ItemPath path) { return this; } @@ -1052,7 +1052,7 @@ public static void accept(Collection modifications, Visitor * Returns the "new" state of the property - the state that would be after * the delta is applied. */ - public Item getItemNew() throws SchemaException { + public Item getItemNew() throws SchemaException { return getItemNew(null); } @@ -1060,11 +1060,11 @@ public Item getItemNew() throws SchemaException { * Returns the "new" state of the property - the state that would be after * the delta is applied. */ - public Item getItemNew(Item itemOld) throws SchemaException { + public Item getItemNew(Item itemOld) throws SchemaException { if (definition == null) { throw new IllegalStateException("No definition in "+this); } - Item itemNew; + Item itemNew; if (itemOld == null) { if (isEmpty()) { return null; @@ -1077,11 +1077,11 @@ public Item getItemNew(Item itemOld) throws SchemaException { return itemNew; } - public Item getItemNewMatchingPath(Item itemOld) throws SchemaException { + public Item getItemNewMatchingPath(Item itemOld) throws SchemaException { if (definition == null) { throw new IllegalStateException("No definition in "+this); } - Item itemNew; + Item itemNew; if (itemOld == null) { if (isEmpty()) { return null; @@ -1100,7 +1100,7 @@ public Item getItemNewMatchingPath(Item itemOld) throws SchemaException { * in this delta. As a consequence it also returns true if the two * deltas are equal. */ - public boolean contains(ItemDelta other) { + public boolean contains(ItemDelta other) { if (!this.getPath().equivalent(other.getPath())) { return false; } @@ -1129,9 +1129,9 @@ private boolean containsSet(Collection thisSet, Collection otherSet) { return thisSet.containsAll(otherSet); } - public abstract ItemDelta clone(); + public abstract ItemDelta clone(); - protected void copyValues(ItemDelta clone) { + protected void copyValues(ItemDelta clone) { clone.definition = this.definition; clone.elementName = this.elementName; clone.parentPath = this.parentPath; @@ -1153,7 +1153,7 @@ private Collection cloneSet(ItemDelta clone, Collection thisSet) { return clonedSet; } - public static > Collection cloneCollection(Collection orig) { + public static > Collection cloneCollection(Collection orig) { if (orig == null) { return null; } @@ -1166,7 +1166,7 @@ public static > Collection cloneCollection(Collection< @Deprecated - public static PrismValueDeltaSetTriple toDeltaSetTriple(Item item, ItemDelta delta, + public static PrismValueDeltaSetTriple toDeltaSetTriple(Item item, ItemDelta delta, boolean oldValuesValid, boolean newValuesValid) { if (item == null && delta == null) { return null; @@ -1176,7 +1176,7 @@ public static PrismValueDeltaSetTriple toDeltaSetTripl } if (oldValuesValid && !newValuesValid) { // There were values but they no longer are -> everything to minus set - PrismValueDeltaSetTriple triple = new PrismValueDeltaSetTriple(); + PrismValueDeltaSetTriple triple = new PrismValueDeltaSetTriple(); if (item != null) { triple.addAllToMinusSet(item.getValues()); } @@ -1186,7 +1186,7 @@ public static PrismValueDeltaSetTriple toDeltaSetTripl return delta.toDeltaSetTriple(item); } if (delta == null || (!oldValuesValid && newValuesValid)) { - PrismValueDeltaSetTriple triple = new PrismValueDeltaSetTriple(); + PrismValueDeltaSetTriple triple = new PrismValueDeltaSetTriple(); if (item != null) { triple.addAllToZeroSet(item.getValues()); } @@ -1195,12 +1195,12 @@ public static PrismValueDeltaSetTriple toDeltaSetTripl return delta.toDeltaSetTriple(item); } - public static PrismValueDeltaSetTriple toDeltaSetTriple(Item item, ItemDelta delta) { + public static PrismValueDeltaSetTriple toDeltaSetTriple(Item item, ItemDelta delta) { if (item == null && delta == null) { return null; } if (delta == null) { - PrismValueDeltaSetTriple triple = new PrismValueDeltaSetTriple(); + PrismValueDeltaSetTriple triple = new PrismValueDeltaSetTriple(); triple.addAllToZeroSet(PrismValue.cloneCollection(item.getValues())); return triple; } @@ -1211,7 +1211,7 @@ public PrismValueDeltaSetTriple toDeltaSetTriple() { return toDeltaSetTriple(null); } - public PrismValueDeltaSetTriple toDeltaSetTriple(Item itemOld) { + public PrismValueDeltaSetTriple toDeltaSetTriple(Item itemOld) { PrismValueDeltaSetTriple triple = new PrismValueDeltaSetTriple(); if (isReplace()) { triple.getPlusSet().addAll(PrismValue.cloneCollection(getValuesToReplace())); @@ -1262,7 +1262,7 @@ private void assertDefinitions(boolean tolarateRawValues, Collection values, if (cval.getItems() == null){ continue; } - for (Item item: cval.getItems()) { + for (Item item: cval.getItems()) { item.assertDefinitions(tolarateRawValues, cval.toString()+" in "+sourceDescription); } } @@ -1305,7 +1305,7 @@ private void reviveSet(Collection set, PrismContext prismContext) throws Sche } } - public void applyDefinition(ItemDefinition itemDefinition, boolean force) throws SchemaException { + public void applyDefinition(D itemDefinition, boolean force) throws SchemaException { if (this.definition != null && !force) { return; } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ObjectDelta.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ObjectDelta.java index 544d8214ea8..abc5198ec29 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ObjectDelta.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ObjectDelta.java @@ -68,7 +68,7 @@ public class ObjectDelta implements DebugDumpable, Visitab /** * Set of relative property deltas. Valid only if changeType==MODIFY */ - private Collection> modifications; + private Collection> modifications; /** * Class of the object that we describe. @@ -95,7 +95,7 @@ public void accept(Visitor visitor){ if (isAdd()) { objectToAdd.accept(visitor); } else if (isModify()) { - for (ItemDelta delta : getModifications()){ + for (ItemDelta delta : getModifications()){ delta.accept(visitor); } } @@ -189,7 +189,7 @@ public void setObjectToAdd(PrismObject objectToAdd) { } } - public Collection getModifications() { + public Collection> getModifications() { return modifications; } @@ -224,28 +224,29 @@ public boolean containsModification(ItemDelta itemDelta) { } public void addModifications(Collection itemDeltas) { - for (ItemDelta modDelta: itemDeltas) { + for (ItemDelta modDelta: itemDeltas) { addModification(modDelta); } } - public void addModifications(ItemDelta... itemDeltas) { - for (ItemDelta modDelta: itemDeltas) { + public void addModifications(ItemDelta... itemDeltas) { + for (ItemDelta modDelta: itemDeltas) { addModification(modDelta); } } - public ItemDelta findItemDelta(ItemPath propertyPath) { + public ItemDelta findItemDelta(ItemPath propertyPath) { return findItemDelta(propertyPath, ItemDelta.class, Item.class); } - private D findItemDelta(ItemPath propertyPath, Class deltaType, Class itemType) { + private ,DD extends ItemDelta> + DD findItemDelta(ItemPath propertyPath, Class
deltaType, Class itemType) { if (changeType == ChangeType.ADD) { I item = objectToAdd.findItem(propertyPath, itemType); if (item == null) { return null; } - D itemDelta = createEmptyDelta(propertyPath, item.getDefinition(), deltaType, item.getClass()); + DD itemDelta = createEmptyDelta(propertyPath, item.getDefinition(), deltaType, item.getClass()); itemDelta.addValuesToAdd(item.getClonedValues()); return itemDelta; } else if (changeType == ChangeType.MODIFY) { @@ -255,25 +256,25 @@ private D findItemDelta(ItemPath propertyP } } - public PartiallyResolvedDelta findPartial(ItemPath propertyPath) { + public PartiallyResolvedDelta findPartial(ItemPath propertyPath) { if (changeType == ChangeType.ADD) { - PartiallyResolvedItem partialValue = objectToAdd.findPartial(propertyPath); + PartiallyResolvedItem partialValue = objectToAdd.findPartial(propertyPath); if (partialValue == null || partialValue.getItem() == null) { return null; } - Item item = partialValue.getItem(); - ItemDelta itemDelta = item.createDelta(); + Item item = partialValue.getItem(); + ItemDelta itemDelta = item.createDelta(); itemDelta.addValuesToAdd(item.getClonedValues()); - return new PartiallyResolvedDelta(itemDelta, partialValue.getResidualPath()); + return new PartiallyResolvedDelta(itemDelta, partialValue.getResidualPath()); } else if (changeType == ChangeType.MODIFY) { - for (ItemDelta modification: modifications) { + for (ItemDelta modification: modifications) { CompareResult compareComplex = modification.getPath().compareComplex(propertyPath); if (compareComplex == CompareResult.EQUIVALENT) { - return new PartiallyResolvedDelta((ItemDelta)modification, null); + return new PartiallyResolvedDelta((ItemDelta)modification, null); } else if (compareComplex == CompareResult.SUPERPATH) { - return new PartiallyResolvedDelta((ItemDelta)modification, null); + return new PartiallyResolvedDelta((ItemDelta)modification, null); } else if (compareComplex == CompareResult.SUBPATH) { - return new PartiallyResolvedDelta((ItemDelta)modification, + return new PartiallyResolvedDelta((ItemDelta)modification, propertyPath.remainder(modification.getPath())); } } @@ -378,7 +379,7 @@ public ReferenceDelta findReferenceModification(ItemPath itemPath) { /** * Returns all item deltas at or below a specified path. */ - public Collection> findItemDeltasSubPath(ItemPath itemPath) { + public Collection> findItemDeltasSubPath(ItemPath itemPath) { return ItemDelta.findItemDeltasSubPath(modifications, itemPath); } @@ -414,7 +415,7 @@ public boolean isEmpty() { if (modifications == null || modifications.isEmpty()) { return true; } - for (ItemDelta mod: modifications) { + for (ItemDelta mod: modifications) { if (!mod.isEmpty()) { return false; } @@ -429,7 +430,7 @@ public void normalize() { if (modifications != null) { Iterator iterator = modifications.iterator(); while (iterator.hasNext()) { - ItemDelta modification = iterator.next(); + ItemDelta modification = iterator.next(); modification.normalize(); if (modification.isEmpty()) { iterator.remove(); @@ -452,7 +453,7 @@ public ObjectDelta clone() { ObjectDelta clone = new ObjectDelta(this.objectTypeClass, this.changeType, this.prismContext); clone.oid = this.oid; clone.modifications = createEmptyModifications(); - for (ItemDelta thisModification: this.modifications) { + for (ItemDelta thisModification: this.modifications) { ((Collection)clone.modifications).add(thisModification.clone()); } if (this.objectToAdd == null) { @@ -600,12 +601,12 @@ private static ObjectDelta mergeToDelta(ObjectDelta } public void mergeModifications(Collection modificationsToMerge) throws SchemaException { - for (ItemDelta propDelta : modificationsToMerge) { + for (ItemDelta propDelta : modificationsToMerge) { mergeModification(propDelta); } } - public void mergeModification(ItemDelta modificationToMerge) throws SchemaException { + public void mergeModification(ItemDelta modificationToMerge) throws SchemaException { if (changeType == ChangeType.ADD) { modificationToMerge.applyTo(objectToAdd); } else if (changeType == ChangeType.MODIFY) { @@ -669,7 +670,7 @@ public PrismObject computeChangedObject(PrismObject objectOld) throws Sche * Incorporates the property delta into the existing property deltas * (regardless of the change type). */ - public void swallow(ItemDelta newItemDelta) throws SchemaException { + public void swallow(ItemDelta newItemDelta) throws SchemaException { if (changeType == ChangeType.MODIFY) { // TODO: check for conflict addModification(newItemDelta); @@ -680,19 +681,19 @@ public void swallow(ItemDelta newItemDelta) throws SchemaException { // nothing to do for DELETE } - private Collection> createEmptyModifications() { + private Collection> createEmptyModifications() { // Lists are easier to debug - return new ArrayList>(); + return new ArrayList>(); } - public PropertyDelta createPropertyModification(QName name, PrismPropertyDefinition propertyDefinition) { + public PropertyDelta createPropertyModification(QName name, PrismPropertyDefinition propertyDefinition) { PropertyDelta propertyDelta = new PropertyDelta(name, propertyDefinition, prismContext); return addModification(propertyDelta); } public PropertyDelta createPropertyModification(ItemPath path) { PrismObjectDefinition objDef = getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(getObjectTypeClass()); - PrismPropertyDefinition propDef = objDef.findPropertyDefinition(path); + PrismPropertyDefinition propDef = objDef.findPropertyDefinition(path); return createPropertyModification(path, propDef); } @@ -1247,7 +1248,7 @@ public void assertDefinitions(boolean tolerateRawElements, String sourceDescript objectToAdd.assertDefinitions("add delta in "+sourceDescription); } if (changeType == ChangeType.MODIFY) { - for (ItemDelta mod: modifications) { + for (ItemDelta mod: modifications) { mod.assertDefinitions(tolerateRawElements, "modify delta for "+getOid()+" in "+sourceDescription); } } @@ -1258,7 +1259,7 @@ public void revive(PrismContext prismContext) throws SchemaException { objectToAdd.revive(prismContext); } if (modifications != null) { - for (ItemDelta modification: modifications) { + for (ItemDelta modification: modifications) { modification.revive(prismContext); } } @@ -1273,7 +1274,7 @@ public void applyDefinition(PrismObjectDefinition objectDefinition, boolean f objectToAdd.applyDefinition(objectDefinition, force); } if (modifications != null) { - for (ItemDelta modification: modifications) { + for (ItemDelta modification: modifications) { ItemPath path = modification.getPath(); ItemDefinition itemDefinition = objectDefinition.findItemDefinition(path); modification.applyDefinition(itemDefinition, force); diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/PartiallyResolvedDelta.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/PartiallyResolvedDelta.java index d07c3880496..08d3aa2562f 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/PartiallyResolvedDelta.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/PartiallyResolvedDelta.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.evolveum.midpoint.prism.delta; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.path.ItemPath; @@ -22,22 +23,22 @@ * @author semancik * */ -public class PartiallyResolvedDelta { +public class PartiallyResolvedDelta { - private ItemDelta delta; + private ItemDelta delta; private ItemPath residualPath; - public PartiallyResolvedDelta(ItemDelta itemDelta, ItemPath residualPath) { + public PartiallyResolvedDelta(ItemDelta itemDelta, ItemPath residualPath) { super(); this.delta = itemDelta; this.residualPath = residualPath; } - public ItemDelta getDelta() { + public ItemDelta getDelta() { return delta; } - public void setDelta(ItemDelta itemDelta) { + public void setDelta(ItemDelta itemDelta) { this.delta = itemDelta; } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/PropertyDelta.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/PropertyDelta.java index bb1d9f16a4a..b4e03bbdea2 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/PropertyDelta.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/PropertyDelta.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,34 +51,34 @@ * @author Radovan Semancik * @see ObjectDelta */ -public class PropertyDelta extends ItemDelta> { +public class PropertyDelta extends ItemDelta,PrismPropertyDefinition> { - public PropertyDelta(PrismPropertyDefinition propertyDefinition, PrismContext prismContext) { + public PropertyDelta(PrismPropertyDefinition propertyDefinition, PrismContext prismContext) { super(propertyDefinition, prismContext); } - public PropertyDelta(QName name, PrismPropertyDefinition propertyDefinition, PrismContext prismContext) { + public PropertyDelta(QName name, PrismPropertyDefinition propertyDefinition, PrismContext prismContext) { super(name, propertyDefinition, prismContext); } - public PropertyDelta(ItemPath parentPath, QName name, PrismPropertyDefinition propertyDefinition, PrismContext prismContext) { + public PropertyDelta(ItemPath parentPath, QName name, PrismPropertyDefinition propertyDefinition, PrismContext prismContext) { super(parentPath, name, propertyDefinition, prismContext); } - public PropertyDelta(ItemPath propertyPath, PrismPropertyDefinition propertyDefinition, PrismContext prismContext) { + public PropertyDelta(ItemPath propertyPath, PrismPropertyDefinition propertyDefinition, PrismContext prismContext) { super(propertyPath, propertyDefinition, prismContext); } - public PrismPropertyDefinition getPropertyDefinition() { - return (PrismPropertyDefinition) super.getDefinition(); + public PrismPropertyDefinition getPropertyDefinition() { + return super.getDefinition(); } - void setPropertyDefinition(PrismPropertyDefinition propertyDefinition) { + void setPropertyDefinition(PrismPropertyDefinition propertyDefinition) { super.setDefinition(propertyDefinition); } @Override - public void setDefinition(ItemDefinition definition) { + public void setDefinition(PrismPropertyDefinition definition) { if (!(definition instanceof PrismPropertyDefinition)) { throw new IllegalArgumentException("Cannot apply "+definition+" to property delta"); } @@ -86,7 +86,7 @@ public void setDefinition(ItemDefinition definition) { } @Override - public void applyDefinition(ItemDefinition definition) throws SchemaException { + public void applyDefinition(PrismPropertyDefinition definition) throws SchemaException { if (!(definition instanceof PrismPropertyDefinition)) { throw new IllegalArgumentException("Cannot apply "+definition+" to a property delta "+this); } @@ -370,7 +370,7 @@ public static Collection createModificationReplacePropertyC return modifications; } - public static PropertyDelta findPropertyDelta(Collection modifications, ItemPath propertyPath) { + public static PropertyDelta findPropertyDelta(Collection modifications, ItemPath propertyPath) { for (ItemDelta delta: modifications) { if (delta instanceof PropertyDelta && delta.getPath().equivalent(propertyPath)) { return (PropertyDelta) delta; @@ -379,7 +379,7 @@ public static PropertyDelta findPropertyDelta(Collection mo return null; } - public static PropertyDelta findPropertyDelta(Collection modifications, QName propertyName) { + public static PropertyDelta findPropertyDelta(Collection modifications, QName propertyName) { for (ItemDelta delta: modifications) { if (delta instanceof PropertyDelta && delta.getParentPath().isEmpty() && QNameUtil.match(delta.getElementName(),propertyName)) { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ReferenceDelta.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ReferenceDelta.java index 21842edc88b..5bfa0773014 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ReferenceDelta.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ReferenceDelta.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ * @author semancik * */ -public class ReferenceDelta extends ItemDelta { +public class ReferenceDelta extends ItemDelta { public ReferenceDelta(PrismReferenceDefinition itemDefinition, PrismContext prismContext) { super(itemDefinition, prismContext); @@ -62,7 +62,7 @@ public Class getItemClass() { } @Override - public void setDefinition(ItemDefinition definition) { + public void setDefinition(PrismReferenceDefinition definition) { if (!(definition instanceof PrismReferenceDefinition)) { throw new IllegalArgumentException("Cannot apply "+definition+" to reference delta"); } @@ -70,7 +70,7 @@ public void setDefinition(ItemDefinition definition) { } @Override - public void applyDefinition(ItemDefinition definition) throws SchemaException { + public void applyDefinition(PrismReferenceDefinition definition) throws SchemaException { if (!(definition instanceof PrismReferenceDefinition)) { throw new IllegalArgumentException("Cannot apply definition "+definition+" to reference delta "+this); } @@ -139,14 +139,14 @@ public static ReferenceDelta createModificationReplace(QName refName, PrismObjec public static Collection createModificationAddCollection(QName propertyName, PrismObjectDefinition objectDefinition, PrismReferenceValue refValue) { - Collection> modifications = createModificationsCollection(1); + Collection> modifications = createModificationsCollection(1); ReferenceDelta delta = createModificationAdd(propertyName, objectDefinition, refValue); ((Collection)modifications).add(delta); return modifications; } - private static Collection> createModificationsCollection(int initSize) { - return new ArrayList>(initSize); + private static Collection> createModificationsCollection(int initSize) { + return new ArrayList>(initSize); } public static ReferenceDelta createModificationAdd(QName refName, PrismObjectDefinition objectDefinition, @@ -197,7 +197,7 @@ public static Collection createModif public static Collection createModificationAddCollection(Class type, QName refName, PrismContext prismContext, PrismReferenceValue refValue) { - Collection> modifications = createModificationsCollection(1); + Collection> modifications = createModificationsCollection(1); ReferenceDelta delta = createModificationAdd(type, refName, prismContext, refValue); ((Collection)modifications).add(delta); return modifications; @@ -211,7 +211,7 @@ public static ReferenceDelta createModificationAdd(Class< public static Collection createModificationAddCollection(Class type, QName refName, PrismContext prismContext, PrismObject refTarget) { - Collection> modifications = createModificationsCollection(1); + Collection> modifications = createModificationsCollection(1); ReferenceDelta delta = createModificationAdd(type, refName, prismContext, refTarget); ((Collection)modifications).add(delta); return modifications; @@ -261,7 +261,7 @@ public static ReferenceDelta createModificationDelete(Cla public static Collection createModificationDeleteCollection(Class type, QName refName, PrismContext prismContext, PrismReferenceValue refValue) { - Collection> modifications = createModificationsCollection(1); + Collection> modifications = createModificationsCollection(1); ReferenceDelta delta = createModificationDelete(type, refName, prismContext, refValue); ((Collection)modifications).add(delta); return modifications; @@ -280,7 +280,7 @@ public static ReferenceDelta createModificationDelete(Cla public static Collection createModificationDeleteCollection(Class type, QName refName, PrismContext prismContext, PrismObject refTarget) { - Collection> modifications = createModificationsCollection(1); + Collection> modifications = createModificationsCollection(1); ReferenceDelta delta = createModificationDelete(type, refName, prismContext, refTarget); ((Collection)modifications).add(delta); return modifications; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/json/PrismJasonProcessor.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/json/PrismJasonProcessor.java index 36a43fce4cc..e3c37fe5cb5 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/json/PrismJasonProcessor.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/json/PrismJasonProcessor.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2013-2015 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.evolveum.midpoint.prism.json; import java.io.File; @@ -150,7 +166,7 @@ private void serializeToJson(PrismContainerValue val, // } generator.writeStartObject(); - for (Item item : val.getItems()){ + for (Item item : val.getItems()){ // generator.writeFieldName(item.getElementName().getLocalPart()); if (item.isEmpty()){ @@ -407,7 +423,7 @@ private PrismContainer parsePrismContainer(JsonNode private void addValuesToContainerValue(PrismContainerValue containerValue, Collection newContainerItems) throws SchemaException { - for (Item newItem : newContainerItems) { + for (Item newItem : newContainerItems) { if (newItem == null){ //System.out.println("new item name null"); continue; @@ -423,14 +439,14 @@ private void addValuesToContainerValue(PrismContainerV } } - protected Collection> parsePrismContainerItems(JsonNode jsonObject, + protected Collection> parsePrismContainerItems(JsonNode jsonObject, PrismContainerDefinition containerDefinition, String defaultNamespace) throws SchemaException, JsonParseException, JsonMappingException, IOException { // TODO: more robustness in handling schema violations (min/max // constraints, etc.) - Collection> props = new HashSet>(); + Collection> props = new HashSet<>(); // Iterate over all the XML elements there. Each element is // an item value. @@ -483,7 +499,7 @@ protected Collection> parsePrismCont // if (item.getValue().isObject()){ // parsePrismContainerItems(item.getValue(), containerDefinition, defaultNamespace); // } else{ - Item parsedItem = parseItem(item.getValue(), itemQName, defaultNamespace, def); + Item parsedItem = parseItem(item.getValue(), itemQName, defaultNamespace, def); props.add(parsedItem); // } } @@ -522,19 +538,19 @@ private ItemDefinition locateItemDefinition( return def; } - public Item parseItem(JsonNode values, QName itemName, String defaultNamespace, ItemDefinition def) + public Item parseItem(JsonNode values, QName itemName, String defaultNamespace, ItemDefinition def) throws SchemaException, JsonParseException, JsonMappingException, IOException { if (def == null) { // Assume property in a container with runtime definition - return (Item) parsePrismPropertyRaw(values, itemName); + return (Item) parsePrismPropertyRaw(values, itemName); } if (def instanceof PrismContainerDefinition) { - return (Item) parsePrismContainer(values, itemName, defaultNamespace, (PrismContainerDefinition) def); + return (Item) parsePrismContainer(values, itemName, defaultNamespace, (PrismContainerDefinition) def); } else if (def instanceof PrismPropertyDefinition) { - return (Item) parsePrismProperty(values, itemName, (PrismPropertyDefinition) def); + return (Item) parsePrismProperty(values, itemName, (PrismPropertyDefinition) def); } if (def instanceof PrismReferenceDefinition) { - return (Item) parsePrismReference(values, itemName, (PrismReferenceDefinition) def); + return (Item) parsePrismReference(values, itemName, (PrismReferenceDefinition) def); } else { throw new IllegalArgumentException("Attempt to parse unknown definition type " + def.getClass().getName()); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/JaxbDomHack.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/JaxbDomHack.java index cd0bc6b1a30..c17cd843b47 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/JaxbDomHack.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/JaxbDomHack.java @@ -214,7 +214,7 @@ private ItemDefinition resolveGlobalItemDefinition( /** * This is used in a form of "fromAny" to parse elements from a JAXB getAny method to prism. */ - public Item parseRawElement(Object element, PrismContainerDefinition definition) throws SchemaException { + public Item parseRawElement(Object element, PrismContainerDefinition definition) throws SchemaException { Validate.notNull(definition, "Attempt to parse raw element in a container without definition"); QName elementName = JAXBUtil.getElementQName(element); @@ -228,12 +228,12 @@ public Item parseRawElement(Ob } PrismContext prismContext = definition.getPrismContext(); - Item subItem; + Item subItem; if (element instanceof Element) { // DOM Element DomParser domParser = prismContext.getParserDom(); XNode xnode = domParser.parseElementContent((Element)element); - subItem = prismContext.getXnodeProcessor().parseItem(xnode, elementName, itemDefinition); + subItem = (Item) prismContext.getXnodeProcessor().parseItem(xnode, elementName, itemDefinition); } else if (element instanceof JAXBElement) { // JAXB Element JAXBElement jaxbElement = (JAXBElement)element; @@ -245,13 +245,13 @@ public Item parseRawElement(Ob // property PrismProperty property = ((PrismPropertyDefinition)itemDefinition).instantiate(); property.setRealValue(jaxbBean); - subItem = (Item) property; + subItem = (Item) property; } else if (itemDefinition instanceof PrismContainerDefinition) { if (jaxbBean instanceof Containerable) { PrismContainer container = ((PrismContainerDefinition)itemDefinition).instantiate(); PrismContainerValue subValue = ((Containerable)jaxbBean).asPrismContainerValue(); container.add(subValue); - subItem = (Item) container; + subItem = (Item) container; } else { throw new IllegalArgumentException("Unsupported JAXB bean "+jaxbBean.getClass()); } @@ -261,7 +261,7 @@ public Item parseRawElement(Ob PrismReference reference = ((PrismReferenceDefinition)itemDefinition).instantiate(); PrismReferenceValue refValue = ((Referencable) jaxbBean).asReferenceValue(); reference.merge(refValue); - subItem = (Item) reference; + subItem = (Item) reference; } else{ throw new IllegalArgumentException("Unsupported JAXB bean" + jaxbBean); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/QueryConvertor.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/QueryConvertor.java index 46d13172013..376f891e97c 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/QueryConvertor.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/QueryConvertor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -403,7 +403,7 @@ private static RefFilter parseRefFilter(XNode xnode, P XNode valueXnode = xmap.get(KEY_FILTER_EQUAL_VALUE); if (valueXnode != null){ - Item item = prismContext.getXnodeProcessor().parseItem(valueXnode, itemName, itemDefinition); + Item item = prismContext.getXnodeProcessor().parseItem(valueXnode, itemName, itemDefinition); if (preliminaryParsingOnly) { return null; @@ -569,7 +569,7 @@ private static QName determineMatchingRule(MapXNode xmap) throws SchemaException } private static Item parseItem(XNode valueXnode, QName itemName, ItemDefinition itemDefinition, PrismContext prismContext) throws SchemaException{ - Item item; + Item item; if (prismContext == null) { item = (Item)XNodeProcessor.parsePrismPropertyRaw(valueXnode, itemName, prismContext); } else { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/XNodeProcessor.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/XNodeProcessor.java index a49a5e176b8..60dc424d0a7 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/XNodeProcessor.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/XNodeProcessor.java @@ -349,7 +349,7 @@ private PrismContainerValue parsePrismContainerValu } } } - Item item = parseItem(xentry.getValue(), itemQName, itemDef); + Item item = parseItem(xentry.getValue(), itemQName, itemDef); // Merge must be here, not just add. Some items (e.g. references) have alternative // names and representations and these cannot be processed as one map or list if (item != null) { @@ -949,20 +949,20 @@ private ItemDefinition resolveGlobalItemDefinition( * method to call. Value elements have the same element name. They may be * elements of a property or a container. */ - public Item parseItem(XNode xnode, QName itemName, ItemDefinition itemDef) + public Item parseItem(XNode xnode, QName itemName, ItemDefinition itemDef) throws SchemaException { if (itemDef == null) { // Assume property in a container with runtime definition - return (Item) parsePrismPropertyRaw(xnode, itemName, prismContext); + return (Item) parsePrismPropertyRaw(xnode, itemName, prismContext); } if (itemDef instanceof PrismObjectDefinition) { return parseObject(xnode, itemName, (PrismObjectDefinition) itemDef); } else if (itemDef instanceof PrismContainerDefinition) { - return (Item) parseContainerInternal(xnode, itemName, (PrismContainerDefinition) itemDef); + return (Item) parseContainerInternal(xnode, itemName, (PrismContainerDefinition) itemDef); } else if (itemDef instanceof PrismPropertyDefinition) { - return (Item) parsePrismProperty(xnode, itemName, (PrismPropertyDefinition) itemDef); + return (Item) parsePrismProperty(xnode, itemName, (PrismPropertyDefinition) itemDef); } else if (itemDef instanceof PrismReferenceDefinition) { - return (Item) parsePrismReference(xnode, itemName, (PrismReferenceDefinition) itemDef); + return (Item) parsePrismReference(xnode, itemName, (PrismReferenceDefinition) itemDef); } else { throw new IllegalArgumentException("Attempt to parse unknown definition type " + itemDef.getClass().getName()); } @@ -1167,7 +1167,7 @@ public RootXNode serializeObject(PrismObject object, b // return serializer.serializeContainerValueAsRoot(cval, elementName); // } - public XNode serializeItem(Item item) throws SchemaException { + public XNode serializeItem(Item item) throws SchemaException { XNodeSerializer serializer = createSerializer(); return serializer.serializeItem(item); } @@ -1187,7 +1187,7 @@ public XNode serializeItemValue(PrismValue pval) throws SchemaException { return serializer.serializeItemValue(pval, null); } - public RootXNode serializeItemAsRoot(Item item) throws SchemaException { + public RootXNode serializeItemAsRoot(Item item) throws SchemaException { XNodeSerializer serializer = createSerializer(); return serializer.serializeItemAsRoot(item); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/XNodeSerializer.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/XNodeSerializer.java index 56aa1b75be9..14caee14617 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/XNodeSerializer.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/parser/XNodeSerializer.java @@ -109,12 +109,12 @@ private MapXNode serializeObjectContent(PrismObject ob //endregion //region Serializing (any) items - public XNode serializeItem(Item item) throws SchemaException { + public XNode serializeItem(Item item) throws SchemaException { ListXNode xlist = new ListXNode(); - List values = item.getValues(); + List values = item.getValues(); ItemDefinition definition = item.getDefinition(); - for (V val: values) { + for (IV val: values) { XNode xsubnode = serializeItemValue(val, definition); xlist.add(xsubnode); } @@ -168,7 +168,7 @@ private RootXNode serializeItemValueAsRootInternal(PrismValue value, QName eleme return new RootXNode(elementName, valueNode); } - public RootXNode serializeItemAsRoot(Item item) throws SchemaException { + public RootXNode serializeItemAsRoot(Item item) throws SchemaException { Validate.notNull(item.getDefinition(), "Item without a definition"); XNode valueNode = serializeItem(item); return new RootXNode(item.getDefinition().getName(), valueNode); @@ -243,7 +243,7 @@ private void serializeContainerValue(MapXNode xmap, Pr // document won't pass schema validation for (ItemDefinition itemDef: containerDefinition.getDefinitions()) { QName elementName = itemDef.getName(); - Item item = containerVal.findItem(elementName); + Item item = containerVal.findItem(elementName); if (item != null) { XNode xsubnode = serializeItem(item); xmap.put(elementName, xsubnode); @@ -254,7 +254,7 @@ private void serializeContainerValue(MapXNode xmap, Pr // There are some cases when we do not have list of all elements in a container. // E.g. in run-time schema. Therefore we must also iterate over items and not just item definitions. if (containerVal.getItems() != null){ - for (Item item : containerVal.getItems()) { + for (Item item : containerVal.getItems()) { QName elementName = item.getElementName(); if (serializedItems.contains(elementName)) { continue; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/schema/SchemaRegistry.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/schema/SchemaRegistry.java index acd39651e66..071c437270a 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/schema/SchemaRegistry.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/schema/SchemaRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -780,7 +780,7 @@ public PrismSchema findSchemaByCompileTimeClass(Class compileTimeClass) { return null; } - public PrismObjectDefinition findObjectDefinitionByCompileTimeClass(Class compileTimeClass) { + public PrismObjectDefinition findObjectDefinitionByCompileTimeClass(Class compileTimeClass) { PrismSchema schema = findSchemaByCompileTimeClass(compileTimeClass); if (schema == null) { return null; @@ -788,15 +788,15 @@ public PrismObjectDefinition findObjectDefinitionByCom return schema.findObjectDefinitionByCompileTimeClass(compileTimeClass); } - public void applyDefinition(PrismObject prismObject, Class type) throws SchemaException { + public void applyDefinition(PrismObject prismObject, Class type) throws SchemaException { applyDefinition(prismObject, type, true); } /** * This method will try to locate the appropriate object definition and apply it. */ - public void applyDefinition(PrismObject prismObject, Class type, boolean force) throws SchemaException { - PrismObjectDefinition objectDefinition = determineDefinitionFromClass(type); + public void applyDefinition(PrismObject prismObject, Class type, boolean force) throws SchemaException { + PrismObjectDefinition objectDefinition = determineDefinitionFromClass(type); prismObject.applyDefinition(objectDefinition, force); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/CloneUtil.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/CloneUtil.java index 6b52346eca9..a09263a4c0b 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/CloneUtil.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/CloneUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,8 +77,8 @@ public static T clone(T orig) { if (orig instanceof RawType){ return (T) ((RawType) orig).clone(); } - if (orig instanceof Item) { - return (T) ((Item)orig).clone(); + if (orig instanceof Item) { + return (T) ((Item)orig).clone(); } if (orig instanceof PrismValue) { return (T) ((PrismValue)orig).clone(); @@ -89,8 +89,8 @@ public static T clone(T orig) { if (orig instanceof ObjectDeltaType) { return (T) ((ObjectDeltaType) orig).clone(); } - if (orig instanceof ItemDelta) { - return (T) ((ItemDelta)orig).clone(); + if (orig instanceof ItemDelta) { + return (T) ((ItemDelta)orig).clone(); } if (orig instanceof Definition) { return (T) ((Definition)orig).clone(); diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/PrismAsserts.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/PrismAsserts.java index 9d510aa853c..3da1b4c1197 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/PrismAsserts.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/PrismAsserts.java @@ -167,11 +167,11 @@ public static void assertNoItem(PrismContainer object, QName itemName) { } public static void assertNoItem(PrismContainer object, ItemPath itemPath) { - Item item = object.findItem(itemPath); + Item item = object.findItem(itemPath); assert item == null : "Unexpected item "+item+" in "+object; } - public static void assertNotEmpty(Item item) { + public static void assertNotEmpty(Item item) { assert !item.isEmpty() : "Item "+item+" is empty"; } @@ -180,7 +180,7 @@ public static void assertNoEmptyItem(PrismContainer container) { @Override public void visit(Visitable visitable) { if (visitable != null && visitable instanceof Item) { - assertNotEmpty((Item)visitable); + assertNotEmpty((Item)visitable); } } }; @@ -292,14 +292,14 @@ public static void assertValueId(Long expectedId, Prism public static void assertParentConsistency(PrismContainerValue pval) { if (pval.getItems() != null) { - for (Item item : pval.getItems()) { + for (Item item : pval.getItems()) { assert item.getParent() == pval : "Wrong parent in " + item; assertParentConsistency(item); } } } - public static void assertParentConsistency(Item item) { + public static void assertParentConsistency(Item item) { for (PrismValue pval: item.getValues()) { assert pval.getParent() == item : "Wrong parent of "+pval+" in "+PrettyPrinter.prettyPrint(item.getElementName()); if (pval instanceof PrismContainerValue) { @@ -472,27 +472,27 @@ public static void asserHasDelta(String message, Collection void assertNoReplace(ItemDelta delta) { + public static void assertNoReplace(ItemDelta delta) { assertNoReplace(null, delta); } - public static void assertNoReplace(String message, ItemDelta delta) { + public static void assertNoReplace(String message, ItemDelta delta) { assertNoSet(message, "replace", delta.getValuesToReplace()); } - public static void assertNoAdd(ItemDelta delta) { + public static void assertNoAdd(ItemDelta delta) { assertNoAdd(null, delta); } - public static void assertNoAdd(String message, ItemDelta delta) { + public static void assertNoAdd(String message, ItemDelta delta) { assertNoSet(message, "add", delta.getValuesToAdd()); } - public static void assertNoDelete(ItemDelta delta) { + public static void assertNoDelete(ItemDelta delta) { assertNoDelete(null, delta); } - public static void assertNoDelete(String message, ItemDelta delta) { + public static void assertNoDelete(String message, ItemDelta delta) { assertNoSet(message, "delete", delta.getValuesToDelete()); } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/RawTypeUtil.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/RawTypeUtil.java index 2f4f37ab5a5..6099f6beccc 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/RawTypeUtil.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/util/RawTypeUtil.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2013-2015 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.evolveum.midpoint.prism.util; import java.util.ArrayList; @@ -39,16 +55,16 @@ public class RawTypeUtil { - public static Item getParsedItem(ItemDefinition itemDefinition, List values, QName elementQName, PrismContainerDefinition containerDef) throws SchemaException{ + public static Item getParsedItem(ID itemDefinition, List values, QName elementQName, PrismContainerDefinition containerDef) throws SchemaException{ - Item subItem = null; + Item subItem = null; - List parsedValues = new ArrayList(); + List parsedValues = new ArrayList(); for (RawType rawValue : values){ if (itemDefinition == null && containerDef != null){ - itemDefinition = containerDef.getPrismContext().getXnodeProcessor().locateItemDefinition(containerDef, elementQName, rawValue.getXnode()); + itemDefinition = (ID) containerDef.getPrismContext().getXnodeProcessor().locateItemDefinition(containerDef, elementQName, rawValue.getXnode()); } - V parsed = rawValue.getParsedValue(itemDefinition, elementQName); + IV parsed = rawValue.getParsedValue(itemDefinition, elementQName); if (parsed != null){ parsedValues.add(parsed); } @@ -72,25 +88,25 @@ public static Item getParsedItem(ItemDefinition itemDe if (itemDefinition instanceof PrismPropertyDefinition) { // property PrismProperty property = ((PrismPropertyDefinition) itemDefinition).instantiate(); - for (V val : parsedValues){ + for (IV val : parsedValues){ property.add((PrismPropertyValue) val.clone()); } - subItem = (Item) property; + subItem = (Item) property; } else if (itemDefinition instanceof PrismContainerDefinition) { PrismContainer container = ((PrismContainerDefinition) itemDefinition) .instantiate(); - for (V val : parsedValues){ + for (IV val : parsedValues){ container.add((PrismContainerValue) val.clone()); } - subItem = (Item) container; + subItem = (Item) container; } else if (itemDefinition instanceof PrismReferenceDefinition) { // TODO PrismReference reference = ((PrismReferenceDefinition) itemDefinition).instantiate(); - for (V val : parsedValues){ + for (IV val : parsedValues){ reference.merge((PrismReferenceValue) val.clone()); } - subItem = (Item) reference; + subItem = (Item) reference; } else { throw new IllegalArgumentException("Unsupported definition type " + itemDefinition.getClass()); diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/xjc/AnyArrayList.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/xjc/AnyArrayList.java index 94e5e8ffd1c..2a793544bd0 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/xjc/AnyArrayList.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/xjc/AnyArrayList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public int size() { if (containerValue.isEmpty()){ return size; } - for (Item item: containerValue.getItems()) { + for (Item item: containerValue.getItems()) { size += item.getValues().size(); } return size; @@ -80,7 +80,7 @@ public Object get(int index) { return containerValue.getRawElements().get(index); } else { if (containerValue != null) { - for (Item item : containerValue.getItems()) { + for (Item item : containerValue.getItems()) { if (index < item.getValues().size()) { return asElement(item.getValue(index)); } else { @@ -133,7 +133,7 @@ public Object remove(int index) { if (isSchemaless()) { return containerValue.getRawElements().remove(index); } else { - for (Item item: containerValue.getItems()) { + for (Item item: containerValue.getItems()) { if (index < item.getValues().size()) { item.remove(index); } else { diff --git a/infra/prism/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/RawType.java b/infra/prism/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/RawType.java index 14fe455d277..8d29e335cdc 100644 --- a/infra/prism/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/RawType.java +++ b/infra/prism/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/RawType.java @@ -80,46 +80,46 @@ public PrismContext getPrismContext() { //region Parsing and serialization // itemDefinition may be null; in that case we do the best what we can - public V getParsedValue(ItemDefinition itemDefinition, QName itemName) throws SchemaException { + public IV getParsedValue(ItemDefinition itemDefinition, QName itemName) throws SchemaException { if (parsed != null) { - return (V) parsed; + return (IV) parsed; } else if (xnode != null) { - V value; + IV value; if (itemDefinition != null) { if (itemName == null) { itemName = itemDefinition.getName(); } checkPrismContext(); - Item subItem = PrismUtil.getXnodeProcessor(prismContext).parseItem(xnode, itemName, itemDefinition); + Item subItem = PrismUtil.getXnodeProcessor(prismContext).parseItem(xnode, itemName, itemDefinition); if (!subItem.isEmpty()){ value = subItem.getValue(0); } else { value = null; } } else { - PrismProperty subItem = XNodeProcessor.parsePrismPropertyRaw(xnode, itemName, prismContext); - value = (V) subItem.getValue(); + PrismProperty subItem = XNodeProcessor.parsePrismPropertyRaw(xnode, itemName, prismContext); + value = (IV) subItem.getValue(); } xnode = null; parsed = value; - return (V) parsed; + return (IV) parsed; } else { return null; } } - public Item getParsedItem(ItemDefinition itemDefinition) throws SchemaException { + public Item getParsedItem(ID itemDefinition) throws SchemaException { Validate.notNull(itemDefinition); return getParsedItem(itemDefinition, itemDefinition.getName()); } - public Item getParsedItem(ItemDefinition itemDefinition, QName itemName) throws SchemaException { + public Item getParsedItem(ID itemDefinition, QName itemName) throws SchemaException { Validate.notNull(itemDefinition); Validate.notNull(itemName); - Item item = itemDefinition.instantiate(); - V newValue = getParsedValue(itemDefinition, itemName); + Item item = itemDefinition.instantiate(); + IV newValue = getParsedValue(itemDefinition, itemName); if (newValue != null) { - item.add((V) newValue.clone()); + item.add((IV) newValue.clone()); } return item; } diff --git a/infra/prism/src/test/java/com/evolveum/midpoint/prism/TestDelta.java b/infra/prism/src/test/java/com/evolveum/midpoint/prism/TestDelta.java index 973d655bddb..3faea4296cd 100644 --- a/infra/prism/src/test/java/com/evolveum/midpoint/prism/TestDelta.java +++ b/infra/prism/src/test/java/com/evolveum/midpoint/prism/TestDelta.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ public void testDeltaPaths() throws Exception { assignmentValue1.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "jamalalicha patlama paprtala", PrismTestUtil.getPrismContext()); ObjectDelta assObjDelta1 = ObjectDelta.createModificationAddContainer(UserType.class, USER_FOO_OID, UserType.F_ASSIGNMENT, PrismTestUtil.getPrismContext(), assignmentValue1); - ItemDelta assDelta1 = assObjDelta1.getModifications().iterator().next(); + ItemDelta assDelta1 = assObjDelta1.getModifications().iterator().next(); assertPath(assDelta1, new ItemPath(UserType.F_ASSIGNMENT)); PrismContainerValue assignmentValue2 = new PrismContainerValue(PrismTestUtil.getPrismContext()); @@ -88,7 +88,7 @@ public void testDeltaPaths() throws Exception { assignmentValue1.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "jamalalicha patlama paprtala", PrismTestUtil.getPrismContext()); ObjectDelta assObjDelta2 = ObjectDelta.createModificationAddContainer(UserType.class, USER_FOO_OID, UserType.F_ASSIGNMENT, PrismTestUtil.getPrismContext(), assignmentValue2); - ItemDelta assDelta2 = assObjDelta2.getModifications().iterator().next(); + ItemDelta assDelta2 = assObjDelta2.getModifications().iterator().next(); assertPath(assDelta2, new ItemPath(UserType.F_ASSIGNMENT)); PrismPropertyDefinition assDescDefinition = new PrismPropertyDefinition<>(AssignmentType.F_DESCRIPTION, @@ -106,7 +106,7 @@ public void testDeltaPaths() throws Exception { } - private void assertPath(ItemDelta delta, ItemPath expectedPath) { + private void assertPath(ItemDelta delta, ItemPath expectedPath) { assertEquals("Wrong path in "+delta, expectedPath, delta.getPath()); } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/DeltaConvertor.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/DeltaConvertor.java index 6bd8eb40cc4..10bccb6e0d9 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/DeltaConvertor.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/DeltaConvertor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -177,7 +177,7 @@ public static ObjectModificationType toObjectModification ObjectModificationType modType = new ObjectModificationType(); modType.setOid(delta.getOid()); List propModTypes = modType.getItemDelta(); - for (ItemDelta propDelta : delta.getModifications()) { + for (ItemDelta propDelta : delta.getModifications()) { Collection propPropModTypes; try { propPropModTypes = toPropertyModificationTypes(propDelta); @@ -221,7 +221,7 @@ public static ObjectDeltaType toObjectDeltaType(ObjectDelta propDelta : objectDelta.getModifications()) { + for (ItemDelta propDelta : objectDelta.getModifications()) { Collection propPropModTypes; try { propPropModTypes = toPropertyModificationTypes(propDelta); @@ -273,7 +273,7 @@ private static ChangeTypeType convertChangeType(ChangeType changeType) { * Creates delta from PropertyModificationType (XML). The values inside the PropertyModificationType are converted to java. * That's the reason this method needs schema and objectType (to locate the appropriate definitions). */ - public static ItemDelta createItemDelta(ItemDeltaType propMod, + public static ItemDelta createItemDelta(ItemDeltaType propMod, Class objectType, PrismContext prismContext) throws SchemaException { Validate.notNull("No prismContext in DeltaConvertor.createItemDelta call"); PrismObjectDefinition objectDefinition = prismContext.getSchemaRegistry(). @@ -281,7 +281,7 @@ public static ItemDelta createItemDelta(ItemDeltaType return createItemDelta(propMod, objectDefinition); } - public static ItemDelta createItemDelta(ItemDeltaType propMod, PrismContainerDefinition pcDef, boolean allowRawValues) throws + public static ItemDelta createItemDelta(ItemDeltaType propMod, PrismContainerDefinition pcDef, boolean allowRawValues) throws SchemaException { ItemPathType parentPathType = propMod.getPath(); ItemPath parentPath = null; @@ -307,7 +307,7 @@ public static ItemDelta createItemDelta(ItemDeltaType } QName elementName = parentPath.lastNamed().getName(); Item item = RawTypeUtil.getParsedItem(containingPcd, propMod.getValue(), elementName, containerDef);//propMod.getValue().getParsedValue(containingPcd); - ItemDelta itemDelta = item.createDelta(parentPath); + ItemDelta itemDelta = item.createDelta(parentPath); if (propMod.getModificationType() == ModificationTypeType.ADD) { itemDelta.addValuesToAdd(PrismValue.resetParentCollection(PrismValue.cloneCollection(item.getValues()))); } else if (propMod.getModificationType() == ModificationTypeType.DELETE) { @@ -320,7 +320,7 @@ public static ItemDelta createItemDelta(ItemDeltaType } - public static ItemDelta createItemDelta(ItemDeltaType propMod, PrismContainerDefinition pcDef) throws + public static ItemDelta createItemDelta(ItemDeltaType propMod, PrismContainerDefinition pcDef) throws SchemaException { return createItemDelta(propMod, pcDef, false); } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java index 31f86ba3505..4fb837b95d4 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -414,7 +414,7 @@ public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitio throw new IllegalStateException(values.size()+" values in ResourceAttributeContainer, expected just one"); } PrismContainerValue value = values.get(0); - List> items = value.getItems(); + List> items = value.getItems(); if (items == null) { return; } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java index 4eb5f8724b6..1d3d2569496 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java @@ -193,7 +193,7 @@ public static Collection> createCollection(Obj * Convenience method that helps avoid some compiler warnings. */ @SuppressWarnings({ "rawtypes", "unchecked" }) - public static Collection> createCollection(ItemDelta... deltas) { + public static Collection> createCollection(ItemDelta... deltas) { return (Collection)MiscUtil.createCollection(deltas); } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ReportTypeUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ReportTypeUtil.java index f72a3ee64ff..d34410acf87 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ReportTypeUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ReportTypeUtil.java @@ -136,7 +136,7 @@ public static PrismContainerDefinition findReportConfig public static void applyDefinition(PrismObject report, PrismContext prismContext) throws SchemaException { - PrismContainer configuration = report.findContainer(ReportType.F_CONFIGURATION); + PrismContainer configuration = report.findContainer(ReportType.F_CONFIGURATION); if (configuration == null) { //nothing to apply definitions on return; diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ResourceTypeUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ResourceTypeUtil.java index e52553c627d..96c76fca118 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ResourceTypeUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ResourceTypeUtil.java @@ -27,6 +27,7 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType; @@ -46,9 +47,11 @@ import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; + import org.w3c.dom.Element; import javax.xml.namespace.QName; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -399,11 +402,11 @@ public static ResourceObjectTypeDefinitionType getResourceObjectTypeDefinitionTy return null; } - public static PrismContainer getConfigurationContainer(ResourceType resourceType) { + public static PrismContainer getConfigurationContainer(ResourceType resourceType) { return getConfigurationContainer(resourceType.asPrismObject()); } - public static PrismContainer getConfigurationContainer(PrismObject resource) { + public static PrismContainer getConfigurationContainer(PrismObject resource) { return resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ShadowUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ShadowUtil.java index 22cf21e5277..298a2795093 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ShadowUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ShadowUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -290,7 +290,7 @@ private static void applyObjectClass(PrismObject shadow, PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); ResourceAttributeContainerDefinition racDef = new ResourceAttributeContainerDefinition(ShadowType.F_ATTRIBUTES, objectClassDefinition, objectClassDefinition.getPrismContext()); - attributesContainer.applyDefinition(racDef, true); + attributesContainer.applyDefinition((PrismContainerDefinition) racDef, true); } public static PrismObjectDefinition applyObjectClass(PrismObjectDefinition shadowDefinition, diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDeltaConverter.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDeltaConverter.java index 783c1ce9827..3e382aaa2a7 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDeltaConverter.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDeltaConverter.java @@ -384,7 +384,7 @@ public void testItemDeltaReplace() throws Exception { System.out.println(itemDeltaTypes); // WHEN - ItemDelta deltaAfter = DeltaConvertor.createItemDelta(itemDeltaTypes.iterator().next(), userDef); + ItemDelta deltaAfter = DeltaConvertor.createItemDelta(itemDeltaTypes.iterator().next(), userDef); // THEN System.out.println("Parsed"); @@ -410,7 +410,7 @@ public void testItemDeltaReplaceEmptyString() throws Exception { System.out.println(itemDeltaTypes); // WHEN - ItemDelta deltaAfter = DeltaConvertor.createItemDelta(itemDeltaTypes.iterator().next(), userDef); + ItemDelta deltaAfter = DeltaConvertor.createItemDelta(itemDeltaTypes.iterator().next(), userDef); // THEN System.out.println("Parsed"); @@ -439,7 +439,7 @@ public void testItemDeltaReplaceNil() throws Exception { System.out.println(xml); // WHEN - ItemDelta deltaAfter = DeltaConvertor.createItemDelta(itemDeltaType, userDef); + ItemDelta deltaAfter = DeltaConvertor.createItemDelta(itemDeltaType, userDef); // THEN System.out.println("Parsed"); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java index a17527558cb..9afce2012d3 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -255,7 +255,7 @@ private void assertGenericObject(PrismObject generic) throws PrismContainerDefinition extensionContainerDefinition = extensionContainer.getDefinition(); assertTrue("Extension container definition is NOT dynamic", extensionContainerDefinition.isDynamic()); PrismContainerValue extensionContainerValue = extensionContainer.getValue(); - List> extensionItems = extensionContainerValue.getItems(); + List> extensionItems = extensionContainerValue.getItems(); assertEquals("Wrong number of extension items", 5, extensionItems.size()); // COMPLEX RUN TIME PROPERTIES...NOT SUPPORTED WITH NEW PARSERS.. diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseResource.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseResource.java index bc90a40b421..a578bf5e7e8 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseResource.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -461,7 +461,7 @@ private void assertResourcePrism(PrismObject resource, boolean isS PrismContainer configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertContainerDefinition(configurationContainer, "configuration", ConnectorConfigurationType.COMPLEX_TYPE, 1, 1); PrismContainerValue configContainerValue = configurationContainer.getValue(); - List> configItems = configContainerValue.getItems(); + List> configItems = configContainerValue.getItems(); assertEquals("Wrong number of config items", isSimple ? 1 : 4, configItems.size()); PrismContainer ldapConfigPropertiesContainer = configurationContainer.findContainer(ICFC_CONFIGURATION_PROPERTIES); @@ -469,7 +469,7 @@ private void assertResourcePrism(PrismObject resource, boolean isS PrismContainerDefinition ldapConfigPropertiesContainerDef = ldapConfigPropertiesContainer.getDefinition(); assertNotNull("No icfcldap:configurationProperties container definition", ldapConfigPropertiesContainerDef); assertEquals("icfcldap:configurationProperties container definition maxOccurs", 1, ldapConfigPropertiesContainerDef.getMaxOccurs()); - List> ldapConfigPropItems = ldapConfigPropertiesContainer.getValue().getItems(); + List> ldapConfigPropItems = ldapConfigPropertiesContainer.getValue().getItems(); assertEquals("Wrong number of ldapConfigPropItems items", 7, ldapConfigPropItems.size()); PrismContainer schemaContainer = resource.findContainer(ResourceType.F_SCHEMA); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseUser.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseUser.java index a27c6678246..fb8bf2c4b9b 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseUser.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseUser.java @@ -238,7 +238,7 @@ void assertUserPrism(PrismObject user) { PrismContainer assignmentExtensionContainer = firstAssignmentValue.findContainer(AssignmentType.F_EXTENSION); PrismAsserts.assertDefinition(assignmentExtensionContainer.getDefinition(), AssignmentType.F_EXTENSION, ExtensionType.COMPLEX_TYPE, 0, 1); - List> assignmentExtensionItems = assignmentExtensionContainer.getValue().getItems(); + List> assignmentExtensionItems = assignmentExtensionContainer.getValue().getItems(); assertNotNull("No assignment extension items", assignmentExtensionItems); assertEquals("Wrong number of assignment extension items", 1, assignmentExtensionItems.size()); PrismProperty firstAssignmentExtensionItem = (PrismProperty) assignmentExtensionItems.get(0); diff --git a/infra/util/src/main/java/com/evolveum/midpoint/util/Validator.java b/infra/util/src/main/java/com/evolveum/midpoint/util/Validator.java new file mode 100644 index 00000000000..ff2148663ef --- /dev/null +++ b/infra/util/src/main/java/com/evolveum/midpoint/util/Validator.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2015 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.util; + +/** + * Interface for object validation (mostly to be used in tests). + * + * @author Radovan Semancik + */ +public interface Validator { + + /** + * Validate the provided object. Throws appropriate exception if + * the object is not valid. + * + * @param object object to validate + * @param name short string name of the object. Designed to be used in exception messages. + * @throws Exception appropriate exception if the object is not valid. + */ + void validate(T object, String name) throws Exception; + +} diff --git a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/ModelService.java b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/ModelService.java index 27101fd4f10..ac919f04a6a 100644 --- a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/ModelService.java +++ b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/ModelService.java @@ -274,7 +274,7 @@ void recompute(Class type, String oid, Task task, Oper * state */ PrismObject findShadowOwner(String shadowOid, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SecurityViolationException, SchemaException; + throws ObjectNotFoundException, SecurityViolationException, SchemaException, ConfigurationException; /** *

@@ -555,8 +555,8 @@ void importFromResource(String shadowOid, Task task, OperationResult parentResul * @return discovered connectors * @throws CommunicationException error communicating with the connector host */ - public Set discoverConnectors(ConnectorHostType hostType, OperationResult parentResult) - throws CommunicationException, SecurityViolationException, SchemaException; + public Set discoverConnectors(ConnectorHostType hostType, Task task, OperationResult parentResult) + throws CommunicationException, SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException; /** * Finish initialization of the model and lower system components diff --git a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java index 8f1b3278fe5..83ff7c6bf57 100644 --- a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java +++ b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -486,7 +486,7 @@ void recompute(Class type, String oid) * unknown error from underlying layers or other unexpected * state */ - PrismObject findShadowOwner(String accountOid) throws ObjectNotFoundException, SecurityViolationException, SchemaException; + PrismObject findShadowOwner(String accountOid) throws ObjectNotFoundException, SecurityViolationException, SchemaException, ConfigurationException; /** *

diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/Expression.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/Expression.java index a41a505fd0f..b2efbb8369f 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/Expression.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/Expression.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,17 +59,17 @@ * @author semancik * */ -public class Expression { +public class Expression { ExpressionType expressionType; - ItemDefinition outputDefinition; + D outputDefinition; PrismContext prismContext; ObjectResolver objectResolver; - List> evaluators = new ArrayList>(1); + List> evaluators = new ArrayList>(1); private static final Trace LOGGER = TraceManager.getTrace(Expression.class); - public Expression(ExpressionType expressionType, ItemDefinition outputDefinition, ObjectResolver objectResolver, PrismContext prismContext) { + public Expression(ExpressionType expressionType, D outputDefinition, ObjectResolver objectResolver, PrismContext prismContext) { //Validate.notNull(outputDefinition, "null outputDefinition"); Validate.notNull(objectResolver, "null objectResolver"); Validate.notNull(prismContext, "null prismContext"); @@ -98,7 +98,7 @@ public void parse(ExpressionFactory factory, String contextDescription, Operatio } } - private ExpressionEvaluator createEvaluator(Collection> evaluatorElements, ExpressionFactory factory, + private ExpressionEvaluator createEvaluator(Collection> evaluatorElements, ExpressionFactory factory, String contextDescription, OperationResult result) throws SchemaException, ObjectNotFoundException { if (evaluatorElements.isEmpty()) { @@ -112,7 +112,7 @@ private ExpressionEvaluator createEvaluator(Collection> evalua return evaluatorFactory.createEvaluator(evaluatorElements, outputDefinition, contextDescription, result); } - private ExpressionEvaluator createDefaultEvaluator(ExpressionFactory factory, String contextDescription, + private ExpressionEvaluator createDefaultEvaluator(ExpressionFactory factory, String contextDescription, OperationResult result) throws SchemaException, ObjectNotFoundException { ExpressionEvaluatorFactory evaluatorFactory = factory.getDefaultEvaluatorFactory(); if (evaluatorFactory == null) { @@ -134,7 +134,7 @@ public PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext context) ExpressionEvaluationContext processedParameters = context.shallowClone(); processedParameters.setVariables(processedVariables); - for (ExpressionEvaluator evaluator: evaluators) { + for (ExpressionEvaluator evaluator: evaluators) { PrismValueDeltaSetTriple outputTriple = (PrismValueDeltaSetTriple) evaluator.evaluate(processedParameters); if (outputTriple != null) { traceSuccess(context, processedVariables, outputTriple); @@ -193,11 +193,11 @@ private void appendTraceHeader(StringBuilder sb, ExpressionEvaluationContext con sb.append(context.getContextDescription()); sb.append("]---------------------------"); sb.append("\nSources:"); - Collection> sources = context.getSources(); + Collection> sources = context.getSources(); if (sources == null) { sb.append(" null"); } else { - for (Source source: sources) { + for (Source source: sources) { sb.append("\n"); sb.append(source.debugDump(1)); } @@ -278,7 +278,7 @@ public String shortDebugDump() { return evaluators.iterator().next().shortDebugDump(); } StringBuilder sb = new StringBuilder("["); - for (ExpressionEvaluator evaluator: evaluators) { + for (ExpressionEvaluator evaluator: evaluators) { sb.append(evaluator.shortDebugDump()); sb.append(","); } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluationContext.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluationContext.java index c1d0da64f68..adae90b7fb9 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluationContext.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluationContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +36,8 @@ */ public class ExpressionEvaluationContext { - private Collection> sources; - private Source defaultSource; + private Collection> sources; + private Source defaultSource; private ExpressionVariables variables; private boolean skipEvaluationPlus = false; private boolean skipEvaluationMinus = false; @@ -50,7 +50,7 @@ public class ExpressionEvaluationContext { private Task task; private OperationResult result; - public ExpressionEvaluationContext(Collection> sources, + public ExpressionEvaluationContext(Collection> sources, ExpressionVariables variables, String contextDescription, Task task, OperationResult result) { super(); @@ -61,19 +61,19 @@ public ExpressionEvaluationContext(Collection> sour this.result = result; } - public Collection> getSources() { + public Collection> getSources() { return sources; } - public void setSources(Collection> sources) { + public void setSources(Collection> sources) { this.sources = sources; } - public Source getDefaultSource() { + public Source getDefaultSource() { return defaultSource; } - public void setDefaultSource(Source defaultSource) { + public void setDefaultSource(Source defaultSource) { this.defaultSource = defaultSource; } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluator.java index 4d542556dbc..489fe4ff7e3 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ * @author Radovan Semancik * */ -public interface ExpressionEvaluator { +public interface ExpressionEvaluator { PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext parameters) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException; diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluatorFactory.java index 266ce0ca30a..51856298fcd 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionEvaluatorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +36,8 @@ public interface ExpressionEvaluatorFactory { QName getElementName(); - ExpressionEvaluator createEvaluator(Collection> evaluatorElements, - ItemDefinition outputDefinition, String contextDescription, OperationResult result) + ExpressionEvaluator createEvaluator(Collection> evaluatorElements, + D outputDefinition, String contextDescription, OperationResult result) throws SchemaException, ObjectNotFoundException; } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionFactory.java index 5cc4df6f283..9847877f825 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class ExpressionFactory { private Map evaluatorFactoriesMap = new HashMap(); private ExpressionEvaluatorFactory defaultEvaluatorFactory; - private Map> cache = new HashMap>(); + private Map> cache = new HashMap>(); private PrismContext prismContext; private ObjectResolver objectResolver; @@ -58,11 +58,11 @@ public void setEvaluatorFactories(Collection evaluat } } - public Expression makeExpression(ExpressionType expressionType, - ItemDefinition outputDefinition, String shortDesc, OperationResult result) + public Expression makeExpression(ExpressionType expressionType, + D outputDefinition, String shortDesc, OperationResult result) throws SchemaException, ObjectNotFoundException { ExpressionIdentifier eid = new ExpressionIdentifier(expressionType, outputDefinition); - Expression expression = (Expression) cache.get(eid); + Expression expression = (Expression) cache.get(eid); if (expression == null) { expression = createExpression(expressionType, outputDefinition, shortDesc, result); cache.put(eid, expression); @@ -70,10 +70,10 @@ public Expression makeExpression(ExpressionType expres return expression; } - private Expression createExpression(ExpressionType expressionType, - ItemDefinition outputDefinition, String shortDesc, OperationResult result) + private Expression createExpression(ExpressionType expressionType, + D outputDefinition, String shortDesc, OperationResult result) throws SchemaException, ObjectNotFoundException { - Expression expression = new Expression(expressionType, outputDefinition, objectResolver, prismContext); + Expression expression = new Expression(expressionType, outputDefinition, objectResolver, prismContext); expression.parse(this, shortDesc, result); return expression; } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionUtil.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionUtil.java index 98818749f9a..26f30ee860c 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionUtil.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -229,13 +229,13 @@ public static Object resolvePath(ItemPath path, ExpressionVariables variables, O return ((PrismContainer)root).find(relativePath); } else if (root instanceof PrismContainerValue) { return ((PrismContainerValue)root).find(relativePath); - } else if (root instanceof Item) { + } else if (root instanceof Item) { // Except for container (which is handled above) throw new SchemaException("Cannot apply path "+relativePath+" to "+root+" in "+shortDesc); } else if (root instanceof ObjectDeltaObject) { return ((ObjectDeltaObject)root).findIdi(relativePath); - } else if (root instanceof ItemDeltaItem) { - return ((ItemDeltaItem)root).findIdi(relativePath); + } else if (root instanceof ItemDeltaItem) { + return ((ItemDeltaItem)root).findIdi(relativePath); } else { throw new IllegalArgumentException("Unexpected root "+root+" (relative path:"+relativePath+") in "+shortDesc); } @@ -262,7 +262,7 @@ private static PrismObject resolveReference(ObjectReferenceType ref, ObjectRe } } - public static ItemDefinition resolveDefinitionPath(ItemPath path, ExpressionVariables variables, + public static ID resolveDefinitionPath(ItemPath path, ExpressionVariables variables, PrismObjectDefinition defaultContext, String shortDesc) throws SchemaException { while (path!=null && !path.isEmpty() && !(path.first() instanceof NameItemPathSegment)) { path = path.rest(); @@ -275,10 +275,10 @@ public static ItemDefinition resolveDefinitionPath(ItemPath path, ExpressionVari QName varName = first.getName(); if (variables.containsKey(varName)) { Object varValue = variables.get(varName); - if (varValue instanceof ItemDeltaItem) { - root = ((ItemDeltaItem)varValue).getDefinition(); - } else if (varValue instanceof Item) { - root = ((Item)varValue).getDefinition(); + if (varValue instanceof ItemDeltaItem) { + root = ((ItemDeltaItem)varValue).getDefinition(); + } else if (varValue instanceof Item) { + root = ((Item)varValue).getDefinition(); } else if (varValue instanceof Objectable) { root = ((Objectable)varValue).asPrismObject().getDefinition(); } else if (varValue instanceof ItemDefinition) { @@ -297,7 +297,7 @@ public static ItemDefinition resolveDefinitionPath(ItemPath path, ExpressionVari return null; } if (relativePath.isEmpty()) { - return (ItemDefinition) root; + return (ID) root; } ItemDefinition result = null; if (root instanceof PrismObjectDefinition) { @@ -312,22 +312,22 @@ public static ItemDefinition resolveDefinitionPath(ItemPath path, ExpressionVari } } - public static ItemDeltaItem toItemDeltaItem(Object object, ObjectResolver objectResolver, + public static ItemDeltaItem toItemDeltaItem(Object object, ObjectResolver objectResolver, String string, OperationResult result) { if (object == null) { return null; } - if (object instanceof ItemDeltaItem) { - return (ItemDeltaItem) object; + if (object instanceof ItemDeltaItem) { + return (ItemDeltaItem) object; } if (object instanceof PrismObject) { - return (ItemDeltaItem) new ObjectDeltaObject((PrismObject)object, null, (PrismObject)object); - } else if (object instanceof Item) { - return new ItemDeltaItem((Item)object, null, (Item)object); - } else if (object instanceof ItemDelta) { - return new ItemDeltaItem(null, (ItemDelta)object, null); + return (ItemDeltaItem) new ObjectDeltaObject((PrismObject)object, null, (PrismObject)object); + } else if (object instanceof Item) { + return new ItemDeltaItem((Item)object, null, (Item)object); + } else if (object instanceof ItemDelta) { + return new ItemDeltaItem(null, (ItemDelta)object, null); } else { throw new IllegalArgumentException("Unexpected object "+object+" "+object.getClass()); } @@ -400,7 +400,7 @@ private static ObjectFilter evaluateFilterExpressionsInternal(ObjectFilter filte // PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME, // DOMUtil.XSD_STRING, prismContext); // outputDefinition.setMaxOccurs(-1); - Collection expressionResult = evaluateExpression(variables, prismContext, valueExpression, expressionFactory, shortDesc, task, result); + Collection expressionResult = evaluateStringExpression(variables, prismContext, valueExpression, expressionFactory, shortDesc, task, result); if (expressionResult == null || expressionResult.isEmpty()) { LOGGER.debug("Result of search filter expression was null or empty. Expression: {}", @@ -525,12 +525,12 @@ private static V evaluateExpression(ExpressionVariables // shortDesc, result); } - public static V evaluateExpression(ExpressionVariables variables, - ItemDefinition outputDefinition, ExpressionType expressionType, + public static V evaluateExpression(ExpressionVariables variables, + D outputDefinition, ExpressionType expressionType, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { - Expression expression = expressionFactory.makeExpression(expressionType, + Expression expression = expressionFactory.makeExpression(expressionType, outputDefinition, shortDesc, parentResult); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task, parentResult); @@ -552,26 +552,26 @@ public static V evaluateExpression(ExpressionVariables va return nonNegativeValues.iterator().next(); } - public static Collection evaluateExpression(ExpressionVariables variables, PrismContext prismContext, + private static Collection evaluateStringExpression(ExpressionVariables variables, PrismContext prismContext, ExpressionType expressionType, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { - PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME, + PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME, DOMUtil.XSD_STRING, prismContext); outputDefinition.setMaxOccurs(-1); - Expression expression = expressionFactory.makeExpression(expressionType, + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, outputDefinition, shortDesc, parentResult); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task, parentResult); - PrismValueDeltaSetTriple outputTriple = expression.evaluate(params); + PrismValueDeltaSetTriple> outputTriple = expression.evaluate(params); LOGGER.trace("Result of the expression evaluation: {}", outputTriple); if (outputTriple == null) { return null; } - Collection nonNegativeValues = outputTriple.getNonNegativeValues(); + Collection> nonNegativeValues = outputTriple.getNonNegativeValues(); if (nonNegativeValues == null || nonNegativeValues.isEmpty()) { return null; } @@ -598,7 +598,7 @@ public static Map compileVariablesAndSources(ExpressionEvaluation } if (params.getSources() != null) { - for (Source source: params.getSources()) { + for (Source source: params.getSources()) { variablesAndSources.put(source.getName(), source); } } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionVariables.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionVariables.java index beebfa17aab..fcd555bc40c 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionVariables.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ExpressionVariables.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,8 +78,8 @@ public void addVariableDefinitionsOld(Map extraVariables) { if (value instanceof ObjectDeltaObject) { ObjectDeltaObject odo = (ObjectDeltaObject)value; value = odo.getOldObject(); - } else if (value instanceof ItemDeltaItem) { - ItemDeltaItem idi = (ItemDeltaItem)value; + } else if (value instanceof ItemDeltaItem) { + ItemDeltaItem idi = (ItemDeltaItem)value; value = idi.getItemOld(); } variables.put(entry.getKey(), value); @@ -101,8 +101,8 @@ public void addVariableDefinitionsNew(Map extraVariables) { if (value instanceof ObjectDeltaObject) { ObjectDeltaObject odo = (ObjectDeltaObject)value; value = odo.getNewObject(); - } else if (value instanceof ItemDeltaItem) { - ItemDeltaItem idi = (ItemDeltaItem)value; + } else if (value instanceof ItemDeltaItem) { + ItemDeltaItem idi = (ItemDeltaItem)value; value = idi.getItemNew(); } variables.put(entry.getKey(), value); diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ItemDeltaItem.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ItemDeltaItem.java index f558963f271..0b76289d1a4 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ItemDeltaItem.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ItemDeltaItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,66 +41,66 @@ * @author semancik * */ -public class ItemDeltaItem { +public class ItemDeltaItem { - Item itemOld; - ItemDelta delta; - Item itemNew; + Item itemOld; + ItemDelta delta; + Item itemNew; ItemPath resolvePath = ItemPath.EMPTY_PATH; ItemPath residualPath = null; // The deltas in sub-items. E.g. if this object represents "ContainerDeltaContainer" // this property contains property deltas that may exist inside the container. - Collection> subItemDeltas; + Collection> subItemDeltas; public ItemDeltaItem() { } - public ItemDeltaItem(Item itemOld, ItemDelta delta, Item itemNew) { + public ItemDeltaItem(Item itemOld, ItemDelta delta, Item itemNew) { super(); this.itemOld = itemOld; this.delta = delta; this.itemNew = itemNew; } - public ItemDeltaItem(ItemDeltaItem idi) { + public ItemDeltaItem(ItemDeltaItem idi) { super(); this.itemOld = idi.getItemOld(); this.itemNew = idi.getItemNew(); this.delta = idi.getDelta(); } - public ItemDeltaItem(Item item) { + public ItemDeltaItem(Item item) { super(); this.itemOld = item; this.itemNew = item; this.delta = null; } - public Item getItemOld() { + public Item getItemOld() { return itemOld; } - public void setItemOld(Item itemOld) { + public void setItemOld(Item itemOld) { this.itemOld = itemOld; } - public ItemDelta getDelta() { + public ItemDelta getDelta() { return delta; } - public void setDelta(ItemDelta delta) { + public void setDelta(ItemDelta delta) { this.delta = delta; } - public Item getItemNew() { + public Item getItemNew() { return itemNew; } - public void setItemNew(Item itemNew) { + public void setItemNew(Item itemNew) { this.itemNew = itemNew; } - public Item getAnyItem() { + public Item getAnyItem() { if (itemOld != null) { return itemOld; } @@ -123,11 +123,11 @@ public void setResolvePath(ItemPath resolvePath) { this.resolvePath = resolvePath; } - public Collection> getSubItemDeltas() { + public Collection> getSubItemDeltas() { return subItemDeltas; } - public void setSubItemDeltas(Collection> subItemDeltas) { + public void setSubItemDeltas(Collection> subItemDeltas) { this.subItemDeltas = subItemDeltas; } @@ -136,7 +136,7 @@ public boolean isNull() { } public QName getElementName() { - Item anyItem = getAnyItem(); + Item anyItem = getAnyItem(); if (anyItem != null) { return anyItem.getElementName(); } @@ -147,7 +147,7 @@ public QName getElementName() { } public ItemDefinition getDefinition() { - Item anyItem = getAnyItem(); + Item anyItem = getAnyItem(); if (anyItem != null) { return anyItem.getDefinition(); } @@ -167,29 +167,29 @@ public void recompute() throws SchemaException { if (itemNew == null) { throw new SchemaException("Cannot apply subitem delta to null new item"); } - for (ItemDelta subItemDelta: subItemDeltas) { - itemNew = (Item) subItemDelta.getItemNew((Item) itemNew); + for (ItemDelta subItemDelta: subItemDeltas) { + itemNew = (Item) subItemDelta.getItemNew((Item) itemNew); } } } - public ItemDeltaItem findIdi(ItemPath path) { + public ItemDeltaItem findIdi(ItemPath path) { if (path.isEmpty()) { - return (ItemDeltaItem) this; + return (ItemDeltaItem) this; } - Item subItemOld = null; + Item subItemOld = null; ItemPath subResidualPath = null; ItemPath newResolvePath = resolvePath.subPath(path); if (itemOld != null) { - PartiallyResolvedItem partialItemOld = itemOld.findPartial(path); + PartiallyResolvedItem partialItemOld = itemOld.findPartial(path); if (partialItemOld != null) { subItemOld = partialItemOld.getItem(); subResidualPath = partialItemOld.getResidualPath(); } } - Item subItemNew = null; + Item subItemNew = null; if (itemNew != null) { - PartiallyResolvedItem partialItemNew = itemNew.findPartial(path); + PartiallyResolvedItem partialItemNew = itemNew.findPartial(path); if (partialItemNew != null) { subItemNew = partialItemNew.getItem(); if (subResidualPath == null) { @@ -197,25 +197,25 @@ public ItemDeltaItem findIdi(ItemPath path) { } } } - ItemDelta subDelta= null; + ItemDelta subDelta= null; if (delta != null) { if (delta instanceof ContainerDelta) { - subDelta = (ItemDelta) ((ContainerDelta)delta).getSubDelta(path); + subDelta = (ItemDelta) ((ContainerDelta)delta).getSubDelta(path); } else { CompareResult compareComplex = delta.getPath().compareComplex(newResolvePath); if (compareComplex == CompareResult.EQUIVALENT || compareComplex == CompareResult.SUBPATH) { - subDelta = (ItemDelta) delta; + subDelta = (ItemDelta) delta; } } } - ItemDeltaItem subIdi = new ItemDeltaItem(subItemOld, subDelta, subItemNew); + ItemDeltaItem subIdi = new ItemDeltaItem(subItemOld, subDelta, subItemNew); subIdi.setResidualPath(subResidualPath); subIdi.resolvePath = newResolvePath; if (subItemDeltas != null) { - Item subAnyItem = subIdi.getAnyItem(); - Collection> subSubItemDeltas = new ArrayList<>(); - for (ItemDelta subItemDelta: subItemDeltas) { + Item subAnyItem = subIdi.getAnyItem(); + Collection> subSubItemDeltas = new ArrayList<>(); + for (ItemDelta subItemDelta: subItemDeltas) { CompareResult compareComplex = subItemDelta.getPath().compareComplex(subAnyItem.getPath()); if (compareComplex == CompareResult.EQUIVALENT || compareComplex == CompareResult.SUBPATH) { subSubItemDeltas.add(subItemDelta); @@ -224,9 +224,9 @@ public ItemDeltaItem findIdi(ItemPath path) { if (!subSubItemDeltas.isEmpty()) { // Niceness optimization if (subDelta == null && subSubItemDeltas.size() == 1) { - ItemDelta subSubItemDelta = subSubItemDeltas.iterator().next(); + ItemDelta subSubItemDelta = subSubItemDeltas.iterator().next(); if (subSubItemDelta.isApplicableTo(subAnyItem)) { - subDelta = (ItemDelta) subSubItemDelta; + subDelta = (ItemDelta) subSubItemDelta; subIdi.setDelta(subDelta); } else { subIdi.setSubItemDeltas(subSubItemDeltas); @@ -245,7 +245,7 @@ public PrismValueDeltaSetTriple toDeltaSetTriple() { } public boolean isContainer() { - Item item = getAnyItem(); + Item item = getAnyItem(); if (item != null) { return item instanceof PrismContainer; } @@ -256,7 +256,7 @@ public boolean isContainer() { } public boolean isProperty() { - Item item = getAnyItem(); + Item item = getAnyItem(); if (item != null) { return item instanceof PrismProperty; } @@ -287,12 +287,12 @@ public boolean isStructuredProperty() { } // Assumes that this IDI represents structured property - public ItemDeltaItem> resolveStructuredProperty(ItemPath resolvePath, PrismPropertyDefinition outputDefinition, ItemPath outputPath) { - ItemDeltaItem> thisIdi = (ItemDeltaItem>)this; + public ItemDeltaItem,PrismPropertyDefinition> resolveStructuredProperty(ItemPath resolvePath, PrismPropertyDefinition outputDefinition, ItemPath outputPath) { + ItemDeltaItem,PrismPropertyDefinition> thisIdi = (ItemDeltaItem,PrismPropertyDefinition>)this; PrismProperty outputPropertyNew = resolveStructuredPropertyItem((PrismProperty) thisIdi.getItemNew(), resolvePath, outputDefinition); PrismProperty outputPropertyOld = resolveStructuredPropertyItem((PrismProperty) thisIdi.getItemOld(), resolvePath, outputDefinition); PropertyDelta outputDelta = resolveStructuredPropertyDelta((PropertyDelta) thisIdi.getDelta(), resolvePath, outputDefinition, outputPath); - return new ItemDeltaItem>(outputPropertyOld, outputDelta, outputPropertyNew); + return new ItemDeltaItem,PrismPropertyDefinition>(outputPropertyOld, outputDelta, outputPropertyNew); } private PrismProperty resolveStructuredPropertyItem(PrismProperty sourceProperty, ItemPath resolvePath, PrismPropertyDefinition outputDefinition) { @@ -340,7 +340,7 @@ private Collection> resolveStructuredDeltaSet(Collecti return outputSet; } - public void applyDefinition(ItemDefinition def, boolean force) throws SchemaException { + public void applyDefinition(D def, boolean force) throws SchemaException { if (itemNew != null) { itemNew.applyDefinition(def, force); } @@ -352,13 +352,13 @@ public void applyDefinition(ItemDefinition def, boolean force) throws SchemaExce } } - public ItemDeltaItem clone() { - ItemDeltaItem clone = new ItemDeltaItem<>(); + public ItemDeltaItem clone() { + ItemDeltaItem clone = new ItemDeltaItem<>(); copyValues(clone); return clone; } - protected void copyValues(ItemDeltaItem clone) { + protected void copyValues(ItemDeltaItem clone) { if (this.itemNew != null) { clone.itemNew = this.itemNew.clone(); } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ObjectDeltaObject.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ObjectDeltaObject.java index d5b802c90b6..34ece4a3d72 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ObjectDeltaObject.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ObjectDeltaObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.evolveum.midpoint.prism.PartiallyResolvedItem; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismObjectDefinition; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.delta.ChangeType; import com.evolveum.midpoint.prism.delta.ItemDelta; @@ -41,32 +42,32 @@ * @author Radovan Semancik * */ -public class ObjectDeltaObject extends ItemDeltaItem> implements DebugDumpable { +public class ObjectDeltaObject extends ItemDeltaItem,PrismObjectDefinition> implements DebugDumpable { - private PrismObject oldObject; - private ObjectDelta delta; - private PrismObject newObject; + private PrismObject oldObject; + private ObjectDelta delta; + private PrismObject newObject; - public ObjectDeltaObject(PrismObject oldObject, ObjectDelta delta, PrismObject newObject) { + public ObjectDeltaObject(PrismObject oldObject, ObjectDelta delta, PrismObject newObject) { super(); this.oldObject = oldObject; this.delta = delta; this.newObject = newObject; } - public PrismObject getOldObject() { + public PrismObject getOldObject() { return oldObject; } - public ObjectDelta getObjectDelta() { + public ObjectDelta getObjectDelta() { return delta; } - public PrismObject getNewObject() { + public PrismObject getNewObject() { return newObject; } - public PrismObject getAnyObject() { + public PrismObject getAnyObject() { if (newObject != null) { return newObject; } @@ -74,12 +75,12 @@ public PrismObject getAnyObject() { } @Override - public ItemDelta> getDelta() { + public ItemDelta,PrismObjectDefinition> getDelta() { throw new UnsupportedOperationException("You probably wanted to call getObjectDelta()"); } @Override - public void setDelta(ItemDelta> delta) { + public void setDelta(ItemDelta,PrismObjectDefinition> delta) { throw new UnsupportedOperationException("You probably wanted to call setObjectDelta()"); } @@ -89,8 +90,8 @@ public boolean isContainer() { } @Override - public ItemDefinition getDefinition() { - PrismObject anyObject = getAnyObject(); + public PrismObjectDefinition getDefinition() { + PrismObject anyObject = getAnyObject(); if (anyObject != null) { return anyObject.getDefinition(); } @@ -101,19 +102,19 @@ public ItemDefinition getDefinition() { } @Override - public ItemDeltaItem findIdi(ItemPath path) { - Item subItemOld = null; + public ItemDeltaItem findIdi(ItemPath path) { + Item subItemOld = null; ItemPath subResidualPath = null; if (oldObject != null) { - PartiallyResolvedItem partialOld = oldObject.findPartial(path); + PartiallyResolvedItem partialOld = oldObject.findPartial(path); if (partialOld != null) { subItemOld = partialOld.getItem(); subResidualPath = partialOld.getResidualPath(); } } - Item subItemNew = null; + Item subItemNew = null; if (newObject != null) { - PartiallyResolvedItem partialNew = newObject.findPartial(path); + PartiallyResolvedItem partialNew = newObject.findPartial(path); if (partialNew != null) { subItemNew = partialNew.getItem(); if (subResidualPath == null) { @@ -121,14 +122,14 @@ public ItemDeltaItem findIdi(ItemPath path) { } } } - ItemDelta itemDelta = null; - Collection> subSubItemDeltas = null; + ItemDelta itemDelta = null; + Collection> subSubItemDeltas = null; if (delta != null) { if (delta.getChangeType() == ChangeType.ADD) { - PrismObject objectToAdd = delta.getObjectToAdd(); - PartiallyResolvedItem partialValue = objectToAdd.findPartial(path); + PrismObject objectToAdd = delta.getObjectToAdd(); + PartiallyResolvedItem partialValue = objectToAdd.findPartial(path); if (partialValue != null && partialValue.getItem() != null) { - Item item = partialValue.getItem(); + Item item = partialValue.getItem(); itemDelta = item.createDelta(); itemDelta.addValuesToAdd(item.getClonedValues()); } else { @@ -137,9 +138,9 @@ public ItemDeltaItem findIdi(ItemPath path) { } else if (delta.getChangeType() == ChangeType.DELETE) { if (subItemOld != null) { ItemPath subPath = subItemOld.getPath().remainder(path); - PartiallyResolvedItem partialValue = subItemOld.findPartial(subPath); + PartiallyResolvedItem partialValue = subItemOld.findPartial(subPath); if (partialValue != null && partialValue.getItem() != null) { - Item item = partialValue.getItem(); + Item item = partialValue.getItem(); itemDelta = item.createDelta(); itemDelta.addValuesToDelete(item.getClonedValues()); } else { @@ -147,13 +148,13 @@ public ItemDeltaItem findIdi(ItemPath path) { } } } else if (delta.getChangeType() == ChangeType.MODIFY) { - for (ItemDelta modification: delta.getModifications()) { + for (ItemDelta modification: delta.getModifications()) { CompareResult compareComplex = modification.getPath().compareComplex(path); if (compareComplex == CompareResult.EQUIVALENT) { if (itemDelta != null) { throw new IllegalStateException("Conflicting modification in delta "+delta+": "+itemDelta+" and "+modification); } - itemDelta = (ItemDelta) modification; + itemDelta = (ItemDelta) modification; } else if (compareComplex == CompareResult.SUPERPATH) { if (subSubItemDeltas == null) { subSubItemDeltas = new ArrayList<>(); @@ -163,12 +164,12 @@ public ItemDeltaItem findIdi(ItemPath path) { if (itemDelta != null) { throw new IllegalStateException("Conflicting modification in delta "+delta+": "+itemDelta+" and "+modification); } - itemDelta = (ItemDelta) modification.getSubDelta(path); + itemDelta = (ItemDelta) modification.getSubDelta(path); } } } } - ItemDeltaItem subIdi = new ItemDeltaItem(subItemOld, itemDelta, subItemNew); + ItemDeltaItem subIdi = new ItemDeltaItem(subItemOld, itemDelta, subItemNew); subIdi.setSubItemDeltas(subSubItemDeltas); subIdi.setResolvePath(path); subIdi.setResidualPath(subResidualPath); @@ -200,7 +201,7 @@ public static ObjectDeltaObject create(PrismObject return new ObjectDeltaObject(oldObject, delta, newObject); } - public static ObjectDeltaObject create(PrismObject oldObject, ItemDelta... itemDeltas) throws SchemaException { + public static ObjectDeltaObject create(PrismObject oldObject, ItemDelta... itemDeltas) throws SchemaException { ObjectDelta objectDelta = oldObject.createDelta(ChangeType.MODIFY); objectDelta.addModifications(itemDeltas); return create(oldObject, objectDelta); @@ -269,7 +270,7 @@ public String debugDump(int indent) { return sb.toString(); } - private void dumpObject(StringBuilder sb, PrismObject object, String label, int indent) { + private void dumpObject(StringBuilder sb, PrismObject object, String label, int indent) { sb.append("\n"); DebugUtil.indentDebugDump(sb, indent); sb.append(label).append(":"); diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/Source.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/Source.java index 5025562851d..0b628a38cc4 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/Source.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/Source.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,16 +31,16 @@ * @author semancik * */ -public class Source extends ItemDeltaItem implements DebugDumpable { +public class Source extends ItemDeltaItem implements DebugDumpable { private QName name; - public Source(Item itemOld, ItemDelta delta, Item itemNew, QName name) { + public Source(Item itemOld, ItemDelta delta, Item itemNew, QName name) { super(itemOld, delta, itemNew); this.name = name; } - public Source(ItemDeltaItem idi, QName name) { + public Source(ItemDeltaItem idi, QName name) { super(idi); this.name = name; } @@ -53,7 +53,7 @@ public void setName(QName name) { this.name = name; } - public Item getEmptyItem() { + public Item getEmptyItem() { ItemDefinition definition = getDefinition(); if (definition == null) { throw new IllegalStateException("No definition in source "+this); diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/SourceTriple.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/SourceTriple.java index 4f79d2a7f30..8f833d57834 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/SourceTriple.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/SourceTriple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import javax.xml.namespace.QName; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; import com.evolveum.midpoint.prism.path.ItemPath; @@ -27,25 +28,25 @@ * @author semancik * */ -public class SourceTriple extends PrismValueDeltaSetTriple { +public class SourceTriple extends PrismValueDeltaSetTriple { - private Source source; + private Source source; - public SourceTriple(Source source) { + public SourceTriple(Source source) { super(); this.source = source; } - public SourceTriple(Source source, Collection zeroSet, Collection plusSet, Collection minusSet) { + public SourceTriple(Source source, Collection zeroSet, Collection plusSet, Collection minusSet) { super(zeroSet, plusSet, minusSet); this.source = source; } - public Source getSource() { + public Source getSource() { return source; } - public void setSource(Source source) { + public void setSource(Source source) { this.source = source; } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AbstractSearchExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AbstractSearchExpressionEvaluator.java index 7b5eb3760ed..b670f5b18c7 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AbstractSearchExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AbstractSearchExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,19 +80,19 @@ /** * @author Radovan Semancik */ -public abstract class AbstractSearchExpressionEvaluator - extends AbstractValueTransformationExpressionEvaluator { +public abstract class AbstractSearchExpressionEvaluator + extends AbstractValueTransformationExpressionEvaluator { private static final Trace LOGGER = TraceManager.getTrace(AbstractSearchExpressionEvaluator.class); private PrismContext prismContext; - private ItemDefinition outputDefinition; + private D outputDefinition; private Protector protector; private ObjectResolver objectResolver; private ModelService modelService; protected AbstractSearchExpressionEvaluator(SearchObjectExpressionEvaluatorType expressionEvaluatorType, - ItemDefinition outputDefinition, Protector protector, ObjectResolver objectResolver, + D outputDefinition, Protector protector, ObjectResolver objectResolver, ModelService modelService, PrismContext prismContext, SecurityEnforcer securityEnforcer) { super(expressionEvaluatorType, securityEnforcer); this.outputDefinition = outputDefinition; @@ -265,7 +265,7 @@ private String createOnDemand(Class targetTypeClass, E } else { for (PopulateItemType populateItem: populateObject.getPopulateItem()) { - ItemDelta itemDelta = evaluatePopulateExpression(populateItem, variables, params, + ItemDelta itemDelta = evaluatePopulateExpression(populateItem, variables, params, objectDefinition, contextDescription, task, result); if (itemDelta != null) { itemDelta.applyTo(newObject); @@ -291,7 +291,7 @@ private String createOnDemand(Class targetTypeClass, E return addDelta.getOid(); } - private ItemDelta evaluatePopulateExpression(PopulateItemType populateItem, + private ItemDelta evaluatePopulateExpression(PopulateItemType populateItem, ExpressionVariables variables, ExpressionEvaluationContext params, PrismObjectDefinition objectDefinition, String contextDescription, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException { ExpressionType expressionType = populateItem.getExpression(); @@ -312,7 +312,7 @@ private ItemDelta evaluatePopula throw new SchemaException("No path in target definition in "+contextDescription); } ItemPath targetPath = itemPathType.getItemPath(); - ItemDefinition propOutputDefinition = ExpressionUtil.resolveDefinitionPath(targetPath, variables, + ID propOutputDefinition = ExpressionUtil.resolveDefinitionPath(targetPath, variables, objectDefinition, "target definition in "+contextDescription); if (propOutputDefinition == null) { throw new SchemaException("No target item that would conform to the path "+targetPath+" in "+contextDescription); @@ -320,7 +320,7 @@ private ItemDelta evaluatePopula String expressionDesc = "expression in assignment expression in "+contextDescription; ExpressionFactory expressionFactory = params.getExpressionFactory(); - Expression expression = expressionFactory.makeExpression(expressionType, propOutputDefinition, + Expression expression = expressionFactory.makeExpression(expressionType, propOutputDefinition, expressionDesc, result); ExpressionEvaluationContext expressionParams = new ExpressionEvaluationContext(null, variables, expressionDesc, task, result); @@ -329,9 +329,9 @@ private ItemDelta evaluatePopula expressionParams.setDefaultTargetContext(params.getDefaultTargetContext()); expressionParams.setSkipEvaluationMinus(true); expressionParams.setSkipEvaluationPlus(false); - PrismValueDeltaSetTriple outputTriple = expression.evaluate(expressionParams); + PrismValueDeltaSetTriple outputTriple = expression.evaluate(expressionParams); LOGGER.trace("output triple: {}", outputTriple.debugDump()); - Collection pvalues = outputTriple.getNonNegativeValues(); + Collection pvalues = outputTriple.getNonNegativeValues(); // Maybe not really clean but it works. TODO: refactor later NameItemPathSegment first = (NameItemPathSegment)targetPath.first(); @@ -339,7 +339,7 @@ private ItemDelta evaluatePopula targetPath = targetPath.rest(); } - ItemDelta itemDelta = propOutputDefinition.createEmptyDelta(targetPath); + ItemDelta itemDelta = propOutputDefinition.createEmptyDelta(targetPath); itemDelta.addValuesToAdd(PrismValue.cloneCollection(pvalues)); LOGGER.trace("Item delta:\n{}", itemDelta.debugDump()); diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AbstractValueTransformationExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AbstractValueTransformationExpressionEvaluator.java index fbeee2ae67d..017a078a0f3 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AbstractValueTransformationExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AbstractValueTransformationExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import com.evolveum.midpoint.model.common.expression.Source; import com.evolveum.midpoint.model.common.expression.SourceTriple; import com.evolveum.midpoint.prism.Item; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.DeltaSetTriple; @@ -67,8 +68,8 @@ /** * @author Radovan Semancik */ -public abstract class AbstractValueTransformationExpressionEvaluator - implements ExpressionEvaluator { +public abstract class AbstractValueTransformationExpressionEvaluator + implements ExpressionEvaluator { private SecurityEnforcer securityEnforcer; @@ -108,7 +109,7 @@ public PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext context) outputTriple = evaluateAbsoluteExpression(null, context.getVariables(), context, context.getContextDescription(), context.getTask(), context.getResult()); } else { - List> sourceTriples = processSources(context.getSources(), + List> sourceTriples = processSources(context.getSources(), isIncludeNullInputs(), context); outputTriple = evaluateRelativeExpression(sourceTriples, context.getVariables(), context.isSkipEvaluationMinus(), context.isSkipEvaluationPlus(), isIncludeNullInputs(), context, context.getContextDescription(), context.getTask(), context.getResult()); @@ -133,16 +134,16 @@ protected boolean isRelative() { return true; } - private List> processSources(Collection> sources, Boolean includeNulls, + private List> processSources(Collection> sources, Boolean includeNulls, ExpressionEvaluationContext params) { - List> sourceTriples = - new ArrayList>(sources == null ? 0 : sources.size()); + List> sourceTriples = + new ArrayList>(sources == null ? 0 : sources.size()); if (sources == null) { return sourceTriples; } - for (Source source: sources) { - SourceTriple sourceTriple = new SourceTriple((Source) source); - ItemDelta delta = source.getDelta(); + for (Source source: sources) { + SourceTriple sourceTriple = new SourceTriple<>(source); + ItemDelta delta = source.getDelta(); if (delta != null) { sourceTriple.merge((DeltaSetTriple) delta.toDeltaSetTriple((Item) source.getItemOld())); } else { @@ -155,8 +156,8 @@ private List> processSources(Collection itemOld = source.getItemOld(); - Item itemNew = source.getItemNew(); + Item itemOld = source.getItemOld(); + Item itemNew = source.getItemNew(); if (itemOld == null || itemOld.isEmpty()) { if (!(itemNew == null || itemNew.isEmpty())) { // change empty -> non-empty: we are removing "null" value @@ -183,7 +184,7 @@ private List> processSources(Collection evaluateAbsoluteExpression(Collection> sources, + private PrismValueDeltaSetTriple evaluateAbsoluteExpression(Collection> sources, ExpressionVariables variables, ExpressionEvaluationContext params, String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { @@ -212,11 +213,11 @@ private PrismValueDeltaSetTriple evaluateAbsoluteExpression(Collection> sources) { + private boolean hasDeltas(Collection> sources) { if (sources == null) { return false; } - for (Source source: sources) { + for (Source source: sources) { if (source.getDelta() != null && !source.getDelta().isEmpty()) { return true; } @@ -231,8 +232,8 @@ private boolean hasDeltas(ExpressionVariables variables) { if (((ObjectDeltaObject)value).getObjectDelta() != null && !((ObjectDeltaObject)value).getObjectDelta().isEmpty()) { return true; } - } else if (value instanceof ItemDeltaItem) { - if (((ItemDeltaItem)value).getDelta() != null && !((ItemDeltaItem)value).getDelta().isEmpty()) { + } else if (value instanceof ItemDeltaItem) { + if (((ItemDeltaItem)value).getDelta() != null && !((ItemDeltaItem)value).getDelta().isEmpty()) { return true; } } @@ -240,7 +241,7 @@ private boolean hasDeltas(ExpressionVariables variables) { return false; } - private Collection evaluateScriptExpression(Collection> sources, + private Collection evaluateScriptExpression(Collection> sources, ExpressionVariables variables, String contextDescription, boolean useNew, ExpressionEvaluationContext params, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { @@ -253,7 +254,7 @@ private Collection evaluateScriptExpression(Collection source: sources) { + for (Source source: sources) { LOGGER.trace("source: {}", source); QName name = source.getName(); if (name == null) { @@ -309,7 +310,7 @@ protected abstract List transformSingleValue(ExpressionVariables variables, P boolean useNew, ExpressionEvaluationContext params, String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException; - private Object getRealContent(Item item, ItemPath residualPath) { + private Object getRealContent(Item item, ItemPath residualPath) { if (residualPath == null || residualPath.isEmpty()) { return item; } @@ -329,14 +330,14 @@ private Object getRealContent(PrismValue pval, ItemPath residualPath) { return pval.find(residualPath); } - private PrismValueDeltaSetTriple evaluateRelativeExpression(final List> sourceTriples, + private PrismValueDeltaSetTriple evaluateRelativeExpression(final List> sourceTriples, final ExpressionVariables variables, final boolean skipEvaluationMinus, final boolean skipEvaluationPlus, final Boolean includeNulls, final ExpressionEvaluationContext params, final String contextDescription, final Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { List> valueCollections = new ArrayList>(sourceTriples.size()); - for (SourceTriple sourceTriple: sourceTriples) { + for (SourceTriple sourceTriple: sourceTriples) { Collection values = sourceTriple.union(); if (values.isEmpty()) { // No values for this source. Add null instead. It will make sure that the expression will @@ -356,12 +357,12 @@ public void process(Collection pvalues) { return; } Map sourceVariables = new HashMap(); - Iterator> sourceTriplesIterator = sourceTriples.iterator(); + Iterator> sourceTriplesIterator = (Iterator)sourceTriples.iterator(); boolean hasMinus = false; boolean hasZero = false; boolean hasPlus = false; for (PrismValue pval: pvalues) { - SourceTriple sourceTriple = (SourceTriple) sourceTriplesIterator.next(); + SourceTriple sourceTriple = sourceTriplesIterator.next(); QName name = sourceTriple.getName(); sourceVariables.put(name, getRealContent(pval, sourceTriple.getResidualPath())); // Note: a value may be both in plus and minus sets, e.g. in case that the value is replaced diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AsIsExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AsIsExpressionEvaluator.java index 50af24b4508..a5059916aec 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AsIsExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AsIsExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,15 +51,15 @@ /** * @author Radovan Semancik */ -public class AsIsExpressionEvaluator implements ExpressionEvaluator { +public class AsIsExpressionEvaluator implements ExpressionEvaluator { private PrismContext prismContext; - ItemDefinition outputDefinition; + D outputDefinition; private AsIsExpressionEvaluatorType asIsExpressionEvaluatorType; private Protector protector; public AsIsExpressionEvaluator(AsIsExpressionEvaluatorType asIsExpressionEvaluatorType, - ItemDefinition outputDefinition, Protector protector, PrismContext prismContext) { + D outputDefinition, Protector protector, PrismContext prismContext) { this.asIsExpressionEvaluatorType = asIsExpressionEvaluatorType; this.outputDefinition = outputDefinition; this.prismContext = prismContext; @@ -70,12 +70,12 @@ public AsIsExpressionEvaluator(AsIsExpressionEvaluatorType asIsExpressionEvaluat public PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext params) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { - Source source; + Source source; if (params.getSources().isEmpty()) { throw new ExpressionEvaluationException("asIs evaluator cannot work without a source in "+params.getContextDescription()); } if (params.getSources().size() > 1) { - Source defaultSource = (Source) params.getDefaultSource(); + Source defaultSource = (Source) params.getDefaultSource(); if (defaultSource != null) { source = defaultSource; } else { @@ -83,7 +83,7 @@ public PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext params) +" sources specified) without specification of a default source, in "+params.getContextDescription()); } } else { - source = (Source) params.getSources().iterator().next(); + source = (Source) params.getSources().iterator().next(); } PrismValueDeltaSetTriple sourceTriple = ItemDelta.toDeltaSetTriple(source.getItemOld(), source.getDelta()); diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AsIsExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AsIsExpressionEvaluatorFactory.java index 912bf5ec559..2f8edf6cec6 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AsIsExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AsIsExpressionEvaluatorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,8 +58,8 @@ public QName getElementName() { * @see com.evolveum.midpoint.common.expression.ExpressionEvaluatorFactory#createEvaluator(javax.xml.bind.JAXBElement) */ @Override - public AsIsExpressionEvaluator createEvaluator(Collection> evaluatorElements, - ItemDefinition outputDefinition, String contextDescription, OperationResult result) throws SchemaException { + public AsIsExpressionEvaluator createEvaluator(Collection> evaluatorElements, + D outputDefinition, String contextDescription, OperationResult result) throws SchemaException { Validate.notNull(outputDefinition, "output definition must be specified for asIs expression evaluator"); @@ -78,7 +78,7 @@ public AsIsExpressionEvaluator createEvaluator(Collect if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof AsIsExpressionEvaluatorType)) { throw new SchemaException("AsIs value constructor cannot handle elements of type " + evaluatorTypeObject.getClass().getName()+" in "+contextDescription); } - return new AsIsExpressionEvaluator((AsIsExpressionEvaluatorType)evaluatorTypeObject, + return new AsIsExpressionEvaluator((AsIsExpressionEvaluatorType)evaluatorTypeObject, outputDefinition, protector, prismContext); } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssignmentTargetSearchExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssignmentTargetSearchExpressionEvaluator.java index 89d82862a9c..248cc91d55e 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssignmentTargetSearchExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssignmentTargetSearchExpressionEvaluator.java @@ -21,6 +21,7 @@ import com.evolveum.midpoint.model.api.ModelService; import com.evolveum.midpoint.model.common.expression.ExpressionEvaluationContext; import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.crypto.Protector; @@ -40,12 +41,13 @@ * @author Radovan Semancik */ public class AssignmentTargetSearchExpressionEvaluator - extends AbstractSearchExpressionEvaluator> { + extends AbstractSearchExpressionEvaluator, + PrismContainerDefinition> { private static final Trace LOGGER = TraceManager.getTrace(AssignmentTargetSearchExpressionEvaluator.class); public AssignmentTargetSearchExpressionEvaluator(SearchObjectRefExpressionEvaluatorType expressionEvaluatorType, - ItemDefinition outputDefinition, Protector protector, ObjectResolver objectResolver, + PrismContainerDefinition outputDefinition, Protector protector, ObjectResolver objectResolver, ModelService modelService, PrismContext prismContext, SecurityEnforcer securityEnforcer) { super(expressionEvaluatorType, outputDefinition, protector, objectResolver, modelService, prismContext, securityEnforcer); } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssignmentTargetSearchExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssignmentTargetSearchExpressionEvaluatorFactory.java index df9c4518929..e617267a242 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssignmentTargetSearchExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssignmentTargetSearchExpressionEvaluatorFactory.java @@ -25,6 +25,7 @@ import com.evolveum.midpoint.model.common.expression.ExpressionEvaluatorFactory; import com.evolveum.midpoint.model.common.expression.ExpressionFactory; import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.crypto.Protector; @@ -32,6 +33,7 @@ import com.evolveum.midpoint.schema.util.ObjectResolver; import com.evolveum.midpoint.security.api.SecurityEnforcer; import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory; import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchObjectRefExpressionEvaluatorType; @@ -70,8 +72,8 @@ public QName getElementName() { * @see com.evolveum.midpoint.common.expression.ExpressionEvaluatorFactory#createEvaluator(javax.xml.bind.JAXBElement) */ @Override - public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, - ItemDefinition outputDefinition, String contextDescription, OperationResult result) throws SchemaException { + public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, + D outputDefinition, String contextDescription, OperationResult result) throws SchemaException { Validate.notNull(outputDefinition, "output definition must be specified for assignmentTargetSearch expression evaluator"); @@ -91,8 +93,8 @@ public ExpressionEvaluator createEvaluator(Collection< throw new SchemaException("assignment expression evaluator cannot handle elements of type " + evaluatorTypeObject.getClass().getName()+" in "+contextDescription); } AssignmentTargetSearchExpressionEvaluator expressionEvaluator = new AssignmentTargetSearchExpressionEvaluator((SearchObjectRefExpressionEvaluatorType)evaluatorTypeObject, - outputDefinition, protector, objectResolver, modelService, prismContext, securityEnforcer); - return (ExpressionEvaluator) expressionEvaluator; + (PrismContainerDefinition) outputDefinition, protector, objectResolver, modelService, prismContext, securityEnforcer); + return (ExpressionEvaluator) expressionEvaluator; } } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationFromLinkExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationFromLinkExpressionEvaluator.java index ce347345dd5..f4343c84f6a 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationFromLinkExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationFromLinkExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Evolveum + * Copyright (c) 2014-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,8 @@ * */ public class AssociationFromLinkExpressionEvaluator - implements ExpressionEvaluator> { + implements ExpressionEvaluator, + PrismContainerDefinition> { private static final Trace LOGGER = TraceManager.getTrace(AssociationFromLinkExpressionEvaluator.class); diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationFromLinkExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationFromLinkExpressionEvaluatorFactory.java index b8b21f99f08..8452e5de1d4 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationFromLinkExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationFromLinkExpressionEvaluatorFactory.java @@ -68,8 +68,8 @@ public QName getElementName() { * @see com.evolveum.midpoint.common.expression.ExpressionEvaluatorFactory#createEvaluator(javax.xml.bind.JAXBElement) */ @Override - public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, - ItemDefinition outputDefinition, String contextDescription, OperationResult result) throws SchemaException { + public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, + D outputDefinition, String contextDescription, OperationResult result) throws SchemaException { Validate.notNull(outputDefinition, "output definition must be specified for associationFromLink expression evaluator"); @@ -91,7 +91,7 @@ public ExpressionEvaluator createEvaluator(Collection< AssociationFromLinkExpressionEvaluator evaluator = new AssociationFromLinkExpressionEvaluator( (ShadowDiscriminatorExpressionEvaluatorType)evaluatorTypeObject, (PrismContainerDefinition) outputDefinition, objectResolver, prismContext); - return (ExpressionEvaluator) evaluator; + return (ExpressionEvaluator) evaluator; } } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationTargetSearchExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationTargetSearchExpressionEvaluator.java index ac4a9508899..df6e4baa231 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationTargetSearchExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationTargetSearchExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.evolveum.midpoint.model.api.ModelService; import com.evolveum.midpoint.model.common.expression.ExpressionEvaluationContext; import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.crypto.Protector; @@ -48,12 +49,13 @@ * @author Radovan Semancik */ public class AssociationTargetSearchExpressionEvaluator - extends AbstractSearchExpressionEvaluator> { + extends AbstractSearchExpressionEvaluator, + PrismContainerDefinition> { private static final Trace LOGGER = TraceManager.getTrace(AssociationTargetSearchExpressionEvaluator.class); public AssociationTargetSearchExpressionEvaluator(SearchObjectExpressionEvaluatorType expressionEvaluatorType, - ItemDefinition outputDefinition, Protector protector, ObjectResolver objectResolver, + PrismContainerDefinition outputDefinition, Protector protector, ObjectResolver objectResolver, ModelService modelService, PrismContext prismContext, SecurityEnforcer securityEnforcer) { super(expressionEvaluatorType, outputDefinition, protector, objectResolver, modelService, prismContext, securityEnforcer); } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationTargetSearchExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationTargetSearchExpressionEvaluatorFactory.java index e9c7ca96d01..3353c337697 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationTargetSearchExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/AssociationTargetSearchExpressionEvaluatorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Evolveum + * Copyright (c) 2014-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.evolveum.midpoint.model.common.expression.ExpressionEvaluator; import com.evolveum.midpoint.model.common.expression.ExpressionEvaluatorFactory; import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.crypto.Protector; @@ -33,6 +34,8 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory; import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchObjectExpressionEvaluatorType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; + import org.apache.commons.lang.Validate; /** @@ -68,8 +71,8 @@ public QName getElementName() { * @see com.evolveum.midpoint.common.expression.ExpressionEvaluatorFactory#createEvaluator(javax.xml.bind.JAXBElement) */ @Override - public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, - ItemDefinition outputDefinition, String contextDescription, OperationResult result) throws SchemaException { + public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, + D outputDefinition, String contextDescription, OperationResult result) throws SchemaException { Validate.notNull(outputDefinition, "output definition must be specified for associationTargetSearch expression evaluator"); @@ -89,8 +92,8 @@ public ExpressionEvaluator createEvaluator(Collection< throw new SchemaException("Association expression evaluator cannot handle elements of type " + evaluatorTypeObject.getClass().getName()+" in "+contextDescription); } AssociationTargetSearchExpressionEvaluator evaluator = new AssociationTargetSearchExpressionEvaluator((SearchObjectExpressionEvaluatorType)evaluatorTypeObject, - outputDefinition, protector, objectResolver, modelService, prismContext, securityEnforcer); - return (ExpressionEvaluator) evaluator; + (PrismContainerDefinition) outputDefinition, protector, objectResolver, modelService, prismContext, securityEnforcer); + return (ExpressionEvaluator) evaluator; } } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/GenerateExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/GenerateExpressionEvaluator.java index b4ffdcb9760..5f09b8c8e4f 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/GenerateExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/GenerateExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,17 +64,17 @@ * @author semancik * */ -public class GenerateExpressionEvaluator implements ExpressionEvaluator { +public class GenerateExpressionEvaluator implements ExpressionEvaluator { public static final int DEFAULT_LENGTH = 8; private GenerateExpressionEvaluatorType generateEvaluatorType; - private ItemDefinition outputDefinition; + private D outputDefinition; private Protector protector; private PrismContext prismContext; private StringPolicyType elementStringPolicy; - GenerateExpressionEvaluator(GenerateExpressionEvaluatorType generateEvaluatorType, ItemDefinition outputDefinition, + GenerateExpressionEvaluator(GenerateExpressionEvaluatorType generateEvaluatorType, D outputDefinition, Protector protector, StringPolicyType elementStringPolicy, PrismContext prismContext) { this.generateEvaluatorType = generateEvaluatorType; this.outputDefinition = outputDefinition; @@ -172,7 +172,7 @@ public PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext params) throw new IllegalArgumentException("Generate value constructor cannot generate values for properties of type " + outputType); } - Item output = outputDefinition.instantiate(); + Item output = outputDefinition.instantiate(); if (output instanceof PrismProperty) { PrismPropertyValue pValue = new PrismPropertyValue(value); ((PrismProperty)output).add(pValue); diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/GenerateExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/GenerateExpressionEvaluatorFactory.java index 4562d010d64..8038100ce49 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/GenerateExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/GenerateExpressionEvaluatorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,8 +74,8 @@ public QName getElementName() { * @see com.evolveum.midpoint.common.expression.ExpressionEvaluatorFactory#createEvaluator(javax.xml.bind.JAXBElement, com.evolveum.midpoint.prism.PrismContext) */ @Override - public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, - ItemDefinition outputDefinition, String contextDescription, OperationResult result) + public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, + D outputDefinition, String contextDescription, OperationResult result) throws SchemaException, ObjectNotFoundException { Validate.notNull(outputDefinition, "output definition must be specified for 'generate' expression evaluator"); @@ -102,7 +102,7 @@ public ExpressionEvaluator createEvaluator(Collection< elementStringPolicy = valuePolicyType.getStringPolicy(); } - return new GenerateExpressionEvaluator(generateEvaluatorType, outputDefinition, protector, elementStringPolicy, prismContext); + return new GenerateExpressionEvaluator(generateEvaluatorType, outputDefinition, protector, elementStringPolicy, prismContext); } } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/LiteralExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/LiteralExpressionEvaluator.java index b655be6aa31..bb5da8d50f9 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/LiteralExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/LiteralExpressionEvaluator.java @@ -49,7 +49,7 @@ * @author Radovan Semancik * */ -public class LiteralExpressionEvaluator implements ExpressionEvaluator { +public class LiteralExpressionEvaluator implements ExpressionEvaluator { PrismValueDeltaSetTriple outputTriple; diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/LiteralExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/LiteralExpressionEvaluatorFactory.java index ff711716ad0..22b58edfc4b 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/LiteralExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/LiteralExpressionEvaluatorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,16 +66,16 @@ public QName getElementName() { * @see com.evolveum.midpoint.common.expression.ExpressionEvaluatorFactory#createEvaluator(javax.xml.bind.JAXBElement, com.evolveum.midpoint.prism.PrismContext) */ @Override - public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, ItemDefinition outputDefinition, + public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, D outputDefinition, String contextDescription, OperationResult result) throws SchemaException { Validate.notNull(outputDefinition, "output definition must be specified for literal expression evaluator"); - Item output = StaticExpressionUtil.parseValueElements(evaluatorElements, outputDefinition, contextDescription, prismContext); + Item output = StaticExpressionUtil.parseValueElements(evaluatorElements, outputDefinition, contextDescription, prismContext); PrismValueDeltaSetTriple deltaSetTriple = ItemDelta.toDeltaSetTriple(output, null); - return new LiteralExpressionEvaluator(deltaSetTriple); + return new LiteralExpressionEvaluator(deltaSetTriple); } } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/PathExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/PathExpressionEvaluator.java index d9f0b37bee2..bad7193a320 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/PathExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/PathExpressionEvaluator.java @@ -65,16 +65,16 @@ /** * @author Radovan Semancik */ -public class PathExpressionEvaluator implements ExpressionEvaluator { +public class PathExpressionEvaluator implements ExpressionEvaluator { private ItemPath path; private ObjectResolver objectResolver; private PrismContext prismContext; - private ItemDefinition outputDefinition; + private D outputDefinition; private Protector protector; public PathExpressionEvaluator(ItemPath path, ObjectResolver objectResolver, - ItemDefinition outputDefinition, Protector protector, PrismContext prismContext) { + D outputDefinition, Protector protector, PrismContext prismContext) { this.path = path; this.objectResolver = objectResolver; this.outputDefinition = outputDefinition; @@ -89,10 +89,10 @@ public PathExpressionEvaluator(ItemPath path, ObjectResolver objectResolver, public PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext params) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { - ItemDeltaItem resolveContext = null; + ItemDeltaItem resolveContext = null; if (params.getSources() != null && params.getSources().size() == 1) { - Source source = params.getSources().iterator().next(); + Source source = params.getSources().iterator().next(); if (path.isEmpty()) { PrismValueDeltaSetTriple outputTriple = (PrismValueDeltaSetTriple) source.toDeltaSetTriple(); return outputTriple.clone(); @@ -119,7 +119,7 @@ public PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext params) if (variableValue == null) { return null; } - if (variableValue instanceof Item || variableValue instanceof ItemDeltaItem) { + if (variableValue instanceof Item || variableValue instanceof ItemDeltaItem) { resolveContext = ExpressionUtil.toItemDeltaItem(variableValue, objectResolver, "path expression in "+params.getContextDescription(), params.getResult()); } else if (variableValue instanceof PrismPropertyValue){ @@ -157,8 +157,8 @@ public PrismValueDeltaSetTriple evaluate(ExpressionEvaluationContext params) } } - PrismValueDeltaSetTriple outputTriple = ItemDelta.toDeltaSetTriple((Item)resolveContext.getItemOld(), - (ItemDelta)resolveContext.getDelta()); + PrismValueDeltaSetTriple outputTriple = ItemDelta.toDeltaSetTriple((Item)resolveContext.getItemOld(), + (ItemDelta)resolveContext.getDelta()); if (outputTriple == null) { return null; diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/PathExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/PathExpressionEvaluatorFactory.java index 8858db3c56f..1ee70bcdfd6 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/PathExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/evaluator/PathExpressionEvaluatorFactory.java @@ -66,8 +66,8 @@ public QName getElementName() { * @see com.evolveum.midpoint.common.expression.ExpressionEvaluatorFactory#createEvaluator(javax.xml.bind.JAXBElement, com.evolveum.midpoint.prism.ItemDefinition, com.evolveum.midpoint.prism.PrismContext) */ @Override - public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, - ItemDefinition outputDefinition, String contextDescription, OperationResult result) throws SchemaException { + public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, + D outputDefinition, String contextDescription, OperationResult result) throws SchemaException { Validate.notNull(outputDefinition, "output definition must be specified for path expression evaluator"); @@ -89,7 +89,7 @@ public ExpressionEvaluator createEvaluator(Collection< // XPathHolder xpath = new XPathHolder((Element)evaluatorElementObject); ItemPath path = ((ItemPathType)evaluatorElementObject).getItemPath(); - return new PathExpressionEvaluator(path, objectResolver, outputDefinition, protector, prismContext); + return new PathExpressionEvaluator<>(path, objectResolver, outputDefinition, protector, prismContext); } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionEvaluator.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionEvaluator.java index 14730e39b31..1076b3e3581 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionEvaluator.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.evolveum.midpoint.model.common.expression.ExpressionEvaluationContext; import com.evolveum.midpoint.model.common.expression.ExpressionVariables; import com.evolveum.midpoint.model.common.expression.evaluator.AbstractValueTransformationExpressionEvaluator; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.delta.PlusMinusZero; import com.evolveum.midpoint.schema.result.OperationResult; @@ -36,8 +37,8 @@ /** * @author Radovan Semancik */ -public class ScriptExpressionEvaluator - extends AbstractValueTransformationExpressionEvaluator { +public class ScriptExpressionEvaluator + extends AbstractValueTransformationExpressionEvaluator { private ScriptExpression scriptExpression; diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionEvaluatorFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionEvaluatorFactory.java index 1002fa2cb07..bf1df2ec547 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionEvaluatorFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionEvaluatorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,8 +53,8 @@ public QName getElementName() { * @see com.evolveum.midpoint.common.expression.ExpressionEvaluatorFactory#createEvaluator(javax.xml.bind.JAXBElement, com.evolveum.midpoint.prism.ItemDefinition) */ @Override - public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, - ItemDefinition outputDefinition, String contextDescription, OperationResult result) throws SchemaException { + public ExpressionEvaluator createEvaluator(Collection> evaluatorElements, + D outputDefinition, String contextDescription, OperationResult result) throws SchemaException { if (evaluatorElements.size() > 1) { throw new SchemaException("More than one evaluator specified in "+contextDescription); diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/Mapping.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/Mapping.java index da3d8cf9aed..6823dcaa41b 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/Mapping.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/Mapping.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,7 +105,7 @@ * @author Radovan Semancik * */ -public class Mapping implements DebugDumpable { +public class Mapping implements DebugDumpable { private static final QName CONDITION_OUTPUT_NAME = new QName(SchemaConstants.NS_C, "condition"); @@ -116,15 +116,15 @@ public class Mapping implements DebugDumpable { private MappingType mappingType; private ObjectResolver objectResolver = null; private SecurityEnforcer securityEnforcer; // in order to get c:actor variable - private Source defaultSource = null; - private ItemDefinition defaultTargetDefinition = null; + private Source defaultSource = null; + private D defaultTargetDefinition = null; private ItemPath defaultTargetPath = null; private ObjectDeltaObject sourceContext = null; private PrismObjectDefinition targetContext = null; private PrismValueDeltaSetTriple outputTriple = null; - private ItemDefinition outputDefinition; + private D outputDefinition; private ItemPath outputPath; - private Collection> sources = new ArrayList>(); + private Collection> sources = new ArrayList>(); private boolean conditionMaskOld = true; private boolean conditionMaskNew = true; private PrismValueDeltaSetTriple> conditionOutputTriple; @@ -146,7 +146,7 @@ public class Mapping implements DebugDumpable { // This is single-use only. Once evaluated it is not used any more // it is remembered only for tracing purposes. - private Expression expression; + private Expression expression; private static final Trace LOGGER = TraceManager.getTrace(Mapping.class); @@ -189,23 +189,23 @@ public void setOriginObject(ObjectType originObject) { this.originObject = originObject; } - public void addSource(Source source) { + public void addSource(Source source) { sources.add(source); } - public Source getDefaultSource() { + public Source getDefaultSource() { return defaultSource; } - public void setDefaultSource(Source defaultSource) { + public void setDefaultSource(Source defaultSource) { this.defaultSource = defaultSource; } - public ItemDefinition getDefaultTargetDefinition() { + public D getDefaultTargetDefinition() { return defaultTargetDefinition; } - public void setDefaultTargetDefinition(ItemDefinition defaultTargetDefinition) { + public void setDefaultTargetDefinition(D defaultTargetDefinition) { this.defaultTargetDefinition = defaultTargetDefinition; } @@ -640,7 +640,7 @@ private void appendTraceHeader(StringBuilder sb) { sb.append(" in "); sb.append(contextDescription); sb.append("]---------------------------"); - for (Source source: sources) { + for (Source source: sources) { sb.append("\nSource: "); sb.append(source.shortDebugDump()); } @@ -769,9 +769,9 @@ private XMLGregorianCalendar parseTimeSource(MappingSourceDeclarationType source return null; } PrismProperty timeProperty; - if (sourceObject instanceof ItemDeltaItem) { - timeProperty = (PrismProperty) ((ItemDeltaItem)sourceObject).getItemNew(); - } else if (sourceObject instanceof Item) { + if (sourceObject instanceof ItemDeltaItem) { + timeProperty = (PrismProperty) ((ItemDeltaItem)sourceObject).getItemNew(); + } else if (sourceObject instanceof Item) { timeProperty = (PrismProperty) sourceObject; } else { throw new IllegalStateException("Unknown resolve result "+sourceObject); @@ -782,7 +782,7 @@ private XMLGregorianCalendar parseTimeSource(MappingSourceDeclarationType source return timeProperty.getRealValue(); } - private Collection> parseSources(OperationResult result) throws SchemaException, ObjectNotFoundException { + private Collection> parseSources(OperationResult result) throws SchemaException, ObjectNotFoundException { List sourceTypes = mappingType.getSource(); if (defaultSource != null) { defaultSource.recompute(); @@ -791,13 +791,13 @@ private Collection> parseSources(OperationResult result) throws Schema } if (sourceTypes != null) { for (MappingSourceDeclarationType sourceType: sourceTypes) { - Source source = parseSource(sourceType, result); + Source source = parseSource(sourceType, result); source.recompute(); // Override existing sources (e.g. default source) - Iterator> iterator = sources.iterator(); + Iterator> iterator = sources.iterator(); while (iterator.hasNext()) { - Source next = iterator.next(); + Source next = iterator.next(); if (next.getName().equals(source.getName())) { iterator.remove(); } @@ -809,7 +809,7 @@ private Collection> parseSources(OperationResult result) throws Schema return sources; } - private Source parseSource(MappingSourceDeclarationType sourceType, OperationResult result) throws SchemaException, ObjectNotFoundException { + private Source parseSource(MappingSourceDeclarationType sourceType, OperationResult result) throws SchemaException, ObjectNotFoundException { ItemPathType itemPathType = sourceType.getPath(); if (itemPathType == null) { throw new SchemaException("No path in source definition in "+getMappingContextDescription()); @@ -824,27 +824,27 @@ private Source parseSource(MappingSourceDeclarationTyp } ItemPath resolvePath = path; Object sourceObject = ExpressionUtil.resolvePath(path, variables, sourceContext, objectResolver, "source definition in "+getMappingContextDescription(), result); - Item itemOld = null; - ItemDelta delta = null; - Item itemNew = null; + Item itemOld = null; + ItemDelta delta = null; + Item itemNew = null; ItemPath residualPath = null; - Collection> subItemDeltas = null; + Collection> subItemDeltas = null; if (sourceObject != null) { - if (sourceObject instanceof ItemDeltaItem) { - itemOld = ((ItemDeltaItem)sourceObject).getItemOld(); - delta = ((ItemDeltaItem)sourceObject).getDelta(); - itemNew = ((ItemDeltaItem)sourceObject).getItemNew(); - residualPath = ((ItemDeltaItem)sourceObject).getResidualPath(); - resolvePath = ((ItemDeltaItem)sourceObject).getResolvePath(); - subItemDeltas = ((ItemDeltaItem)sourceObject).getSubItemDeltas(); - } else if (sourceObject instanceof Item) { - itemOld = (Item) sourceObject; - itemNew = (Item) sourceObject; + if (sourceObject instanceof ItemDeltaItem) { + itemOld = ((ItemDeltaItem)sourceObject).getItemOld(); + delta = ((ItemDeltaItem)sourceObject).getDelta(); + itemNew = ((ItemDeltaItem)sourceObject).getItemNew(); + residualPath = ((ItemDeltaItem)sourceObject).getResidualPath(); + resolvePath = ((ItemDeltaItem)sourceObject).getResolvePath(); + subItemDeltas = ((ItemDeltaItem)sourceObject).getSubItemDeltas(); + } else if (sourceObject instanceof Item) { + itemOld = (Item) sourceObject; + itemNew = (Item) sourceObject; } else { throw new IllegalStateException("Unknown resolve result "+sourceObject); } } - Source source = new Source(itemOld, delta, itemNew, name); + Source source = new Source<>(itemOld, delta, itemNew, name); source.setResidualPath(residualPath); source.setResolvePath(resolvePath); source.setSubItemDeltas(subItemDeltas); @@ -881,7 +881,7 @@ private void parseTarget() throws SchemaException { } } - public ItemDefinition getOutputDefinition() throws SchemaException { + public D getOutputDefinition() throws SchemaException { if (outputDefinition == null) { parseTarget(); } @@ -942,8 +942,8 @@ private void evaluateCondition(Task task, OperationResult result) throws SchemaE conditionOutputTriple.addToZeroSet(new PrismPropertyValue(Boolean.TRUE)); return; } - ItemDefinition conditionOutput = new PrismPropertyDefinition(CONDITION_OUTPUT_NAME, DOMUtil.XSD_BOOLEAN, expressionFactory.getPrismContext()); - Expression> expression = expressionFactory.makeExpression(conditionExpressionType, + PrismPropertyDefinition conditionOutput = new PrismPropertyDefinition<>(CONDITION_OUTPUT_NAME, DOMUtil.XSD_BOOLEAN, expressionFactory.getPrismContext()); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(conditionExpressionType, conditionOutput, "condition in "+getMappingContextDescription(), result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(sources, variables, "condition in "+getMappingContextDescription(), task, result); @@ -1006,16 +1006,16 @@ public PrismValueDeltaSetTriple getOutputTriple() { return outputTriple; } - public Item getOutput() throws SchemaException { + public Item getOutput() throws SchemaException { if (outputTriple == null) { return null; } - Item output = outputDefinition.instantiate(); + Item output = outputDefinition.instantiate(); output.addAll(PrismValue.cloneCollection(outputTriple.getNonNegativeValues())); return output; } - public ItemDelta createEmptyDelta(ItemPath path) { + public ItemDelta createEmptyDelta(ItemPath path) { return outputDefinition.createEmptyDelta(path); } @@ -1038,8 +1038,8 @@ private PrismPropertyValue filterValue(PrismPropertyValue propertyValu /** * Shallow clone. Only the output is cloned deeply. */ - public Mapping clone() { - Mapping clone = new Mapping(mappingType, contextDescription, expressionFactory, securityEnforcer); + public Mapping clone() { + Mapping clone = new Mapping<>(mappingType, contextDescription, expressionFactory, securityEnforcer); clone.conditionMaskNew = this.conditionMaskNew; clone.conditionMaskOld = this.conditionMaskOld; if (this.conditionOutputTriple != null) { diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingFactory.java index 38865ccae25..943fd4b29c0 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,8 +114,8 @@ public void setProfiling(boolean profiling) { this.profiling = profiling; } - public Mapping createMapping(MappingType mappingType, String shortDesc) { - Mapping mapping = new Mapping<>(mappingType, shortDesc, expressionFactory, securityEnforcer); + public Mapping createMapping(MappingType mappingType, String shortDesc) { + Mapping mapping = new Mapping<>(mappingType, shortDesc, expressionFactory, securityEnforcer); mapping.setFilterManager(filterManager); mapping.setProfiling(profiling); return mapping; diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java index 1e3d71f1089..871330f7f8f 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Evolveum + * Copyright (c) 2013-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ public void testIterationCondition() throws Exception { PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME, DOMUtil.XSD_BOOLEAN, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, outputDefinition , TEST_NAME, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, outputDefinition , TEST_NAME, result); ExpressionVariables variables = new ExpressionVariables(); PrismObject user = PrismTestUtil.parseObject(new File(TEST_DIR, "user-jack.xml")); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java index 3fd73a3b6cf..72b9dcc3270 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ import static org.testng.AssertJUnit.assertEquals; import com.evolveum.midpoint.prism.PrismContext; - import com.evolveum.midpoint.prism.util.PrismAsserts; + import org.testng.annotations.Test; import org.testng.AssertJUnit; @@ -43,6 +43,7 @@ import com.evolveum.midpoint.model.common.expression.ObjectDeltaObject; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.parser.XPathHolder; @@ -141,7 +142,7 @@ public void testResolvePathPolyStringOdo() throws Exception { // GIVEN // WHEN - ItemDeltaItem> idi = resolvePathOdo("$user/fullName", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName", TEST_NAME); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), @@ -162,7 +163,7 @@ public void testResolvePathPolyStringOdoOrig() throws Exception { // GIVEN // WHEN - ItemDeltaItem> idi = resolvePathOdo("$user/fullName/t:orig", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:orig", TEST_NAME); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), @@ -181,7 +182,7 @@ public void testResolvePathPolyStringOdoNorm() throws Exception { // GIVEN // WHEN - ItemDeltaItem> idi = resolvePathOdo("$user/fullName/t:norm", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:norm", TEST_NAME); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/MappingTestEvaluator.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/MappingTestEvaluator.java index d994b6a19ff..c978cb610b7 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/MappingTestEvaluator.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/MappingTestEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.crypto.AESProtector; import com.evolveum.midpoint.prism.crypto.EncryptionException; @@ -113,30 +114,30 @@ public AESProtector getProtector() { return protector; } - public Mapping> createMapping(String filename, String testName, final StringPolicyType policy, String defaultTargetPropertyName, ObjectDelta userDelta) throws SchemaException, IOException, JAXBException, EncryptionException { + public Mapping,PrismPropertyDefinition> createMapping(String filename, String testName, final StringPolicyType policy, String defaultTargetPropertyName, ObjectDelta userDelta) throws SchemaException, IOException, JAXBException, EncryptionException { return createMapping(filename, testName, policy, toPath(defaultTargetPropertyName), userDelta); } - public Mapping> createMapping(String filename, String testName, String defaultTargetPropertyName, + public Mapping,PrismPropertyDefinition> createMapping(String filename, String testName, String defaultTargetPropertyName, ObjectDelta userDelta) throws SchemaException, IOException, JAXBException, EncryptionException { return createMapping(filename, testName, null, toPath(defaultTargetPropertyName), userDelta); } - public Mapping> createMapping(String filename, String testName, QName defaultTargetPropertyName, + public Mapping,PrismPropertyDefinition> createMapping(String filename, String testName, QName defaultTargetPropertyName, ObjectDelta userDelta) throws SchemaException, IOException, JAXBException, EncryptionException { return createMapping(filename, testName, null, toPath(defaultTargetPropertyName), userDelta); } - public Mapping> createMapping(String filename, String testName, String defaultTargetPropertyName, + public Mapping,PrismPropertyDefinition> createMapping(String filename, String testName, String defaultTargetPropertyName, ObjectDelta userDelta, PrismObject userOld) throws SchemaException, IOException, JAXBException { return createMapping(filename, testName, null, toPath(defaultTargetPropertyName), userDelta, userOld); } - public Mapping> createMapping(String filename, String testName, ItemPath defaultTargetPropertyName, ObjectDelta userDelta) throws SchemaException, IOException, JAXBException, EncryptionException { + public Mapping,PrismPropertyDefinition> createMapping(String filename, String testName, ItemPath defaultTargetPropertyName, ObjectDelta userDelta) throws SchemaException, IOException, JAXBException, EncryptionException { return createMapping(filename, testName, null, defaultTargetPropertyName, userDelta); } - public Mapping> createMapping(String filename, String testName, final StringPolicyType policy, + public Mapping,PrismPropertyDefinition> createMapping(String filename, String testName, final StringPolicyType policy, ItemPath defaultTargetPropertyPath, ObjectDelta userDelta) throws SchemaException, IOException, JAXBException, EncryptionException { PrismObject userOld = null; @@ -146,14 +147,14 @@ public Mapping> createMapping(String filename, String return createMapping(filename, testName, policy, defaultTargetPropertyPath, userDelta, userOld); } - public Mapping> createMapping(String filename, String testName, final StringPolicyType policy, + public Mapping,PrismPropertyDefinition> createMapping(String filename, String testName, final StringPolicyType policy, ItemPath defaultTargetPropertyPath, ObjectDelta userDelta, PrismObject userOld) throws SchemaException, IOException, JAXBException { MappingType mappingType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, filename), MappingType.COMPLEX_TYPE); - Mapping> mapping = mappingFactory.createMapping(mappingType, testName); + Mapping,PrismPropertyDefinition> mapping = mappingFactory.createMapping(mappingType, testName); // Source context: user ObjectDeltaObject userOdo = new ObjectDeltaObject(userOld , userDelta, null); @@ -197,7 +198,7 @@ public StringPolicyType resolve() { mapping.setStringPolicyResolver(stringPolicyResolver); // Default target if (defaultTargetPropertyPath != null) { - ItemDefinition targetDefDefinition = userDefinition.findItemDefinition(defaultTargetPropertyPath); + PrismPropertyDefinition targetDefDefinition = userDefinition.findItemDefinition(defaultTargetPropertyPath); if (targetDefDefinition == null) { throw new IllegalArgumentException("The item path '"+defaultTargetPropertyPath+"' does not have a definition in "+userDefinition); } @@ -207,15 +208,15 @@ public StringPolicyType resolve() { return mapping; } - public Mapping> createInboudMapping(String filename, String testName, ItemDelta delta, UserType user, ShadowType account, ResourceType resource, final StringPolicyType policy) throws SchemaException, IOException, JAXBException{ + public Mapping,PrismPropertyDefinition> createInboudMapping(String filename, String testName, ItemDelta delta, UserType user, ShadowType account, ResourceType resource, final StringPolicyType policy) throws SchemaException, IOException, JAXBException{ MappingType mappingType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, filename), MappingType.COMPLEX_TYPE); - Mapping> mapping = mappingFactory.createMapping(mappingType,testName); + Mapping,PrismPropertyDefinition> mapping = mappingFactory.createMapping(mappingType,testName); - Source> defaultSource = new Source>(null, delta, null, ExpressionConstants.VAR_INPUT); + Source,PrismPropertyDefinition> defaultSource = new Source<>(null, delta, null, ExpressionConstants.VAR_INPUT); defaultSource.recompute(); mapping.setDefaultSource(defaultSource); mapping.setTargetContext(getUserDefinition()); @@ -270,7 +271,7 @@ public PrismObjectDefinition getUserDefinition() { public PrismValueDeltaSetTriple> evaluateMapping(String filename, String testName, ItemPath defaultTargetPropertyPath) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyPath, null); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyPath, null); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); @@ -280,7 +281,7 @@ public PrismValueDeltaSetTriple> evaluateMapping(Str public PrismValueDeltaSetTriple> evaluateMapping(String filename, String testName, QName defaultTargetPropertyName) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyName, null); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyName, null); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); @@ -290,7 +291,7 @@ public PrismValueDeltaSetTriple> evaluateMapping(Str public PrismValueDeltaSetTriple> evaluateMapping(String filename, String testName, String defaultTargetPropertyName) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyName, null); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyName, null); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); @@ -317,7 +318,7 @@ public PrismValueDeltaSetTriple> evaluateMappingDyna String changedPropertyName, I... valuesToAdd) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { ObjectDelta userDelta = ObjectDelta.createModificationAddProperty(UserType.class, USER_OLD_OID, toPath(changedPropertyName), prismContext, valuesToAdd); - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyPath, userDelta); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyPath, userDelta); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); @@ -329,7 +330,7 @@ public PrismValueDeltaSetTriple> evaluateMappingDyna String changedPropertyName, I... valuesToAdd) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { ObjectDelta userDelta = ObjectDelta.createModificationDeleteProperty(UserType.class, USER_OLD_OID, toPath(changedPropertyName), prismContext, valuesToAdd); - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); @@ -341,7 +342,7 @@ public PrismValueDeltaSetTriple> evaluateMappingDyna String changedPropertyName, I... valuesToReplace) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { ObjectDelta userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_OLD_OID, toPath(changedPropertyName), prismContext, valuesToReplace); - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); @@ -353,7 +354,7 @@ public PrismValueDeltaSetTriple> evaluateMappingDyna ItemPath changedPropertyName, I... valuesToReplace) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { ObjectDelta userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_OLD_OID, changedPropertyName, prismContext, valuesToReplace); - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); @@ -365,7 +366,7 @@ public PrismValueDeltaSetTriple> evaluateMappingDyna String changedPropertyName, I... valuesToReplace) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { ObjectDelta userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_OLD_OID, toPath(changedPropertyName), prismContext, valuesToReplace); - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); @@ -377,7 +378,7 @@ public PrismValueDeltaSetTriple> evaluateMappingDyna ItemPath changedPropertyName, I... valuesToReplace) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException { ObjectDelta userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_OLD_OID, changedPropertyName, prismContext, valuesToReplace); - Mapping> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); + Mapping,PrismPropertyDefinition> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta); OperationResult opResult = new OperationResult(testName); mapping.evaluate(null, opResult); assertResult(opResult); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java index dd568fe83d7..f954b1c92b1 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; @@ -59,7 +60,7 @@ public void testModifyObjectSetAdditionalName() throws Exception { UserType.F_ADDITIONAL_NAME, evaluator.getPrismContext(), "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_NUMBER, "321"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, TEST_NAME, "title", delta); @@ -88,7 +89,7 @@ public void testModifyObjectSetAdditionalNameFalse() throws Exception { PrismObject userOld = evaluator.getUserOld(); userOld.asObjectable().getEmployeeType().clear(); userOld.asObjectable().getEmployeeType().add("WHATEVER"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, TEST_NAME, "title", delta, userOld); @@ -114,7 +115,7 @@ public void testModifyObjectUnrelated() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("costCenter"), evaluator.getPrismContext(), "X606"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, TEST_NAME, "title", delta); @@ -142,7 +143,7 @@ public void testModifyObjectUnrelatedFalse() throws Exception { PrismObject userOld = evaluator.getUserOld(); userOld.asObjectable().getEmployeeType().clear(); userOld.asObjectable().getEmployeeType().add("WHATEVER"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, TEST_NAME, "title", delta, userOld); @@ -167,7 +168,7 @@ public void testAddObjectUnrelatedFalse() throws Exception { user.asObjectable().getEmployeeType().add("WHATEVER"); ObjectDelta delta = user.createAddDelta(); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, TEST_NAME, "title", delta); @@ -191,7 +192,7 @@ public void testAddObjectUnrelatedEmptyFalse() throws Exception { user.asObjectable().getEmployeeType().clear(); ObjectDelta delta = user.createAddDelta(); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, TEST_NAME, "title", delta); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java index 154cdfa46ee..f42c3dd8e6f 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -595,7 +595,7 @@ public void testAsIsVariablesPolyStringOrig() throws Exception { @Test public void testScriptExtraVariablesRef() throws Exception { // GIVEN - Mapping> mapping = evaluator.createMapping("mapping-script-extra-variables.xml", + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-script-extra-variables.xml", "testScriptExtraVariablesRef", "employeeType", null); Map vars = new HashMap(); @@ -622,7 +622,7 @@ public void testScriptExtraVariablesJaxb() throws Exception { // GIVEN final String TEST_NAME = "testScriptExtraVariablesJaxb"; TestUtil.displayTestTile(TEST_NAME); - Mapping> mapping = evaluator.createMapping("mapping-script-extra-variables.xml", + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-script-extra-variables.xml", TEST_NAME, "employeeType", null); Map vars = new HashMap(); @@ -685,7 +685,7 @@ public void testScriptFullNameDeleteGivenName() throws Exception { ObjectDelta delta = ObjectDelta.createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_GIVEN_NAME, evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack")); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-fullname.xml", TEST_NAME, "fullName", // target @@ -715,7 +715,7 @@ public void testScriptFullNameDeleteGivenNameFromNull() throws Exception { PrismObject userOld = evaluator.getUserOld(); userOld.asObjectable().setGivenName(null); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-fullname.xml", TEST_NAME, "fullName", // target @@ -743,7 +743,7 @@ public void testScriptFullNameDeleteGivenNameFamilyName() throws Exception { UserType.F_GIVEN_NAME, evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack")); delta.addModificationDeleteProperty(UserType.F_FAMILY_NAME, PrismTestUtil.createPolyString("Sparrow")); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-fullname.xml", TEST_NAME, "fullName", // target @@ -805,7 +805,7 @@ public void testScriptRootNodeRef() throws Exception { // GIVEN final String TEST_NAME = "testScriptRootNodeRef"; TestUtil.displayTestTile(TEST_NAME); - Mapping> mapping = evaluator.createMapping("mapping-script-root-node.xml", + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-script-root-node.xml", TEST_NAME, "locality", null); mapping.setRootNode(MiscSchemaUtil.createObjectReference( @@ -818,7 +818,7 @@ public void testScriptRootNodeRef() throws Exception { mapping.evaluate(null, opResult); // THEN - PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); + PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleZero(outputTriple, new PolyString("Black Pearl", "black pearl")); PrismAsserts.assertTripleNoPlus(outputTriple); PrismAsserts.assertTripleNoMinus(outputTriple); @@ -829,7 +829,7 @@ public void testScriptRootNodeJaxb() throws Exception { // GIVEN final String TEST_NAME = "testScriptRootNodeJaxb"; TestUtil.displayTestTile(TEST_NAME); - Mapping> mapping = evaluator.createMapping("mapping-script-root-node.xml", + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-script-root-node.xml", TEST_NAME, "locality", null); PrismObject user = PrismTestUtil.parseObject(new File(MidPointTestConstants.OBJECTS_DIR, "c0c010c0-d34d-b33f-f00d-111111111111.xml")); @@ -841,7 +841,7 @@ public void testScriptRootNodeJaxb() throws Exception { mapping.evaluate(null, opResult); // THEN - PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); + PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleZero(outputTriple, new PolyString("Black Pearl", "black pearl")); PrismAsserts.assertTripleNoPlus(outputTriple); PrismAsserts.assertTripleNoMinus(outputTriple); @@ -956,7 +956,7 @@ public void testConditionNonEmptyCaptain() throws Exception { user.asObjectable().getEmployeeType().add("CAPTAIN"); ObjectDelta delta = ObjectDelta.createAddDelta(user); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", TEST_NAME, "title", delta); @@ -983,7 +983,7 @@ public void testConditionNonEmptyEmpty() throws Exception { user.asObjectable().getEmployeeType().add(""); ObjectDelta delta = ObjectDelta.createAddDelta(user); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", TEST_NAME, "title", delta); @@ -1007,7 +1007,7 @@ public void testConditionNonEmptyNoValue() throws Exception { user.asObjectable().getEmployeeType().clear(); ObjectDelta delta = ObjectDelta.createAddDelta(user); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", TEST_NAME, "title", delta); @@ -1032,7 +1032,7 @@ public void testScriptTransformMulti() throws Exception { propDelta.addValueToDelete(new PrismPropertyValue("LANDLUBER")); delta.addModification(propDelta); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-transform.xml", TEST_NAME, "organizationalUnit", delta); @@ -1063,7 +1063,7 @@ public void testInboundMapping() throws Exception{ PrismObject user = evaluator.getUserDefinition().instantiate(); - Mapping> mapping = evaluator.createInboudMapping("mapping-inbound.xml", TEST_NAME, delta, user.asObjectable(), account.asObjectable(), null, null); + Mapping,PrismPropertyDefinition> mapping = evaluator.createInboudMapping("mapping-inbound.xml", TEST_NAME, delta, user.asObjectable(), account.asObjectable(), null, null); OperationResult opResult = new OperationResult(TEST_NAME); mapping.evaluate(null, opResult); @@ -1081,7 +1081,7 @@ public void testGenerateDefault() throws Exception { final StringPolicyType stringPolicy = evaluator.getStringPolicy(); // GIVEN - Mapping> mapping = evaluator.createMapping("mapping-generate.xml", + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-generate.xml", TEST_NAME, stringPolicy, "employeeNumber", null); // StringPolicyResolver stringPolicyResolver = new StringPolicyResolver() { @@ -1173,7 +1173,7 @@ private void generatePolicy(final String TEST_NAME, String mappingFileName, Stri new File(MidPointTestConstants.OBJECTS_DIR, policyFileName)); final StringPolicyType stringPolicy = valuePolicy.asObjectable().getStringPolicy(); // GIVEN - Mapping> mapping = evaluator.createMapping(mappingFileName, + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping(mappingFileName, TEST_NAME, stringPolicy, "employeeNumber", null); OperationResult opResult = new OperationResult(TEST_NAME); @@ -1253,7 +1253,7 @@ private void generatePolicyNumeric(final String TEST_NAME, String mappingFil new File(MidPointTestConstants.OBJECTS_DIR, policyFileName)); final StringPolicyType stringPolicy = valuePolicy.asObjectable().getStringPolicy(); // GIVEN - Mapping> mapping = evaluator.createMapping(mappingFileName, + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping(mappingFileName, TEST_NAME, stringPolicy, new ItemPath( UserType.F_EXTENSION, new QName(NS_EXTENSION, extensionPropName)), null); @@ -1294,7 +1294,7 @@ public void testGenerateProtectedString() throws Exception { final String TEST_NAME = "testGenerateProtectedString"; TestUtil.displayTestTile(TEST_NAME); // GIVEN - Mapping> mapping = evaluator.createMapping("mapping-generate.xml", + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-generate.xml", TEST_NAME, SchemaConstants.PATH_PASSWORD_VALUE, null); OperationResult opResult = new OperationResult(TEST_NAME); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java index c34bc5a98f0..84a514d3916 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; @@ -88,7 +89,7 @@ public void testScriptSystemVariablesConditionAddObjectTrue(String filename) thr user.asObjectable().getEmployeeType().add("CAPTAIN"); ObjectDelta delta = ObjectDelta.createAddDelta(user); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -116,7 +117,7 @@ public void testScriptSystemVariablesConditionModifyObjectTrueGroovyUnrelated() ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("employeeNumber"), evaluator.getPrismContext(), "666"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-condition-groovy.xml", TEST_NAME, "title", delta); @@ -155,7 +156,7 @@ public void testScriptSystemVariablesConditionAddObjectFalse(String filename) th user.asObjectable().getEmployeeType().add("SAILOR"); ObjectDelta delta = ObjectDelta.createAddDelta(user); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -194,7 +195,7 @@ public void testScriptSystemVariablesConditionAddObjectFalseNoVal(String filenam employeeTypeProperty.clear(); ObjectDelta delta = ObjectDelta.createAddDelta(user); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -233,7 +234,7 @@ public void testScriptSystemVariablesConditionAddObjectFalseNoProperty(String fi user.removeProperty(UserType.F_EMPLOYEE_TYPE); ObjectDelta delta = ObjectDelta.createAddDelta(user); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -266,7 +267,7 @@ public void testScriptSystemVariablesConditionTrueToTrue(String filename) throws ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("name"), evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack")); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -304,7 +305,7 @@ public void testScriptSystemVariablesConditionFalseToFalse(String filename) thro ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("name"), evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack")); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -337,7 +338,7 @@ public void testScriptSystemVariablesConditionFalseToTrue(String filename) throw evaluator.toPath("name"), evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack")); delta.addModificationAddProperty(evaluator.toPath("employeeType"), "CAPTAIN"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); OperationResult opResult = new OperationResult(TEST_NAME); @@ -371,7 +372,7 @@ public void testScriptSystemVariablesConditionTrueToFalse(String filename) throw evaluator.toPath("name"), evaluator.getPrismContext(), "Jack"); delta.addModificationDeleteProperty(evaluator.toPath("employeeType"), "CAPTAIN"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); @@ -421,7 +422,7 @@ public void testScriptSystemVariablesConditionEmptyTrue(final String TEST_NAME, ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("name"), evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack")); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -461,7 +462,7 @@ public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String TEST ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("employeeNumber"), evaluator.getPrismContext()); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -512,7 +513,7 @@ public void testScriptSystemVariablesConditionEmptyFalse(final String TEST_NAME, ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("name"), evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack")); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -550,7 +551,7 @@ public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String TEST ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("employeeNumber"), evaluator.getPrismContext(), "666"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( filename, TEST_NAME, "title", delta); @@ -579,7 +580,7 @@ public void testNpeFalseToTrue() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, evaluator.getPrismContext(), "Captain Sparrow"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-npe.xml", TEST_NAME, "title", delta); @@ -604,7 +605,7 @@ public void testNpeTrueToFalse() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, evaluator.getPrismContext()); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-npe.xml", TEST_NAME, "title", delta); @@ -633,7 +634,7 @@ public void testPathEnum() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, evaluator.getPrismContext(), ActivationStatusType.DISABLED); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-path-enum.xml", TEST_NAME, "costCenter", delta); @@ -780,7 +781,7 @@ public void testEmployeeTypeDeltaAreplaceB() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "B"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta); @@ -810,7 +811,7 @@ public void testEmployeeTypeDeltaNullreplaceB() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "B"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta); @@ -840,7 +841,7 @@ public void testEmployeeTypeDeltaBreplaceB() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "B"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta); @@ -929,7 +930,7 @@ public PrismValueDeltaSetTriple> employeeTypeDeltaABA ObjectDelta delta = ObjectDelta.createModificationAddProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), addVal); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta); @@ -1021,7 +1022,7 @@ public PrismValueDeltaSetTriple> employeeTypeDeltaDel ObjectDelta delta = ObjectDelta.createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), delVal); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java index 5f89560be2a..35584da3fb6 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public void testBeforeTimeFrom() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "CAPTAIN"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_TIME_FROM_TO_FILENAME, TEST_NAME, "title", delta); mapping.setNow(TIME_PAST); @@ -99,7 +99,7 @@ public void testBetweenTimes() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "CAPTAIN"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_TIME_FROM_TO_FILENAME, TEST_NAME, "title", delta); mapping.setNow(TIME_BETWEEN); @@ -127,7 +127,7 @@ public void testAfterTimeTo() throws Exception { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "CAPTAIN"); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_TIME_FROM_TO_FILENAME, TEST_NAME, "title", delta); mapping.setNow(TIME_FUTURE); @@ -150,7 +150,7 @@ public void testExistenceBefore() throws Exception { System.out.println("===[ "+TEST_NAME+"]==="); // GIVEN - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_TIME_ACTIVATION, TEST_NAME, "title", null); @@ -179,7 +179,7 @@ public void testExistenceAfter() throws Exception { System.out.println("===[ "+TEST_NAME+"]==="); // GIVEN - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_TIME_ACTIVATION, TEST_NAME, "title", null); @@ -214,7 +214,7 @@ public void testNoReferenceTime() throws Exception { PrismObject userOld = evaluator.getUserOld(); userOld.asObjectable().getActivation().setDisableTimestamp(null); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_TIME_ACTIVATION, TEST_NAME, "title", null, userOld); @@ -252,7 +252,7 @@ public void testSetReferenceTimeBefore() throws Exception { new ItemPath(UserType.F_ACTIVATION, ActivationType.F_DISABLE_TIMESTAMP), evaluator.getPrismContext(), disableTimestamp); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_TIME_ACTIVATION, TEST_NAME, "title", delta, userOld); @@ -289,7 +289,7 @@ public void testSetReferenceTimeAfter() throws Exception { new ItemPath(UserType.F_ACTIVATION, ActivationType.F_DISABLE_TIMESTAMP), evaluator.getPrismContext(), disableTimestamp); - Mapping> mapping = evaluator.createMapping( + Mapping,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_TIME_ACTIVATION, TEST_NAME, "title", delta, userOld); @@ -318,7 +318,7 @@ private void assertNullTriple(PrismValueDeltaSetTriple outputTriple) { assertNull("Unexpected output triple: "+outputTriple, outputTriple); } - private void assertNextRecompute(Mapping mapping, XMLGregorianCalendar expected) { + private void assertNextRecompute(Mapping mapping, XMLGregorianCalendar expected) { XMLGregorianCalendar nextRecomputeTime = mapping.getNextRecomputeTime(); assertEquals("Wrong nextRecomputeTime in mapping "+mapping, expected, nextRecomputeTime); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelCrudService.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelCrudService.java index e4a94a73c7d..568d070b677 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelCrudService.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelCrudService.java @@ -495,7 +495,7 @@ public void modifyObject(Class type, String oid, } public PrismObject findShadowOwner(String accountOid, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SecurityViolationException, SchemaException { + throws ObjectNotFoundException, SecurityViolationException, SchemaException, ConfigurationException { return modelController.findShadowOwner(accountOid, task, parentResult); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelObjectResolver.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelObjectResolver.java index d600ffe709d..072ed4ec266 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelObjectResolver.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelObjectResolver.java @@ -111,11 +111,11 @@ public O resolve(ObjectReferenceType ref, Class expect } } - public PrismObject resolve(PrismReferenceValue refVal, String string, Task task, OperationResult result) throws ObjectNotFoundException { + public PrismObject resolve(PrismReferenceValue refVal, String string, Task task, OperationResult result) throws ObjectNotFoundException { return resolve(refVal, string, null, task, result); } - public PrismObject resolve(PrismReferenceValue refVal, String string, GetOperationOptions options, Task task, + public PrismObject resolve(PrismReferenceValue refVal, String string, GetOperationOptions options, Task task, OperationResult result) throws ObjectNotFoundException { String oid = refVal.getOid(); Class typeClass = ObjectType.class; @@ -127,7 +127,7 @@ public PrismObject resolve(PrismReferenceValue refVal, String string, GetOper if (typeQName != null) { typeClass = prismContext.getSchemaRegistry().determineCompileTimeClass(typeQName); } - return ((ObjectType) getObjectSimple((Class)typeClass, oid, options, task, result)).asPrismObject(); + return (getObjectSimple((Class)typeClass, oid, options, task, result)).asPrismObject(); } public T getObjectSimple(Class clazz, String oid, GetOperationOptions options, Task task, diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java index 6a1b9382bca..f3a9765c88e 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java @@ -420,6 +420,8 @@ public Response findShadowOwner(@PathParam("oid") String shadowOid, @Context Mes response = Response.status(Status.FORBIDDEN).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); } catch (SchemaException e) { response = Response.status(Status.CONFLICT).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); + } catch (ConfigurationException e) { + response = Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).type(MediaType.TEXT_HTML).build(); } parentResult.computeStatus(); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java index 41b73bbccb0..c96af97dbab 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java @@ -308,10 +308,13 @@ public PrismObject getObject(Class clazz, String oi ref.setOid(oid); ref.setType(ObjectTypes.getObjectType(clazz).getTypeQName()); Utils.clearRequestee(task); + object = objectResolver.getObject(clazz, oid, options, task, result).asPrismObject(); + applySchemasAndSecurity(object, rootOptions, task, result); resolve(object, options, task, result); resolveNames(object, options, task, result); + } catch (SchemaException e) { ModelUtils.recordFatalError(result, e); throw e; @@ -341,12 +344,11 @@ public PrismObject getObject(Class clazz, String oi result.cleanupResult(); - postProcessObject(object, rootOptions, result); return object; } protected void resolve(PrismObject object, Collection> options, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException { + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException { if (object == null || options == null) { return; } @@ -411,7 +413,7 @@ public void visit(Visitable visitable) { } - private void resolve(PrismObject object, SelectorOptions option, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException { + private void resolve(PrismObject object, SelectorOptions option, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException { if (!GetOperationOptions.isResolve(option.getOptions())) { return; } @@ -423,7 +425,7 @@ private void resolve(PrismObject object, SelectorOptions resolve (object, path, option, task, result); } - private void resolve(PrismObject object, ItemPath path, SelectorOptions option, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException { + private void resolve(PrismObject object, ItemPath path, SelectorOptions option, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException { if (path == null || path.isEmpty()) { return; } @@ -435,9 +437,10 @@ private void resolve(PrismObject object, ItemPath path, SelectorOptions refObject = refVal.getObject(); + PrismObject refObject = refVal.getObject(); if (refObject == null) { refObject = objectResolver.resolve(refVal, object.toString(), option.getOptions(), task, result); + applySchemasAndSecurity(refObject, option.getOptions(), task, result); refVal.setObject(refObject); } if (!rest.isEmpty()) { @@ -927,56 +930,91 @@ private void applyObjectTemplateToDefinition(PrismObjectD } ItemPath itemPath = ref.getItemPath(); ItemDefinition itemDef = objectDefinition.findItemDefinition(itemPath); - if (itemDef == null) { - throw new SchemaException("No definition for item "+itemPath+" in object type "+objectDefinition.getTypeName()+" as specified in item definition in "+objectTemplateType); - } + applyObjectTemplateItem(itemDef, templateItemDefType, "item "+itemPath+" in object type "+objectDefinition.getTypeName()+" as specified in item definition in "+objectTemplateType); - String displayName = templateItemDefType.getDisplayName(); - if (displayName != null) { - itemDef.setDisplayName(displayName); + } + } + + private void applyObjectTemplateToObject(PrismObject object, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException { + if (objectTemplateType == null) { + return; + } + for (ObjectReferenceType includeRef: objectTemplateType.getIncludeRef()) { + PrismObject subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result); + applyObjectTemplateToObject(object, subTemplate.asObjectable(), result); + } + for (ObjectTemplateItemDefinitionType templateItemDefType: objectTemplateType.getItem()) { + ItemPathType ref = templateItemDefType.getRef(); + if (ref == null) { + throw new SchemaException("No 'ref' in item definition in "+objectTemplateType); } - - Integer displayOrder = templateItemDefType.getDisplayOrder(); - if (displayOrder != null) { - itemDef.setDisplayOrder(displayOrder); + ItemPath itemPath = ref.getItemPath(); + ItemDefinition itemDefFromObject = object.getDefinition().findItemDefinition(itemPath); + applyObjectTemplateItem(itemDefFromObject, templateItemDefType, "item "+itemPath+" in " + object + + " as specified in item definition in "+objectTemplateType); + Item item = object.findItem(itemPath); + if (item != null) { + ItemDefinition itemDef = item.getDefinition(); + if (itemDef != itemDefFromObject) { + applyObjectTemplateItem(itemDef, templateItemDefType, "item "+itemPath+" in " + object + + " as specified in item definition in "+objectTemplateType); + } } - List limitations = templateItemDefType.getLimitations(); - if (limitations != null) { - PropertyLimitationsType limitationsType = MiscSchemaUtil.getLimitationsType(limitations, LayerType.PRESENTATION); - if (limitationsType != null) { - if (limitationsType.getMinOccurs() != null) { - itemDef.setMinOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMinOccurs())); - } - if (limitationsType.getMaxOccurs() != null) { - itemDef.setMaxOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMaxOccurs())); + } + } + + private void applyObjectTemplateItem(ID itemDef, + ObjectTemplateItemDefinitionType templateItemDefType, String desc) throws SchemaException { + if (itemDef == null) { + throw new SchemaException("No definition for "+desc); + } + + String displayName = templateItemDefType.getDisplayName(); + if (displayName != null) { + itemDef.setDisplayName(displayName); + } + + Integer displayOrder = templateItemDefType.getDisplayOrder(); + if (displayOrder != null) { + itemDef.setDisplayOrder(displayOrder); + } + + List limitations = templateItemDefType.getLimitations(); + if (limitations != null) { + PropertyLimitationsType limitationsType = MiscSchemaUtil.getLimitationsType(limitations, LayerType.PRESENTATION); + if (limitationsType != null) { + if (limitationsType.getMinOccurs() != null) { + itemDef.setMinOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMinOccurs())); + } + if (limitationsType.getMaxOccurs() != null) { + itemDef.setMaxOccurs(XsdTypeMapper.multiplicityToInteger(limitationsType.getMaxOccurs())); + } + if (limitationsType.isIgnore() != null) { + itemDef.setIgnored(limitationsType.isIgnore()); + } + PropertyAccessType accessType = limitationsType.getAccess(); + if (accessType != null) { + if (accessType.isAdd() != null) { + itemDef.setCanAdd(accessType.isAdd()); } - if (limitationsType.isIgnore() != null) { - itemDef.setIgnored(limitationsType.isIgnore()); + if (accessType.isModify() != null) { + itemDef.setCanModify(accessType.isModify()); } - PropertyAccessType accessType = limitationsType.getAccess(); - if (accessType != null) { - if (accessType.isAdd() != null) { - itemDef.setCanAdd(accessType.isAdd()); - } - if (accessType.isModify() != null) { - itemDef.setCanModify(accessType.isModify()); - } - if (accessType.isRead() != null) { - itemDef.setCanRead(accessType.isRead()); - } + if (accessType.isRead() != null) { + itemDef.setCanRead(accessType.isRead()); } } } - - ObjectReferenceType valueEnumerationRef = templateItemDefType.getValueEnumerationRef(); - if (valueEnumerationRef != null) { - PrismReferenceValue valueEnumerationRVal = MiscSchemaUtil.objectReferenceTypeToReferenceValue(valueEnumerationRef); - itemDef.setValueEnumerationRef(valueEnumerationRVal); - } } + + ObjectReferenceType valueEnumerationRef = templateItemDefType.getValueEnumerationRef(); + if (valueEnumerationRef != null) { + PrismReferenceValue valueEnumerationRVal = MiscSchemaUtil.objectReferenceTypeToReferenceValue(valueEnumerationRef); + itemDef.setValueEnumerationRef(valueEnumerationRVal); + } } - + private void applySecurityConstraints(D itemDefinition, ItemPath itemPath, ObjectSecurityConstraints securityConstraints, AuthorizationDecisionType defaultReadDecition, AuthorizationDecisionType defaultAddDecition, AuthorizationDecisionType defaultModifyDecition, AuthorizationPhaseType phase) { @@ -1370,7 +1408,7 @@ public SearchResultList> searchObjects(Cla RepositoryCache.exit(); } - postProcessObjects(list, rootOptions, result); + applySchemasAndSecurityToObjects(list, rootOptions, task, result); return list; } @@ -1416,7 +1454,7 @@ public boolean handle(PrismObject object, OperationResult parentResult) { } } resolveNames(object, options, task, parentResult); - postProcessObject(object, rootOptions, parentResult); + applySchemasAndSecurity(object, rootOptions, task, parentResult); } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException ex) { parentResult.recordFatalError(ex); @@ -1557,7 +1595,7 @@ public Integer countObjects(Class type, ObjectQuery qu @Override public PrismObject findShadowOwner(String accountOid, Task task, OperationResult parentResult) - throws ObjectNotFoundException, SecurityViolationException, SchemaException { + throws ObjectNotFoundException, SecurityViolationException, SchemaException, ConfigurationException { Validate.notEmpty(accountOid, "Account oid must not be null or empty."); Validate.notNull(parentResult, "Result type must not be null."); @@ -1578,11 +1616,18 @@ public PrismObject findShadowOwner(String accountOid, Task task, Opera LoggingUtils.logException(LOGGER, "Account with oid {} doesn't exists", ex, accountOid); result.recordFatalError("Account with oid '" + accountOid + "' doesn't exists", ex); throw ex; - } catch (Exception ex) { + } catch (RuntimeException ex) { + LoggingUtils.logException(LOGGER, "Couldn't list account shadow owner from repository" + + " for account with oid {}", ex, accountOid); + result.recordFatalError("Couldn't list account shadow owner for account with oid '" + + accountOid + "'.", ex); + throw ex; + } catch (Error ex) { LoggingUtils.logException(LOGGER, "Couldn't list account shadow owner from repository" + " for account with oid {}", ex, accountOid); result.recordFatalError("Couldn't list account shadow owner for account with oid '" + accountOid + "'.", ex); + throw ex; } finally { if (LOGGER.isTraceEnabled()) { LOGGER.trace(result.dump(false)); @@ -1592,7 +1637,16 @@ public PrismObject findShadowOwner(String accountOid, Task task, Opera } if (user != null) { - postProcessObject(user, null, result); + try { + applySchemasAndSecurity(user, null, task, result); + } catch (SchemaException | SecurityViolationException | ConfigurationException + | ObjectNotFoundException ex) { + LoggingUtils.logException(LOGGER, "Couldn't list account shadow owner from repository" + + " for account with oid {}", ex, accountOid); + result.recordFatalError("Couldn't list account shadow owner for account with oid '" + + accountOid + "'.", ex); + throw ex; + } } return user; @@ -1865,8 +1919,8 @@ public void importObjectsFromStream(InputStream input, ImportOptionsType options * com.evolveum.midpoint.common.result.OperationResult) */ @Override - public Set discoverConnectors(ConnectorHostType hostType, OperationResult parentResult) - throws CommunicationException, SecurityViolationException, SchemaException { + public Set discoverConnectors(ConnectorHostType hostType, Task task, OperationResult parentResult) + throws CommunicationException, SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException { RepositoryCache.enter(); OperationResult result = parentResult.createSubresult(DISCOVER_CONNECTORS); Set discoverConnectors; @@ -1877,25 +1931,27 @@ public Set discoverConnectors(ConnectorHostType hostType, Operati RepositoryCache.exit(); throw e; } - postProcessObjectTypes(discoverConnectors, null, result); + applySchemasAndSecurityToObjectTypes(discoverConnectors, null, task, result); result.computeStatus("Connector discovery failed"); RepositoryCache.exit(); result.cleanupResult(); return discoverConnectors; } - private void postProcessObjectTypes(Collection objectTypes, GetOperationOptions options, OperationResult result) throws SecurityViolationException, SchemaException { + private void applySchemasAndSecurityToObjectTypes(Collection objectTypes, + GetOperationOptions options, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ConfigurationException, ObjectNotFoundException { for (T objectType: objectTypes) { - postProcessObject(objectType.asPrismObject(), options, result); + applySchemasAndSecurity(objectType.asPrismObject(), options, task, result); } } - private void postProcessObjects(Collection> objects, GetOperationOptions options, OperationResult result) throws SecurityViolationException, SchemaException { + private void applySchemasAndSecurityToObjects(Collection> objects, + GetOperationOptions options, Task task, OperationResult result) throws SecurityViolationException, SchemaException { for (PrismObject object: objects) { - OperationResult subresult = new OperationResult(ModelController.class.getName()+".postProcessObject"); - try { - postProcessObject(object, options, subresult); - } catch (IllegalArgumentException|IllegalStateException|SchemaException|SecurityViolationException e) { + OperationResult subresult = new OperationResult(ModelController.class.getName()+".applySchemasAndSecurityToObjects"); + try { + applySchemasAndSecurity(object, options, task, subresult); + } catch (IllegalArgumentException|IllegalStateException|SchemaException|SecurityViolationException|ConfigurationException|ObjectNotFoundException e) { LOGGER.error("Error post-processing object {}: {}", new Object[]{object, e.getMessage(), e}); OperationResultType fetchResult = object.asObjectable().getFetchResult(); if (fetchResult == null) { @@ -1909,48 +1965,14 @@ private void postProcessObjects(Collection } } - /** - * Validate the objects, remove any non-visible properties (security) and so on. This method is called for - * any object that is returned from the Model Service. - */ - private void postProcessObject(PrismObject object, GetOperationOptions options, OperationResult result) throws SecurityViolationException, SchemaException { - validateObject(object, options, result); - try { - ObjectSecurityConstraints securityConstraints = securityEnforcer.compileSecurityConstraints(object, null); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Security constrains for {}:\n{}", object, securityConstraints==null?"null":securityConstraints.debugDump()); - } - if (securityConstraints == null) { - throw new AuthorizationException("Access denied"); - } - AuthorizationDecisionType globalDecision = securityConstraints.getActionDecision(ModelAuthorizationAction.READ.getUrl(), null); - if (globalDecision == AuthorizationDecisionType.DENY) { - // shortcut - throw new AuthorizationException("Access denied"); - } - if (globalDecision == AuthorizationDecisionType.ALLOW && securityConstraints.hasNoItemDecisions()) { - // shortcut, nothing to do - } else { - removeDeniedItems((List)object.getValue().getItems(), securityConstraints, globalDecision); - if (object.isEmpty()) { - // let's make it explicit - throw new AuthorizationException("Access denied"); - } - } - - } catch (SecurityViolationException | SchemaException e) { - result.recordFatalError(e); - throw e; - } - } - private void removeDeniedItems(List> items, ObjectSecurityConstraints securityContraints, AuthorizationDecisionType defaultDecision) { + private void applySecurityConstraints(List> items, ObjectSecurityConstraints securityContraints, AuthorizationDecisionType defaultDecision) { if (items == null) { return; } - Iterator> iterator = items.iterator(); + Iterator> iterator = items.iterator(); while (iterator.hasNext()) { - Item item = iterator.next(); + Item item = iterator.next(); ItemPath itemPath = item.getPath(); AuthorizationDecisionType itemDecision = securityContraints.findItemDecision(itemPath, ModelAuthorizationAction.READ.getUrl(), null); if (item instanceof PrismContainer) { @@ -1968,9 +1990,9 @@ private void removeDeniedItems(List> items, ObjectSec Iterator> vi = values.iterator(); while (vi.hasNext()) { PrismContainerValue cval = vi.next(); - List> subitems = cval.getItems(); + List> subitems = cval.getItems(); if (subitems != null) { - removeDeniedItems(subitems, securityContraints, subDefaultDecision); + applySecurityConstraints(subitems, securityContraints, subDefaultDecision); if (subitems.isEmpty()) { vi.remove(); } @@ -1988,6 +2010,58 @@ private void removeDeniedItems(List> items, ObjectSec } } + /** + * Validate the objects, apply security to the object definition, remove any non-visible properties (security), + * apply object template definitions and so on. This method is called for + * any object that is returned from the Model Service. + */ + protected void applySchemasAndSecurity(PrismObject object, GetOperationOptions rootOptions, + Task task, OperationResult parentResult) throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + OperationResult result = parentResult.createMinorSubresult(ModelController.class.getName()+".applySchemasAndSecurity"); + validateObject(object, rootOptions, result); + + object.deepCloneDefinition(true); + + try { + ObjectSecurityConstraints securityConstraints = securityEnforcer.compileSecurityConstraints(object, null); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Security constrains for {}:\n{}", object, securityConstraints==null?"null":securityConstraints.debugDump()); + } + if (securityConstraints == null) { + throw new AuthorizationException("Access denied"); + } + AuthorizationDecisionType globalDecision = securityConstraints.getActionDecision(ModelAuthorizationAction.READ.getUrl(), null); + if (globalDecision == AuthorizationDecisionType.DENY) { + // shortcut + throw new AuthorizationException("Access denied"); + } + if (globalDecision == AuthorizationDecisionType.ALLOW && securityConstraints.hasNoItemDecisions()) { + // shortcut, nothing to do + } else { + applySecurityConstraints((List)object.getValue().getItems(), securityConstraints, globalDecision); + if (object.isEmpty()) { + // let's make it explicit + throw new AuthorizationException("Access denied"); + } + } + + } catch (SecurityViolationException | SchemaException e) { + result.recordFatalError(e); + throw e; + } + + ObjectTemplateType objectTemplateType; + try { + objectTemplateType = determineObjectTemplate(object.getCompileTimeClass(), AuthorizationPhaseType.REQUEST, result); + } catch (ConfigurationException | ObjectNotFoundException e) { + result.recordFatalError(e); + throw e; + } + applyObjectTemplateToObject(object, objectTemplateType, result); + + result.computeStatus(); + } + private void validateObject(PrismObject object, GetOperationOptions options, OperationResult result) { try { if (InternalsConfig.readEncryptionChecks) { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandler.java index 512cd8d1ef2..6a18b6450b4 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandler.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -107,9 +107,9 @@ public String evaluateExpression(ShadowType shadow, ExpressionType expressionTyp ExpressionVariables variables = getDefaultXPathVariables(null, shadow, resource); - PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME, + PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition<>(ExpressionConstants.OUTPUT_ELMENT_NAME, DOMUtil.XSD_STRING, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, outputDefinition, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task, result); @@ -139,9 +139,9 @@ public boolean evaluateConfirmationExpression(UserType user, ShadowType shadow, ExpressionVariables variables = getDefaultXPathVariables(user, shadow, resource); String shortDesc = "confirmation expression for "+resource.asPrismObject(); - PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME, + PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition<>(ExpressionConstants.OUTPUT_ELMENT_NAME, DOMUtil.XSD_BOOLEAN, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, outputDefinition, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task, result); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java index 8cbe34cd295..a7cac583e96 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java @@ -1048,7 +1048,7 @@ public void recompute(Class type, String oid) throws Sc } @Override - public PrismObject findShadowOwner(String accountOid) throws ObjectNotFoundException, SecurityViolationException, SchemaException { + public PrismObject findShadowOwner(String accountOid) throws ObjectNotFoundException, SecurityViolationException, SchemaException, ConfigurationException { return modelService.findShadowOwner(accountOid, getCurrentTask(), getCurrentResult()); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/importer/ObjectImporter.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/importer/ObjectImporter.java index d2efc26fec0..a560033b1db 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/importer/ObjectImporter.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/importer/ObjectImporter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -399,7 +399,7 @@ protected void validateWithDynamicSchemas(PrismObject PrismObject resource = (PrismObject)object; ResourceType resourceType = resource.asObjectable(); - PrismContainer configurationContainer = ResourceTypeUtil.getConfigurationContainer(resource); + PrismContainer configurationContainer = ResourceTypeUtil.getConfigurationContainer(resource); if (configurationContainer == null || configurationContainer.isEmpty()) { // Nothing to check result.recordWarning("The resource has no configuration"); @@ -445,7 +445,7 @@ protected void validateWithDynamicSchemas(PrismObject return; } QName configContainerQName = new QName(connectorType.getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart()); - PrismContainerDefinition configContainerDef = connectorSchema.findContainerDefinitionByElementName(configContainerQName); + PrismContainerDefinition configContainerDef = connectorSchema.findContainerDefinitionByElementName(configContainerQName); if (configContainerDef == null) { result.recordFatalError("Definition of configuration container " + configContainerQName + " not found in the schema of of " + connector); return; diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentEvaluator.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentEvaluator.java index 12f244450c1..058d20315f4 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentEvaluator.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import com.evolveum.midpoint.prism.Item; import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismContainerable; import com.evolveum.midpoint.prism.PrismContext; @@ -199,7 +200,7 @@ public void setMappingEvaluationHelper(MappingEvaluationHelper mappingEvaluation this.mappingEvaluationHelper = mappingEvaluationHelper; } - public EvaluatedAssignmentImpl evaluate(ItemDeltaItem> assignmentIdi, + public EvaluatedAssignmentImpl evaluate(ItemDeltaItem,PrismContainerDefinition> assignmentIdi, boolean evaluateOld, ObjectType source, String sourceDescription, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException { assertSource(source, assignmentIdi); @@ -229,7 +230,7 @@ private void evaluateAssignment(EvaluatedAssignmentImpl evalAssignment, Assig LOGGER.trace("Evaluate assignment {} (eval constr: {}, mode: {})", new Object[]{ assignmentPath, assignmentPathSegment.isEvaluateConstructions(), mode}); - ItemDeltaItem> assignmentIdi = assignmentPathSegment.getAssignmentIdi(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = assignmentPathSegment.getAssignmentIdi(); AssignmentType assignmentType = LensUtil.getAssignmentType(assignmentIdi, evaluateOld); checkSchema(assignmentType, sourceDescription); @@ -474,7 +475,7 @@ private boolean evaluateAbstractRole(EvaluatedAssignmentImpl assignment, Assi if (!isApplicable(roleInducement.getFocusType(), roleType)){ continue; } - ItemDeltaItem> roleInducementIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> roleInducementIdi = new ItemDeltaItem<>(); roleInducementIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(roleInducement)); roleInducementIdi.recompute(); AssignmentPathSegment roleAssignmentPathSegment = new AssignmentPathSegment(roleInducementIdi, null); @@ -511,7 +512,7 @@ private boolean evaluateAbstractRole(EvaluatedAssignmentImpl assignment, Assi LOGGER.trace("E{}: follow assignment {} in {}", new Object[]{evaluationOrder, dumpAssignment(roleAssignment), roleType}); } - ItemDeltaItem> roleAssignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> roleAssignmentIdi = new ItemDeltaItem<>(); roleAssignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(roleAssignment)); roleAssignmentIdi.recompute(); AssignmentPathSegment roleAssignmentPathSegment = new AssignmentPathSegment(roleAssignmentIdi, null); @@ -581,7 +582,7 @@ private void assertSource(ObjectType source, EvaluatedAssignment assignment) } } - private void assertSource(ObjectType source, ItemDeltaItem> assignmentIdi) { + private void assertSource(ObjectType source, ItemDeltaItem,PrismContainerDefinition> assignmentIdi) { if (source == null) { throw new IllegalArgumentException("Source cannot be null (while evaluating assignment "+assignmentIdi.getAnyItem()+")"); } @@ -601,7 +602,7 @@ private void checkSchema(AssignmentType assignmentType, String sourceDescription if (extensionContainer.getDefinition() == null) { throw new SchemaException("Extension does not have a definition in assignment "+assignmentType+" in "+sourceDescription); } - for (Item item: extensionContainer.getValue().getItems()) { + for (Item item: extensionContainer.getValue().getItems()) { if (item == null) { throw new SchemaException("Null item in extension in assignment "+assignmentType+" in "+sourceDescription); } @@ -622,7 +623,7 @@ public PrismValueDeltaSetTriple> evaluateMappingAsCo } else { desc = "condition in assignment in " + source; } - Mapping> mapping = mappingFactory.createMapping(conditionType, + Mapping,PrismPropertyDefinition> mapping = mappingFactory.createMapping(conditionType, desc); mapping.addVariableDefinition(ExpressionConstants.VAR_USER, focusOdo); @@ -635,12 +636,12 @@ public PrismValueDeltaSetTriple> evaluateMappingAsCo LensUtil.addAssignmentPathVariables(mapping, assignmentPathVariables); - ItemDefinition outputDefinition = new PrismPropertyDefinition(CONDITION_OUTPUT_NAME, DOMUtil.XSD_BOOLEAN, prismContext); + PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(CONDITION_OUTPUT_NAME, DOMUtil.XSD_BOOLEAN, prismContext); mapping.setDefaultTargetDefinition(outputDefinition); LensUtil.evaluateMapping(mapping, lensContext, task, result); - return (PrismValueDeltaSetTriple>) mapping.getOutputTriple(); + return mapping.getOutputTriple(); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPath.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPath.java index 904cbed6707..7d299af0581 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPath.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import java.util.List; import com.evolveum.midpoint.model.common.expression.ItemDeltaItem; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; @@ -38,7 +39,7 @@ public AssignmentPath() { segments = createNewSegments(); } - AssignmentPath(ItemDeltaItem> assignmentIdi) { + AssignmentPath(ItemDeltaItem,PrismContainerDefinition> assignmentIdi) { this.segments = createNewSegments(); segments.add(new AssignmentPathSegment(assignmentIdi, null)); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPathSegment.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPathSegment.java index 1e5d7529680..695a545dd0e 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPathSegment.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPathSegment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.evolveum.midpoint.model.common.expression.ItemDeltaItem; import com.evolveum.midpoint.prism.Item; import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.util.DebugDumpable; @@ -33,7 +34,7 @@ */ public class AssignmentPathSegment implements DebugDumpable { - private ItemDeltaItem> assignmentIdi; + private ItemDeltaItem,PrismContainerDefinition> assignmentIdi; private ObjectType target; private ObjectType source; private boolean evaluateConstructions = true; @@ -41,17 +42,17 @@ public class AssignmentPathSegment implements DebugDumpable { private int evaluationOrder; private ObjectType varThisObject; - AssignmentPathSegment(ItemDeltaItem> assignmentIdi, ObjectType target) { + AssignmentPathSegment(ItemDeltaItem,PrismContainerDefinition> assignmentIdi, ObjectType target) { super(); this.assignmentIdi = assignmentIdi; this.target = target; } - public ItemDeltaItem> getAssignmentIdi() { + public ItemDeltaItem,PrismContainerDefinition> getAssignmentIdi() { return assignmentIdi; } - public void setAssignmentIdi(ItemDeltaItem> assignmentIdi) { + public void setAssignmentIdi(ItemDeltaItem,PrismContainerDefinition> assignmentIdi) { this.assignmentIdi = assignmentIdi; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPathVariables.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPathVariables.java index 16ba33e1d4d..e5d2316e9e0 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPathVariables.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentPathVariables.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2014 Evolveum + * Copyright (c) 2014-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.evolveum.midpoint.model.impl.lens; import com.evolveum.midpoint.model.common.expression.ItemDeltaItem; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; @@ -27,41 +28,41 @@ */ public class AssignmentPathVariables { - private ItemDeltaItem> magicAssignment; - private ItemDeltaItem> immediateAssignment; - private ItemDeltaItem> thisAssignment; - private ItemDeltaItem> focusAssignment; + private ItemDeltaItem,PrismContainerDefinition> magicAssignment; + private ItemDeltaItem,PrismContainerDefinition> immediateAssignment; + private ItemDeltaItem,PrismContainerDefinition> thisAssignment; + private ItemDeltaItem,PrismContainerDefinition> focusAssignment; private PrismObject immediateRole; - public ItemDeltaItem> getMagicAssignment() { + public ItemDeltaItem,PrismContainerDefinition> getMagicAssignment() { return magicAssignment; } - public void setMagicAssignment(ItemDeltaItem> magicAssignment) { + public void setMagicAssignment(ItemDeltaItem,PrismContainerDefinition> magicAssignment) { this.magicAssignment = magicAssignment; } - public ItemDeltaItem> getImmediateAssignment() { + public ItemDeltaItem,PrismContainerDefinition> getImmediateAssignment() { return immediateAssignment; } - public void setImmediateAssignment(ItemDeltaItem> immediateAssignment) { + public void setImmediateAssignment(ItemDeltaItem,PrismContainerDefinition> immediateAssignment) { this.immediateAssignment = immediateAssignment; } - public ItemDeltaItem> getThisAssignment() { + public ItemDeltaItem,PrismContainerDefinition> getThisAssignment() { return thisAssignment; } - public void setThisAssignment(ItemDeltaItem> thisAssignment) { + public void setThisAssignment(ItemDeltaItem,PrismContainerDefinition> thisAssignment) { this.thisAssignment = thisAssignment; } - public ItemDeltaItem> getFocusAssignment() { + public ItemDeltaItem,PrismContainerDefinition> getFocusAssignment() { return focusAssignment; } - public void setFocusAssignment(ItemDeltaItem> focusAssignment) { + public void setFocusAssignment(ItemDeltaItem,PrismContainerDefinition> focusAssignment) { this.focusAssignment = focusAssignment; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java index 6a2c64b4a06..20b68dee048 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1258,11 +1258,11 @@ private void evaluateScriptArgument(ProvisioningScriptArgumentType argument, Exp QName FAKE_SCRIPT_ARGUMENT_NAME = new QName(SchemaConstants.NS_C, "arg"); - PrismPropertyDefinition scriptArgumentDefinition = new PrismPropertyDefinition(FAKE_SCRIPT_ARGUMENT_NAME, + PrismPropertyDefinition scriptArgumentDefinition = new PrismPropertyDefinition<>(FAKE_SCRIPT_ARGUMENT_NAME, DOMUtil.XSD_STRING, prismContext); String shortDesc = "Provisioning script argument expression"; - Expression> expression = expressionFactory.makeExpression(argument, scriptArgumentDefinition, shortDesc, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(argument, scriptArgumentDefinition, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task, result); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Clockwork.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Clockwork.java index f14a1b6954a..075814458a0 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Clockwork.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Clockwork.java @@ -526,7 +526,7 @@ private

boolean isSignificant(ObjectDelta

delta) { if (delta.isAdd() || delta.isDelete()) { return true; } - Collection> attrDeltas = delta.findItemDeltasSubPath(new ItemPath(ShadowType.F_ATTRIBUTES)); + Collection> attrDeltas = delta.findItemDeltasSubPath(new ItemPath(ShadowType.F_ATTRIBUTES)); if (attrDeltas != null && !attrDeltas.isEmpty()) { return true; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Construction.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Construction.java index 018f498bfb3..9b5891facf0 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Construction.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Construction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,8 +95,8 @@ public class Construction implements DebugDumpable, Seriali private ResourceType resource; private ObjectResolver objectResolver; private MappingFactory mappingFactory; - private Collection>> attributeMappings; - private Collection>> associationMappings; + private Collection,? extends PrismPropertyDefinition>> attributeMappings; + private Collection,PrismContainerDefinition>> associationMappings; private RefinedObjectClassDefinition refinedObjectClassDefinition; private AssignmentPathVariables assignmentPathVariables = null; private PrismContext prismContext; @@ -201,15 +201,15 @@ public Object getDescription() { return constructionType.getDescription(); } - public Collection>> getAttributeMappings() { + public Collection,? extends PrismPropertyDefinition>> getAttributeMappings() { if (attributeMappings == null) { - attributeMappings = new ArrayList>>(); + attributeMappings = new ArrayList<>(); } return attributeMappings; } - public Mapping> getAttributeMapping(QName attrName) { - for (Mapping> myVc : getAttributeMappings()) { + public Mapping,? extends PrismPropertyDefinition> getAttributeMapping(QName attrName) { + for (Mapping,? extends PrismPropertyDefinition> myVc : getAttributeMappings()) { if (myVc.getItemName().equals(attrName)) { return myVc; } @@ -217,12 +217,12 @@ public Mapping> getAttributeMapping(QName attrNa return null; } - public void addAttributeMapping(Mapping> mapping) { + public void addAttributeMapping(Mapping,? extends PrismPropertyDefinition> mapping) { getAttributeMappings().add(mapping); } public boolean containsAttributeMapping(QName attributeName) { - for (Mapping mapping: getAttributeMappings()) { + for (Mapping mapping: getAttributeMappings()) { if (attributeName.equals(mapping.getItemName())) { return true; } @@ -230,19 +230,19 @@ public boolean containsAttributeMapping(QName attributeName) { return false; } - public Collection>> getAssociationMappings() { + public Collection,PrismContainerDefinition>> getAssociationMappings() { if (associationMappings == null) { - associationMappings = new ArrayList>>(); + associationMappings = new ArrayList,PrismContainerDefinition>>(); } return associationMappings; } - public void addAssociationMapping(Mapping> mapping) { + public void addAssociationMapping(Mapping,PrismContainerDefinition> mapping) { getAssociationMappings().add(mapping); } public boolean containsAssociationMapping(QName assocName) { - for (Mapping mapping: getAssociationMappings()) { + for (Mapping mapping: getAssociationMappings()) { if (assocName.equals(mapping.getItemName())) { return true; } @@ -319,7 +319,7 @@ private void evaluateKindIntent(OperationResult result) throws SchemaException, } private void evaluateAttributes(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { - attributeMappings = new ArrayList>>(); + attributeMappings = new ArrayList<>(); // LOGGER.trace("Assignments used for account construction for {} ({}): {}", new Object[]{this.resource, // assignments.size(), assignments}); for (ResourceAttributeDefinitionType attribudeDefinitionType : constructionType.getAttribute()) { @@ -334,14 +334,14 @@ private void evaluateAttributes(Task task, OperationResult result) throws Expres if (outboundMappingType == null) { throw new SchemaException("No outbound section in definition of attribute "+attrName+" in account construction in "+source); } - Mapping> attributeMapping = evaluateAttribute(attribudeDefinitionType, task, result); + Mapping,? extends PrismPropertyDefinition> attributeMapping = evaluateAttribute(attribudeDefinitionType, task, result); if (attributeMapping != null) { attributeMappings.add(attributeMapping); } } } - private Mapping> evaluateAttribute(ResourceAttributeDefinitionType attribudeDefinitionType, + private Mapping,ResourceAttributeDefinition> evaluateAttribute(ResourceAttributeDefinitionType attribudeDefinitionType, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { QName attrName = ItemPathUtil.getOnlySegmentQName(attribudeDefinitionType.getRef()); @@ -355,14 +355,14 @@ private Mapping> evaluateAttribute(ResourceAttri if (outboundMappingType == null) { throw new SchemaException("No outbound section in definition of attribute "+attrName+" in account construction in "+source); } - PrismPropertyDefinition outputDefinition = findAttributeDefinition(attrName); + ResourceAttributeDefinition outputDefinition = findAttributeDefinition(attrName); if (outputDefinition == null) { throw new SchemaException("Attribute "+attrName+" not found in schema for account type "+getIntent()+", "+ObjectTypeUtil.toShortString(getResource(result))+" as definied in "+ObjectTypeUtil.toShortString(source), attrName); } - Mapping> mapping = mappingFactory.createMapping(outboundMappingType, + Mapping,ResourceAttributeDefinition> mapping = mappingFactory.createMapping(outboundMappingType, "for attribute " + PrettyPrinter.prettyPrint(attrName) + " in "+source); - Mapping> evaluatedMapping = evaluateMapping(mapping, attrName, outputDefinition, null, task, result); + Mapping,ResourceAttributeDefinition> evaluatedMapping = evaluateMapping(mapping, attrName, outputDefinition, null, task, result); LOGGER.trace("Evaluated mapping for attribute "+attrName+": "+evaluatedMapping); return evaluatedMapping; @@ -373,7 +373,7 @@ private ResourceAttributeDefinition findAttributeDefinition(QName attributeName) } public boolean hasValueForAttribute(QName attributeName) { - for (Mapping> attributeConstruction: attributeMappings) { + for (Mapping,? extends PrismPropertyDefinition> attributeConstruction: attributeMappings) { if (attributeName.equals(attributeConstruction.getItemName())) { PrismValueDeltaSetTriple> outputTriple = attributeConstruction.getOutputTriple(); if (outputTriple != null && !outputTriple.isEmpty()) { @@ -385,7 +385,7 @@ public boolean hasValueForAttribute(QName attributeName) { } private void evaluateAssociations(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { - associationMappings = new ArrayList>>(); + associationMappings = new ArrayList<>(); for (ResourceObjectAssociationType associationDefinitionType : constructionType.getAssociation()) { QName assocName = ItemPathUtil.getOnlySegmentQName(associationDefinitionType.getRef()); if (assocName == null) { @@ -395,14 +395,14 @@ private void evaluateAssociations(Task task, OperationResult result) throws Expr if (outboundMappingType == null) { throw new SchemaException("No outbound section in definition of association "+assocName+" in construction in "+source); } - Mapping> assocMapping = evaluateAssociation(associationDefinitionType, task, result); + Mapping,PrismContainerDefinition> assocMapping = evaluateAssociation(associationDefinitionType, task, result); if (assocMapping != null) { associationMappings.add(assocMapping); } } } - private Mapping> evaluateAssociation(ResourceObjectAssociationType associationDefinitionType, + private Mapping,PrismContainerDefinition> evaluateAssociation(ResourceObjectAssociationType associationDefinitionType, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { QName assocName = ItemPathUtil.getOnlySegmentQName(associationDefinitionType.getRef()); @@ -414,7 +414,7 @@ private Mapping> evaluateAssociation( throw new SchemaException("No outbound section in definition of association "+assocName+" in construction in "+source); } PrismContainerDefinition outputDefinition = getAssociationContainerDefinition(); - Mapping> mapping = mappingFactory.createMapping(outboundMappingType, + Mapping,PrismContainerDefinition> mapping = mappingFactory.createMapping(outboundMappingType, "for association " + PrettyPrinter.prettyPrint(assocName) + " in " + source); mapping.setOriginType(OriginType.ASSIGNMENTS); mapping.setOriginObject(source); @@ -425,14 +425,14 @@ private Mapping> evaluateAssociation( +" in construction in "+source); } - Mapping> evaluatedMapping = evaluateMapping(mapping, assocName, outputDefinition, + Mapping,PrismContainerDefinition> evaluatedMapping = evaluateMapping(mapping, assocName, outputDefinition, rAssocDef.getAssociationTarget(), task, result); LOGGER.trace("Evaluated mapping for association "+assocName+": "+evaluatedMapping); return evaluatedMapping; } - private Mapping evaluateMapping(Mapping mapping, QName mappingQName, ItemDefinition outputDefinition, + private Mapping evaluateMapping(Mapping mapping, QName mappingQName, D outputDefinition, RefinedObjectClassDefinition assocTargetObjectClassDefinition, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedAssignmentImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedAssignmentImpl.java index 89fbaef2178..f48250abe2f 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedAssignmentImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedAssignmentImpl.java @@ -22,8 +22,10 @@ import com.evolveum.midpoint.model.common.expression.ItemDeltaItem; import com.evolveum.midpoint.model.common.expression.ObjectDeltaObject; import com.evolveum.midpoint.model.common.mapping.Mapping; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.DeltaSetTriple; @@ -53,12 +55,12 @@ public class EvaluatedAssignmentImpl implements EvaluatedAs private static final Trace LOGGER = TraceManager.getTrace(EvaluatedAssignmentImpl.class); - private ItemDeltaItem> assignmentIdi; + private ItemDeltaItem,PrismContainerDefinition> assignmentIdi; private DeltaSetTriple> constructions; private DeltaSetTriple roles; private Collection orgRefVals; private Collection authorizations; - private Collection>> focusMappings; + private Collection,? extends PrismPropertyDefinition>> focusMappings; private PrismObject target; private boolean isValid; private boolean forceRecon; // used also to force recomputation of parentOrgRefs @@ -71,11 +73,11 @@ public EvaluatedAssignmentImpl() { focusMappings = new ArrayList<>(); } - public ItemDeltaItem> getAssignmentIdi() { + public ItemDeltaItem,PrismContainerDefinition> getAssignmentIdi() { return assignmentIdi; } - public void setAssignmentIdi(ItemDeltaItem> assignmentIdi) { + public void setAssignmentIdi(ItemDeltaItem,PrismContainerDefinition> assignmentIdi) { this.assignmentIdi = assignmentIdi; } @@ -141,11 +143,11 @@ public void addAuthorization(Authorization authorization) { authorizations.add(authorization); } - public Collection>> getFocusMappings() { + public Collection,? extends PrismPropertyDefinition>> getFocusMappings() { return focusMappings; } - public void addFocusMapping(Mapping> focusMapping) { + public void addFocusMapping(Mapping,? extends PrismPropertyDefinition> focusMapping) { this.focusMappings.add(focusMapping); } @@ -241,7 +243,7 @@ public String debugDump(int indent) { if (!focusMappings.isEmpty()) { sb.append("\n"); DebugUtil.debugDumpLabel(sb, "Focus Mappings", indent+1); - for (Mapping> mapping: focusMappings) { + for (Mapping,? extends PrismPropertyDefinition> mapping: focusMappings) { sb.append("\n"); DebugUtil.indentDebugDump(sb, indent+2); sb.append(mapping.toString()); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ItemValueWithOrigin.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ItemValueWithOrigin.java index 69acb6d796d..5be9a32ced9 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ItemValueWithOrigin.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ItemValueWithOrigin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import java.util.Collection; import com.evolveum.midpoint.model.common.mapping.Mapping; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.delta.DeltaSetTriple; @@ -30,14 +31,14 @@ * @author semancik * */ -public class ItemValueWithOrigin implements DebugDumpable { +public class ItemValueWithOrigin implements DebugDumpable { private V itemValue; - private Mapping mapping; + private Mapping mapping; private Construction construction; public ItemValueWithOrigin(V propertyValue, - Mapping mapping, Construction accountConstruction) { + Mapping mapping, Construction accountConstruction) { super(); this.itemValue = propertyValue; this.mapping = mapping; @@ -59,7 +60,7 @@ public void setItemValue(V value) { this.itemValue = value; } - public Mapping getMapping() { + public Mapping getMapping() { return mapping; } @@ -74,13 +75,13 @@ public boolean equalsRealValue(V pvalue) { return itemValue.equalsRealValue(pvalue); } - public ItemValueWithOrigin clone() { - ItemValueWithOrigin clone = new ItemValueWithOrigin(itemValue, mapping, construction); + public ItemValueWithOrigin clone() { + ItemValueWithOrigin clone = new ItemValueWithOrigin<>(itemValue, mapping, construction); copyValues(clone); return clone; } - protected void copyValues(ItemValueWithOrigin clone) { + protected void copyValues(ItemValueWithOrigin clone) { if (this.itemValue != null) { clone.itemValue = (V) this.itemValue.clone(); } @@ -90,25 +91,25 @@ protected void copyValues(ItemValueWithOrigin clone) { clone.construction = this.construction; } - public static DeltaSetTriple> createOutputTriple(Mapping mapping) { + public static DeltaSetTriple> createOutputTriple(Mapping mapping) { PrismValueDeltaSetTriple outputTriple = mapping.getOutputTriple(); if (outputTriple == null) { return null; } - Collection> zeroIvwoSet = convertSet(outputTriple.getZeroSet(), mapping); - Collection> plusIvwoSet = convertSet(outputTriple.getPlusSet(), mapping); - Collection> minusIvwoSet = convertSet(outputTriple.getMinusSet(), mapping); - DeltaSetTriple> ivwoTriple = new DeltaSetTriple>(zeroIvwoSet, plusIvwoSet, minusIvwoSet); + Collection> zeroIvwoSet = convertSet(outputTriple.getZeroSet(), mapping); + Collection> plusIvwoSet = convertSet(outputTriple.getPlusSet(), mapping); + Collection> minusIvwoSet = convertSet(outputTriple.getMinusSet(), mapping); + DeltaSetTriple> ivwoTriple = new DeltaSetTriple<>(zeroIvwoSet, plusIvwoSet, minusIvwoSet); return ivwoTriple; } - private static Collection> convertSet(Collection valueSet, Mapping mapping) { + private static Collection> convertSet(Collection valueSet, Mapping mapping) { if (valueSet == null) { return null; } - Collection> ivwoSet = new ArrayList>(valueSet.size()); + Collection> ivwoSet = new ArrayList<>(valueSet.size()); for (V value: valueSet) { - ItemValueWithOrigin ivwo = new ItemValueWithOrigin(value, mapping, null); + ItemValueWithOrigin ivwo = new ItemValueWithOrigin<>(value, mapping, null); ivwoSet.add(ivwo); } return ivwoSet; diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensDebugListener.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensDebugListener.java index 14ccb2eaebb..f8f350969db 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensDebugListener.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensDebugListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public interface LensDebugListener { /** * May be used to gather profiling data, etc. */ - public void afterMappingEvaluation(LensContext context, Mapping evaluatedMapping); + public void afterMappingEvaluation(LensContext context, Mapping evaluatedMapping); // /** // * For all scripts expect for mappings. diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java index d76b7d07a1f..54c84f42be7 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -244,7 +244,7 @@ public void addSecondaryDelta(ObjectDelta delta) throws SchemaException { } } - public void swallowToPrimaryDelta(ItemDelta itemDelta) throws SchemaException { + public void swallowToPrimaryDelta(ItemDelta itemDelta) throws SchemaException { if (primaryDelta == null) { primaryDelta = new ObjectDelta(getObjectTypeClass(), ChangeType.MODIFY, getPrismContext()); primaryDelta.setOid(oid); @@ -252,7 +252,7 @@ public void swallowToPrimaryDelta(ItemDelta itemDelta) throws SchemaException primaryDelta.swallow(itemDelta); } - public void swallowToSecondaryDelta(ItemDelta itemDelta) throws SchemaException { + public void swallowToSecondaryDelta(ItemDelta itemDelta) throws SchemaException { if (secondaryDelta == null) { secondaryDelta = new ObjectDelta(getObjectTypeClass(), ChangeType.MODIFY, getPrismContext()); secondaryDelta.setOid(oid); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensFocusContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensFocusContext.java index 7c8b97e6cee..c18ed499a41 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensFocusContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensFocusContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -157,7 +157,7 @@ public void setProjectionWaveSecondaryDelta(ObjectDelta secondaryDelta) { this.secondaryDeltas.set(getProjectionWave(), secondaryDelta); } - public void swallowToProjectionWaveSecondaryDelta(ItemDelta propDelta) throws SchemaException { + public void swallowToProjectionWaveSecondaryDelta(ItemDelta propDelta) throws SchemaException { ObjectDelta secondaryDelta = getProjectionWaveSecondaryDelta(); @@ -172,7 +172,7 @@ public void swallowToProjectionWaveSecondaryDelta(ItemDelta propDelta) throws secondaryDelta.swallow(propDelta); } - public void swallowToSecondaryDelta(ItemDelta propDelta) throws SchemaException { + public void swallowToSecondaryDelta(ItemDelta propDelta) throws SchemaException { ObjectDelta secondaryDelta = getSecondaryDelta(0); if (secondaryDelta == null) { secondaryDelta = new ObjectDelta(getObjectTypeClass(), ChangeType.MODIFY, getPrismContext()); @@ -185,7 +185,7 @@ public void swallowToSecondaryDelta(ItemDelta propDelta) throws SchemaExcepti secondaryDelta.swallow(propDelta); } - public boolean alreadyHasDelta(ItemDelta itemDelta) { + public boolean alreadyHasDelta(ItemDelta itemDelta) { ObjectDelta primaryDelta = getPrimaryDelta(); if (primaryDelta != null && primaryDelta.containsModification(itemDelta)) { return true; @@ -272,10 +272,10 @@ public void clearIntermediateResults() { // Nothing to do } - public void applyProjectionWaveSecondaryDeltas(Collection> itemDeltas) throws SchemaException { + public void applyProjectionWaveSecondaryDeltas(Collection> itemDeltas) throws SchemaException { ObjectDelta wavePrimaryDelta = getProjectionWavePrimaryDelta(); ObjectDelta waveSecondaryDelta = getProjectionWaveSecondaryDelta(); - for (ItemDelta itemDelta: itemDeltas) { + for (ItemDelta itemDelta: itemDeltas) { if (itemDelta != null && !itemDelta.isEmpty()) { if (wavePrimaryDelta == null || !wavePrimaryDelta.containsModification(itemDelta)) { if (waveSecondaryDelta == null) { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java index e36c1f608fb..cb11a874a7d 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -168,8 +168,8 @@ public class LensProjectionContext extends LensElementContext implem private transient Collection dependencies = null; - private transient Map>>> squeezedAttributes; - private transient Map>>> squeezedAssociations; + private transient Map,PrismPropertyDefinition>>> squeezedAttributes; + private transient Map,PrismContainerDefinition>>> squeezedAssociations; // Cached copy, to avoid constructing it over and over again private transient PrismObjectDefinition shadowDefinition = null; @@ -464,20 +464,20 @@ public void setOutboundConstruction(Construction outboundConstruction) { this.outboundConstruction = outboundConstruction; } - public Map>>> getSqueezedAttributes() { + public Map,PrismPropertyDefinition>>> getSqueezedAttributes() { return squeezedAttributes; } - public void setSqueezedAttributes(Map>>> squeezedAttributes) { + public void setSqueezedAttributes(Map,PrismPropertyDefinition>>> squeezedAttributes) { this.squeezedAttributes = squeezedAttributes; } - public Map>>> getSqueezedAssociations() { + public Map,PrismContainerDefinition>>> getSqueezedAssociations() { return squeezedAssociations; } public void setSqueezedAssociations( - Map>>> squeezedAssociations) { + Map,PrismContainerDefinition>>> squeezedAssociations) { this.squeezedAssociations = squeezedAssociations; } @@ -856,19 +856,19 @@ protected void copyValues(LensProjectionContext clone, LensContext>>> cloneSqueezedAttributes() { + private Map,PrismPropertyDefinition>>> cloneSqueezedAttributes() { if (squeezedAttributes == null) { return null; } - Map>>> clonedMap - = new HashMap>>>(); - Cloner>> cloner = new Cloner>>() { + Map,PrismPropertyDefinition>>> clonedMap + = new HashMap,PrismPropertyDefinition>>>(); + Cloner,PrismPropertyDefinition>> cloner = new Cloner,PrismPropertyDefinition>>() { @Override - public ItemValueWithOrigin> clone(ItemValueWithOrigin> original) { + public ItemValueWithOrigin,PrismPropertyDefinition> clone(ItemValueWithOrigin,PrismPropertyDefinition> original) { return original.clone(); } }; - for (Entry>>> entry: squeezedAttributes.entrySet()) { + for (Entry,PrismPropertyDefinition>>> entry: squeezedAttributes.entrySet()) { clonedMap.put(entry.getKey(), entry.getValue().clone(cloner)); } return clonedMap; diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java index e1ebb35ae7f..f221f95e5e8 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -197,15 +197,15 @@ public static LensProjectionContext createAccountContext( * * filterExistingValues: if true, then values that already exist in the item are not added (and those that don't exist are not removed) */ - public static > ItemDelta consolidateTripleToDelta(ItemPath itemPath, - DeltaSetTriple triple, ItemDefinition itemDefinition, - ItemDelta aprioriItemDelta, PrismContainer itemContainer, ValueMatcher valueMatcher, Comparator comparator, + public static > ItemDelta consolidateTripleToDelta(ItemPath itemPath, + DeltaSetTriple triple, D itemDefinition, + ItemDelta aprioriItemDelta, PrismContainer itemContainer, ValueMatcher valueMatcher, Comparator comparator, boolean addUnchangedValues, boolean filterExistingValues, boolean isExclusiveStrong, String contextDescription, boolean applyWeak) throws ExpressionEvaluationException, PolicyViolationException, SchemaException { - ItemDelta itemDelta = itemDefinition.createEmptyDelta(itemPath); + ItemDelta itemDelta = itemDefinition.createEmptyDelta(itemPath); - Item itemExisting = null; + Item itemExisting = null; if (itemContainer != null) { itemExisting = itemContainer.findItem(itemPath); } @@ -241,11 +241,11 @@ public void visit(I pvwo) { // Check what to do with the value using the usual "triple routine". It means that if a value is // in zero set than we need no delta, plus set means add delta and minus set means delete delta. // The first set that the value is present determines the result. - Collection> zeroPvwos = + Collection> zeroPvwos = collectPvwosFromSet(value, triple.getZeroSet()); - Collection> plusPvwos = + Collection> plusPvwos = collectPvwosFromSet(value, triple.getPlusSet()); - Collection> minusPvwos = + Collection> minusPvwos = collectPvwosFromSet(value, triple.getMinusSet()); if (LOGGER.isTraceEnabled()) { @@ -255,8 +255,8 @@ public void visit(I pvwo) { boolean zeroHasStrong = false; if (!zeroPvwos.isEmpty()) { - for (ItemValueWithOrigin pvwo : zeroPvwos) { - Mapping mapping = pvwo.getMapping(); + for (ItemValueWithOrigin pvwo : zeroPvwos) { + Mapping mapping = pvwo.getMapping(); if (mapping.getStrength() == MappingStrengthType.STRONG) { zeroHasStrong = true; } @@ -273,8 +273,8 @@ public void visit(I pvwo) { continue; } - Mapping exclusiveMapping = null; - Collection> pvwosToAdd = null; + Mapping exclusiveMapping = null; + Collection> pvwosToAdd = null; if (addUnchangedValues) { pvwosToAdd = MiscUtil.union(zeroPvwos, plusPvwos); } else { @@ -286,8 +286,8 @@ public void visit(I pvwo) { boolean hasStrong = false; // There may be several mappings that imply that value. So check them all for // exclusions and strength - for (ItemValueWithOrigin pvwoToAdd : pvwosToAdd) { - Mapping mapping = pvwoToAdd.getMapping(); + for (ItemValueWithOrigin pvwoToAdd : pvwosToAdd) { + Mapping mapping = pvwoToAdd.getMapping(); if (mapping.getStrength() != MappingStrengthType.WEAK) { weakOnly = false; } @@ -344,8 +344,8 @@ public void visit(I pvwo) { boolean hasAuthoritative = false; // There may be several mappings that imply that value. So check them all for // exclusions and strength - for (ItemValueWithOrigin pvwo : minusPvwos) { - Mapping mapping = pvwo.getMapping(); + for (ItemValueWithOrigin pvwo : minusPvwos) { + Mapping mapping = pvwo.getMapping(); if (mapping.getStrength() != MappingStrengthType.WEAK) { weakOnly = false; } @@ -396,8 +396,8 @@ public void visit(I pvwo) { boolean hasAuthoritative = false; // There may be several mappings that imply that value. So check them all for // exclusions and strength - for (ItemValueWithOrigin pvwo : zeroPvwos) { - Mapping mapping = pvwo.getMapping(); + for (ItemValueWithOrigin pvwo : zeroPvwos) { + Mapping mapping = pvwo.getMapping(); if (mapping.getStrength() != MappingStrengthType.WEAK) { weakOnly = false; } @@ -420,13 +420,13 @@ public void visit(I pvwo) { } } - Item itemNew = null; + Item itemNew = null; if (itemContainer != null) { itemNew = itemContainer.findItem(itemPath); } if (!hasValue(itemNew, itemDelta)) { // The application of computed delta results in no value, apply weak mappings - Collection> nonNegativePvwos = triple.getNonNegativeValues(); + Collection> nonNegativePvwos = triple.getNonNegativeValues(); Collection valuesToAdd = addWeakValues(nonNegativePvwos, OriginType.ASSIGNMENTS, applyWeak); if (valuesToAdd.isEmpty()) { valuesToAdd = addWeakValues(nonNegativePvwos, OriginType.OUTBOUND, applyWeak); @@ -454,7 +454,7 @@ public static boolean isSyncChannel(String channel){ return (channel.equals(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI) || channel.equals(SchemaConstants.CHANGE_CHANNEL_RECON_URI)); } - private static boolean hasValue(Item item, ItemDelta itemDelta) throws SchemaException { + private static boolean hasValue(Item item, ItemDelta itemDelta) throws SchemaException { if (item == null || item.isEmpty()) { if (itemDelta != null && itemDelta.addsAnyValue()) { return true; @@ -465,16 +465,16 @@ private static boolean hasValue(Item item, ItemDelta clonedItem = item.clone(); + Item clonedItem = item.clone(); itemDelta.applyToMatchingPath(clonedItem); return !clonedItem.isEmpty(); } } } - private static Collection addWeakValues(Collection> pvwos, OriginType origin, boolean applyWeak) { + private static Collection addWeakValues(Collection> pvwos, OriginType origin, boolean applyWeak) { Collection values = new ArrayList(); - for (ItemValueWithOrigin pvwo: pvwos) { + for (ItemValueWithOrigin pvwo: pvwos) { if (pvwo.getMapping().getStrength() == MappingStrengthType.WEAK && applyWeak) { if (origin == null || origin == pvwo.getPropertyValue().getOriginType()) { values.add((V)pvwo.getPropertyValue().clone()); @@ -484,7 +484,7 @@ private static Collection addWeakValues(Collection boolean hasValue(Item existingUserItem, V newValue, ValueMatcher valueMatcher, Comparator comparator) { + private static boolean hasValue(Item existingUserItem, V newValue, ValueMatcher valueMatcher, Comparator comparator) { if (existingUserItem == null) { return false; } @@ -495,20 +495,20 @@ private static boolean hasValue(Item existingUserItem, } } - private static Collection collectAllValues(DeltaSetTriple> triple) { - Collection allValues = new HashSet(); + private static Collection collectAllValues(DeltaSetTriple> triple) { + Collection allValues = new HashSet<>(); collectAllValuesFromSet(allValues, triple.getZeroSet()); collectAllValuesFromSet(allValues, triple.getPlusSet()); collectAllValuesFromSet(allValues, triple.getMinusSet()); return allValues; } - private static void collectAllValuesFromSet(Collection allValues, - Collection> collection) { + private static void collectAllValuesFromSet(Collection allValues, + Collection> collection) { if (collection == null) { return; } - for (ItemValueWithOrigin pvwo : collection) { + for (ItemValueWithOrigin pvwo : collection) { V pval = pvwo.getPropertyValue(); if (!PrismValue.containsRealValue(allValues, pval)) { allValues.add(pval); @@ -516,10 +516,10 @@ private static void collectAllValuesFromSet(Collection } } - private static Collection> collectPvwosFromSet(V pvalue, - Collection> deltaSet) { - Collection> pvwos = new ArrayList>(); - for (ItemValueWithOrigin setPvwo : deltaSet) { + private static Collection> collectPvwosFromSet(V pvalue, + Collection> deltaSet) { + Collection> pvwos = new ArrayList<>(); + for (ItemValueWithOrigin setPvwo : deltaSet) { if (setPvwo.equalsRealValue(pvalue)) { pvwos.add(setPvwo); } @@ -564,8 +564,8 @@ public static void moveTriggers(LensProjectionContext pro } } - public static void evaluateMapping( - Mapping mapping, LensContext lensContext, Task task, OperationResult parentResult) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { + public static void evaluateMapping( + Mapping mapping, LensContext lensContext, Task task, OperationResult parentResult) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { ModelExpressionThreadLocalHolder.pushLensContext(lensContext); ModelExpressionThreadLocalHolder.pushCurrentResult(parentResult); ModelExpressionThreadLocalHolder.pushCurrentTask(task); @@ -665,7 +665,7 @@ public static Object getIterationVariableValue(LensProjectionContext accCtx) { propDelta.setValueToReplace(new PrismPropertyValue(accCtx.getIteration())); PrismProperty propNew = propDef.instantiate(); propNew.setRealValue(accCtx.getIteration()); - ItemDeltaItem> idi = new ItemDeltaItem>(propOld, propDelta, propNew); + ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(propOld, propDelta, propNew); return idi; } @@ -686,7 +686,7 @@ public static Object getIterationTokenVariableValue(LensProjectionContext accCtx propDelta.setValueToReplace(new PrismPropertyValue(accCtx.getIterationToken())); PrismProperty propNew = propDef.instantiate(); propNew.setRealValue(accCtx.getIterationToken()); - ItemDeltaItem> idi = new ItemDeltaItem>(propOld, propDelta, propNew); + ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(propOld, propDelta, propNew); return idi; } @@ -869,16 +869,16 @@ public static String formatIterationToken(LensContext } PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, DOMUtil.XSD_STRING, context.getPrismContext()); - Expression> expression = expressionFactory.makeExpression(tokenExpressionType, outputDefinition , "iteration token expression in "+accountContext.getHumanReadableName(), result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(tokenExpressionType, outputDefinition , "iteration token expression in "+accountContext.getHumanReadableName(), result); - Collection> sources = new ArrayList>(); + Collection> sources = new ArrayList<>(); PrismPropertyDefinition inputDefinition = new PrismPropertyDefinition(ExpressionConstants.VAR_ITERATION, DOMUtil.XSD_INT, context.getPrismContext()); inputDefinition.setMaxOccurs(1); PrismProperty input = inputDefinition.instantiate(); input.add(new PrismPropertyValue(iteration)); - ItemDeltaItem> idi = new ItemDeltaItem>(input); - Source> iterationSource = new Source>(idi, ExpressionConstants.VAR_ITERATION); + ItemDeltaItem,PrismPropertyDefinition> idi = new ItemDeltaItem<>(input); + Source,PrismPropertyDefinition> iterationSource = new Source<>(idi, ExpressionConstants.VAR_ITERATION); sources.add(iterationSource); ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, @@ -927,7 +927,7 @@ public static boolean evaluateIterationCondition(LensCont } PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME, DOMUtil.XSD_BOOLEAN, context.getPrismContext()); - Expression> expression = expressionFactory.makeExpression(expressionType, outputDefinition , desc, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, outputDefinition , desc, result); variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION, iteration); variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, iterationToken); @@ -959,7 +959,7 @@ public static boolean isValid(AssignmentType assignmentType, XMLGregorianCalenda return effectiveStatus == ActivationStatusType.ENABLED; } - public static Mapping createFocusMapping(final MappingFactory mappingFactory, + public static Mapping createFocusMapping(final MappingFactory mappingFactory, final LensContext context, final MappingType mappingType, ObjectType originObject, ObjectDeltaObject focusOdo, AssignmentPathVariables assignmentPathVariables, PrismObject configuration, XMLGregorianCalendar now, String contextDesc, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { @@ -978,12 +978,12 @@ public static Mapping createFocus iteration, iterationToken, configuration, now, contextDesc, result); } - public static Mapping createFocusMapping(final MappingFactory mappingFactory, + public static Mapping createFocusMapping(final MappingFactory mappingFactory, final LensContext context, final MappingType mappingType, ObjectType originObject, ObjectDeltaObject focusOdo, AssignmentPathVariables assignmentPathVariables, Integer iteration, String iterationToken, PrismObject configuration, XMLGregorianCalendar now, String contextDesc, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { - Mapping mapping = mappingFactory.createMapping(mappingType, contextDesc); + Mapping mapping = mappingFactory.createMapping(mappingType, contextDesc); if (!mapping.isApplicableToChannel(context.getChannel())) { return null; @@ -1010,7 +1010,7 @@ public static Mapping createFocus PrismObject focusNew = focusOdo.getNewObject(); if (focusNew != null) { - Item existingUserItem = (Item) focusNew.findItem(itemPath); + Item existingUserItem = (Item) focusNew.findItem(itemPath); if (existingUserItem != null && !existingUserItem.isEmpty() && mapping.getStrength() == MappingStrengthType.WEAK) { // This valueConstruction only applies if the property does not have a value yet. @@ -1080,9 +1080,9 @@ public static AssignmentPathVariables computeAssignmentPathVariables(AssignmentP Iterator iterator = assignmentPath.getSegments().iterator(); while (iterator.hasNext()) { AssignmentPathSegment segment = iterator.next(); - ItemDeltaItem> segmentAssignmentIdi = segment.getAssignmentIdi(); + ItemDeltaItem,PrismContainerDefinition> segmentAssignmentIdi = segment.getAssignmentIdi(); - ItemDeltaItem> magicAssignmentIdi; + ItemDeltaItem,PrismContainerDefinition> magicAssignmentIdi; // Magic assignment if (vars.getMagicAssignment() == null) { magicAssignmentIdi = segmentAssignmentIdi.clone(); @@ -1103,7 +1103,7 @@ public static AssignmentPathVariables computeAssignmentPathVariables(AssignmentP vars.setImmediateAssignment(vars.getThisAssignment()); // this assignment - ItemDeltaItem> thisAssignment = segmentAssignmentIdi.clone(); + ItemDeltaItem,PrismContainerDefinition> thisAssignment = segmentAssignmentIdi.clone(); vars.setThisAssignment(thisAssignment); if (iterator.hasNext() && segmentSource instanceof AbstractRoleType) { @@ -1112,13 +1112,13 @@ public static AssignmentPathVariables computeAssignmentPathVariables(AssignmentP } AssignmentPathSegment focusAssignmentSegment = assignmentPath.getFirstAssignmentSegment(); - ItemDeltaItem> focusAssignment = focusAssignmentSegment.getAssignmentIdi().clone(); + ItemDeltaItem,PrismContainerDefinition> focusAssignment = focusAssignmentSegment.getAssignmentIdi().clone(); vars.setFocusAssignment(focusAssignment); return vars; } - private static void mergeExtension(ItemDeltaItem> destIdi, ItemDeltaItem> srcIdi) throws SchemaException { + private static void mergeExtension(ItemDeltaItem,PrismContainerDefinition> destIdi, ItemDeltaItem,PrismContainerDefinition> srcIdi) throws SchemaException { mergeExtension(destIdi.getItemOld(), srcIdi.getItemOld()); mergeExtension(destIdi.getItemNew(), srcIdi.getItemNew()); if (srcIdi.getDelta() != null || srcIdi.getSubItemDeltas() != null) { @@ -1126,8 +1126,8 @@ private static void mergeExtension(ItemDeltaItem> dstItem, - Item> srcItem) throws SchemaException { + private static void mergeExtension(Item,PrismContainerDefinition> dstItem, + Item,PrismContainerDefinition> srcItem) throws SchemaException { if (srcItem == null || dstItem == null) { return; } @@ -1135,7 +1135,7 @@ private static void mergeExtension(Item> dst mergeExtensionContainers(dstItem, srcExtension); } - private static void mergeExtension(ItemDeltaItem> destIdi, + private static void mergeExtension(ItemDeltaItem,PrismContainerDefinition> destIdi, PrismObject srcObject) throws SchemaException { if (srcObject == null) { return; @@ -1147,15 +1147,15 @@ private static void mergeExtension(ItemDeltaItem> dstItem, PrismContainer srcExtension) throws SchemaException { + private static void mergeExtensionContainers(Item,PrismContainerDefinition> dstItem, PrismContainer srcExtension) throws SchemaException { if (dstItem == null) { return; } PrismContainer dstContainer = (PrismContainer) dstItem; if (srcExtension != null && !srcExtension.getValue().isEmpty()) { PrismContainer dstExtension = dstContainer.findOrCreateContainer(AssignmentType.F_EXTENSION); - for (Item srcExtensionItem: srcExtension.getValue().getItems()) { - Item magicItem = dstExtension.findItem(srcExtensionItem.getElementName()); + for (Item srcExtensionItem: srcExtension.getValue().getItems()) { + Item magicItem = dstExtension.findItem(srcExtensionItem.getElementName()); if (magicItem == null) { dstExtension.add(srcExtensionItem.clone()); } @@ -1165,8 +1165,8 @@ private static void mergeExtensionContainers(Item magicExtension, PrismContainer segmentExtension) throws SchemaException { if (segmentExtension != null && !segmentExtension.getValue().isEmpty()) { - for (Item segmentItem: segmentExtension.getValue().getItems()) { - Item magicItem = magicExtension.findItem(segmentItem.getElementName()); + for (Item segmentItem: segmentExtension.getValue().getItems()) { + Item magicItem = magicExtension.findItem(segmentItem.getElementName()); if (magicItem == null) { magicExtension.add(segmentItem.clone()); } @@ -1174,7 +1174,7 @@ private static void mergeExtension(PrismContainer magicExtension, } } - public static void addAssignmentPathVariables(Mapping mapping, AssignmentPathVariables assignmentPathVariables) { + public static void addAssignmentPathVariables(Mapping mapping, AssignmentPathVariables assignmentPathVariables) { if (assignmentPathVariables != null ) { mapping.addVariableDefinition(ExpressionConstants.VAR_ASSIGNMENT, assignmentPathVariables.getMagicAssignment()); mapping.addVariableDefinition(ExpressionConstants.VAR_IMMEDIATE_ASSIGNMENT, assignmentPathVariables.getImmediateAssignment()); @@ -1274,7 +1274,7 @@ public static PrismContainer createAssignmentSingleValueContaine return assignmentCont; } - public static AssignmentType getAssignmentType(ItemDeltaItem> assignmentIdi, boolean old) { + public static AssignmentType getAssignmentType(ItemDeltaItem,PrismContainerDefinition> assignmentIdi, boolean old) { if (old) { return ((PrismContainer)assignmentIdi.getItemOld()).getValue(0).asContainerable(); } else { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ActivationProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ActivationProcessor.java index 1e4dbb1cae8..9c55010ce9f 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ActivationProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ActivationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -449,24 +449,24 @@ private boolean evaluateExistenceMapping(final LensContext return legal; } - MappingInitializer> initializer = new MappingInitializer>() { + MappingInitializer,PrismPropertyDefinition> initializer = new MappingInitializer,PrismPropertyDefinition>() { @Override - public void initialize(Mapping> existenceMapping) throws SchemaException { + public void initialize(Mapping,PrismPropertyDefinition> existenceMapping) throws SchemaException { // Source: legal - ItemDeltaItem> legalSourceIdi = getLegalIdi(accCtx); - Source> legalSource - = new Source>(legalSourceIdi, ExpressionConstants.VAR_LEGAL); + ItemDeltaItem,PrismPropertyDefinition> legalSourceIdi = getLegalIdi(accCtx); + Source,PrismPropertyDefinition> legalSource + = new Source<>(legalSourceIdi, ExpressionConstants.VAR_LEGAL); existenceMapping.setDefaultSource(legalSource); // Source: assigned - ItemDeltaItem> assignedIdi = getAssignedIdi(accCtx); - Source> assignedSource = new Source>(assignedIdi, ExpressionConstants.VAR_ASSIGNED); + ItemDeltaItem,PrismPropertyDefinition> assignedIdi = getAssignedIdi(accCtx); + Source,PrismPropertyDefinition> assignedSource = new Source<>(assignedIdi, ExpressionConstants.VAR_ASSIGNED); existenceMapping.addSource(assignedSource); // Source: focusExists - ItemDeltaItem> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext()); - Source> focusExistsSource - = new Source>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS); + ItemDeltaItem,PrismPropertyDefinition> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext()); + Source,PrismPropertyDefinition> focusExistsSource + = new Source<>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS); existenceMapping.addSource(focusExistsSource); // Variable: focus @@ -511,7 +511,7 @@ public void process(ItemPath mappingOutputPath, } }; - MappingEvaluatorHelperParams, ShadowType, F> params = new MappingEvaluatorHelperParams<>(); + MappingEvaluatorHelperParams, PrismPropertyDefinition, ShadowType, F> params = new MappingEvaluatorHelperParams<>(); params.setMappingTypes(outbound); params.setMappingDesc("outbound existence mapping in projection " + accCtxDesc); params.setNow(now); @@ -566,18 +566,18 @@ private void evaluateActivationMapping(final LensContex // shadowPropertyNew = shadowNew.findProperty(projectionPropertyPath); // } - MappingInitializer> initializer = new MappingInitializer>() { + MappingInitializer,PrismPropertyDefinition> initializer = new MappingInitializer,PrismPropertyDefinition>() { @Override - public void initialize(Mapping> mapping) throws SchemaException { + public void initialize(Mapping,PrismPropertyDefinition> mapping) throws SchemaException { // Source: administrativeStatus, validFrom or validTo - ItemDeltaItem> sourceIdi = context.getFocusContext().getObjectDeltaObject().findIdi(focusPropertyPath); + ItemDeltaItem,PrismPropertyDefinition> sourceIdi = context.getFocusContext().getObjectDeltaObject().findIdi(focusPropertyPath); if (capActivation != null) { ActivationValidityCapabilityType capValidFrom = capActivation.getValidFrom(); ActivationValidityCapabilityType capValidTo = capActivation.getValidTo(); // Source: computedShadowStatus - ItemDeltaItem> computedIdi; + ItemDeltaItem,PrismPropertyDefinition> computedIdi; if (capValidFrom != null && capValidTo != null) { // "Native" validFrom and validTo, directly use administrativeStatus computedIdi = context.getFocusContext().getObjectDeltaObject().findIdi(focusPropertyPath); @@ -588,32 +588,32 @@ public void initialize(Mapping> mapping) throws SchemaExce } - Source> computedSource = new Source>(computedIdi, ExpressionConstants.VAR_INPUT); + Source,PrismPropertyDefinition> computedSource = new Source<>(computedIdi, ExpressionConstants.VAR_INPUT); mapping.setDefaultSource(computedSource); - Source> source = new Source>(sourceIdi, ExpressionConstants.VAR_ADMINISTRATIVE_STATUS); + Source,PrismPropertyDefinition> source = new Source<>(sourceIdi, ExpressionConstants.VAR_ADMINISTRATIVE_STATUS); mapping.addSource(source); } else { - Source> source = new Source>(sourceIdi, ExpressionConstants.VAR_INPUT); + Source,PrismPropertyDefinition> source = new Source<>(sourceIdi, ExpressionConstants.VAR_INPUT); mapping.setDefaultSource(source); } // Source: legal - ItemDeltaItem> legalIdi = getLegalIdi(projCtx); - Source> legalSource = new Source>(legalIdi, ExpressionConstants.VAR_LEGAL); + ItemDeltaItem,PrismPropertyDefinition> legalIdi = getLegalIdi(projCtx); + Source,PrismPropertyDefinition> legalSource = new Source<>(legalIdi, ExpressionConstants.VAR_LEGAL); mapping.addSource(legalSource); // Source: assigned - ItemDeltaItem> assignedIdi = getAssignedIdi(projCtx); - Source> assignedSource = new Source>(assignedIdi, ExpressionConstants.VAR_ASSIGNED); + ItemDeltaItem,PrismPropertyDefinition> assignedIdi = getAssignedIdi(projCtx); + Source,PrismPropertyDefinition> assignedSource = new Source<>(assignedIdi, ExpressionConstants.VAR_ASSIGNED); mapping.addSource(assignedSource); // Source: focusExists - ItemDeltaItem> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext()); - Source> focusExistsSource - = new Source>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS); + ItemDeltaItem,PrismPropertyDefinition> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext()); + Source,PrismPropertyDefinition> focusExistsSource + = new Source<>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS); mapping.addSource(focusExistsSource); // Variable: focus @@ -630,7 +630,7 @@ public void initialize(Mapping> mapping) throws SchemaExce }; - MappingEvaluatorHelperParams, ShadowType, F> params = new MappingEvaluatorHelperParams<>(); + MappingEvaluatorHelperParams, PrismPropertyDefinition, ShadowType, F> params = new MappingEvaluatorHelperParams<>(); params.setMappingTypes(outbound); params.setMappingDesc(desc + " outbound activation mapping in projection " + accCtxDesc); params.setNow(now); @@ -647,7 +647,7 @@ public void initialize(Mapping> mapping) throws SchemaExce } - private ItemDeltaItem> getLegalIdi(LensProjectionContext accCtx) throws SchemaException { + private ItemDeltaItem,PrismPropertyDefinition> getLegalIdi(LensProjectionContext accCtx) throws SchemaException { Boolean legal = accCtx.isLegal(); Boolean legalOld = accCtx.isLegalOld(); @@ -659,17 +659,17 @@ private ItemDeltaItem> getLegalIdi(LensProjectionCon legalProp.add(new PrismPropertyValue(legal)); if (legal == legalOld) { - return new ItemDeltaItem>(legalProp); + return new ItemDeltaItem,PrismPropertyDefinition>(legalProp); } else { PrismProperty legalPropOld = legalProp.clone(); legalPropOld.setRealValue(legalOld); PropertyDelta legalDelta = legalPropOld.createDelta(); legalDelta.setValuesToReplace(new PrismPropertyValue(legal)); - return new ItemDeltaItem>(legalPropOld, legalDelta, legalProp); + return new ItemDeltaItem,PrismPropertyDefinition>(legalPropOld, legalDelta, legalProp); } } - private ItemDeltaItem> getAssignedIdi(LensProjectionContext accCtx) throws SchemaException { + private ItemDeltaItem,PrismPropertyDefinition> getAssignedIdi(LensProjectionContext accCtx) throws SchemaException { Boolean assigned = accCtx.isAssigned(); Boolean assignedOld = accCtx.isAssignedOld(); @@ -691,7 +691,7 @@ private ItemDeltaItem> getAssignedIdi(LensProjection } } - private ItemDeltaItem> getFocusExistsIdi( + private ItemDeltaItem,PrismPropertyDefinition> getFocusExistsIdi( LensFocusContext lensFocusContext) throws SchemaException { Boolean existsOld = null; Boolean existsNew = null; @@ -718,13 +718,13 @@ private ItemDeltaItem> getFoc existsProp.add(new PrismPropertyValue(existsNew)); if (existsOld == existsNew) { - return new ItemDeltaItem>(existsProp); + return new ItemDeltaItem,PrismPropertyDefinition>(existsProp); } else { PrismProperty existsPropOld = existsProp.clone(); existsPropOld.setRealValue(existsOld); PropertyDelta existsDelta = existsPropOld.createDelta(); existsDelta.setValuesToReplace(new PrismPropertyValue(existsNew)); - return new ItemDeltaItem>(existsPropOld, existsDelta, existsProp); + return new ItemDeltaItem,PrismPropertyDefinition>(existsPropOld, existsDelta, existsProp); } } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/AssignmentProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/AssignmentProcessor.java index 26fd5f8b854..3224ada632d 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/AssignmentProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/AssignmentProcessor.java @@ -57,6 +57,7 @@ import com.evolveum.midpoint.model.impl.lens.LensProjectionContext; import com.evolveum.midpoint.model.impl.lens.LensUtil; import com.evolveum.midpoint.prism.Containerable; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.Objectable; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerDefinition; @@ -112,6 +113,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintEnforcementType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -278,7 +280,7 @@ private void processAssignmentsProjectionsWithFocus(LensCo AssignmentType assignmentType = assignmentCVal.asContainerable(); PrismContainerValue assignmentCValOld = assignmentCVal; PrismContainerValue assignmentCValNew = assignmentCVal; - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); boolean forceRecon = false; @@ -292,7 +294,7 @@ private void processAssignmentsProjectionsWithFocus(LensCo assignmentPlacementDesc = "delta for "+source; } else { assignmentPlacementDesc = source.toString(); - Collection> assignmentItemDeltas = getExecutionWaveAssignmentItemDeltas(focusContext, assignmentCVal.getId()); + Collection> assignmentItemDeltas = getExecutionWaveAssignmentItemDeltas(focusContext, assignmentCVal.getId()); if (assignmentItemDeltas != null && !assignmentItemDeltas.isEmpty()) { // Small changes inside assignment, but otherwise the assignment stays as it is (not added or deleted) assignmentIdi.setSubItemDeltas(assignmentItemDeltas); @@ -484,12 +486,12 @@ private void processAssignmentsProjectionsWithFocus(LensCo // PROCESSING FOCUS - Map>> focusOutputTripleMap = new HashMap<>(); + Map>> focusOutputTripleMap = new HashMap<>(); collectFocusTripleFromMappings(evaluatedAssignmentTriple.getPlusSet(), focusOutputTripleMap, PlusMinusZero.PLUS); collectFocusTripleFromMappings(evaluatedAssignmentTriple.getMinusSet(), focusOutputTripleMap, PlusMinusZero.MINUS); collectFocusTripleFromMappings(evaluatedAssignmentTriple.getZeroSet(), focusOutputTripleMap, PlusMinusZero.ZERO); ObjectDeltaObject focusOdo = focusContext.getObjectDeltaObject(); - Collection> focusDeltas = objectTemplateProcessor.computeItemDeltas(focusOutputTripleMap, + Collection> focusDeltas = objectTemplateProcessor.computeItemDeltas(focusOutputTripleMap, focusOdo, focusContext.getObjectDefinition(), "focus mappings in assignments of "+focusContext.getHumanReadableName()); LOGGER.trace("Computed focus deltas: {}", focusDeltas); focusContext.applyProjectionWaveSecondaryDeltas(focusDeltas); @@ -941,7 +943,7 @@ private Collection> mergeAssignments( return all; } - private EvaluatedAssignmentImpl evaluateAssignment(ItemDeltaItem> assignmentIdi, + private EvaluatedAssignmentImpl evaluateAssignment(ItemDeltaItem,PrismContainerDefinition> assignmentIdi, boolean evaluateOld, LensContext context, ObjectType source, AssignmentEvaluator assignmentEvaluator, String assignmentPlacementDesc, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, PolicyViolationException { try{ @@ -1154,9 +1156,8 @@ private void createAssignmentDelta(L constructionType.setResourceRef(ObjectTypeUtil.createObjectRef(accountContext.getResource())); assignment.setConstruction(constructionType); assignmentDelta.addValueToAdd(assignment.asPrismContainerValue()); - assignmentDelta.applyDefinition(prismContext.getSchemaRegistry() - .findObjectDefinitionByCompileTimeClass(focusClass) - .findContainerDefinition(FocusType.F_ASSIGNMENT)); + PrismContainerDefinition containerDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(focusClass).findContainerDefinition(FocusType.F_ASSIGNMENT); + assignmentDelta.applyDefinition(containerDefinition); context.getFocusContext().swallowToProjectionWaveSecondaryDelta(assignmentDelta); } @@ -1509,7 +1510,7 @@ private ContainerDelta getExecutionWaveAss return assignmentDelta; } - private Collection> getExecutionWaveAssignmentItemDeltas(LensFocusContext focusContext, Long id) throws SchemaException { + private Collection> getExecutionWaveAssignmentItemDeltas(LensFocusContext focusContext, Long id) throws SchemaException { ObjectDelta focusDelta = (ObjectDelta) focusContext.getWaveDelta(focusContext.getLensContext().getExecutionWave()); if (focusDelta == null) { return null; @@ -1526,19 +1527,19 @@ private PrismContainerDefinition getAssign return focusContext.getObjectDefinition().findContainerDefinition(FocusType.F_ASSIGNMENT); } - private XMLGregorianCalendar collectFocusTripleFromMappings( + private XMLGregorianCalendar collectFocusTripleFromMappings( Collection> evaluatedAssignmnents, - Map>> outputTripleMap, + Map>> outputTripleMap, PlusMinusZero plusMinusZero) throws SchemaException { XMLGregorianCalendar nextRecomputeTime = null; for (EvaluatedAssignmentImpl ea: evaluatedAssignmnents) { - Collection> focusMappings = (Collection)ea.getFocusMappings(); - for (Mapping mapping: focusMappings) { + Collection> focusMappings = (Collection)ea.getFocusMappings(); + for (Mapping mapping: focusMappings) { ItemPath itemPath = mapping.getOutputPath(); - DeltaSetTriple> outputTriple = ItemValueWithOrigin.createOutputTriple(mapping); + DeltaSetTriple> outputTriple = ItemValueWithOrigin.createOutputTriple(mapping); if (outputTriple == null) { continue; } @@ -1551,7 +1552,7 @@ private XMLGregorianCalendar collect outputTriple.clearZeroSet(); outputTriple.clearPlusSet(); } - DeltaSetTriple> mapTriple = (DeltaSetTriple>) outputTripleMap.get(itemPath); + DeltaSetTriple> mapTriple = (DeltaSetTriple>) outputTripleMap.get(itemPath); if (mapTriple == null) { outputTripleMap.put(itemPath, outputTriple); } else { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConsolidationProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConsolidationProcessor.java index 7062f0fb6f7..c104b71468d 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConsolidationProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConsolidationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -166,22 +166,22 @@ private ObjectDelta consolidateValuesToModifyD // "Squeeze" all the relevant mappings into a data structure that we can process conveniently. We want to have all the // (meta)data about relevant for a specific attribute in one data structure, not spread over several account constructions. - MappingExtractor, F> attributeExtractor = new MappingExtractor, F>() { + MappingExtractor,PrismPropertyDefinition,F> attributeExtractor = new MappingExtractor,PrismPropertyDefinition,F>() { @Override - public Collection>> getMappings(Construction construction) { + public Collection,PrismPropertyDefinition>> getMappings(Construction construction) { return (Collection)construction.getAttributeMappings(); } }; - Map>>> squeezedAttributes = sqeeze(projCtx, attributeExtractor); + Map,PrismPropertyDefinition>>> squeezedAttributes = sqeeze(projCtx, attributeExtractor); projCtx.setSqueezedAttributes(squeezedAttributes); - MappingExtractor, F> associationExtractor = new MappingExtractor, F>() { + MappingExtractor,PrismContainerDefinition,F> associationExtractor = new MappingExtractor,PrismContainerDefinition,F>() { @Override - public Collection>> getMappings(Construction construction) { + public Collection,PrismContainerDefinition>> getMappings(Construction construction) { return construction.getAssociationMappings(); } }; - Map>>> squeezedAssociations = + Map,PrismContainerDefinition>>> squeezedAssociations = sqeeze(projCtx, associationExtractor); projCtx.setSqueezedAssociations(squeezedAssociations); @@ -229,9 +229,9 @@ public Collection>> getMappin // ATTRIBUTES // Iterate and process each attribute separately. Now that we have squeezed the data we can process each attribute just // with the data in ItemValueWithOrigin triples. - for (Map.Entry>>> entry : squeezedAttributes.entrySet()) { + for (Map.Entry,PrismPropertyDefinition>>> entry : squeezedAttributes.entrySet()) { QName attributeName = entry.getKey(); - DeltaSetTriple>> triple = entry.getValue(); + DeltaSetTriple,PrismPropertyDefinition>> triple = entry.getValue(); PropertyDelta propDelta = consolidateAttribute(rOcDef, discr, existingDelta, projCtx, addUnchangedValues, completeAccount, attributeName, (DeltaSetTriple)triple); if (propDelta != null) { @@ -240,9 +240,9 @@ public Collection>> getMappin } // ASSOCIATIONS - for (Entry>>> entry : squeezedAssociations.entrySet()) { + for (Entry,PrismContainerDefinition>>> entry : squeezedAssociations.entrySet()) { QName associationName = entry.getKey(); - DeltaSetTriple>> triple = entry.getValue(); + DeltaSetTriple,PrismContainerDefinition>> triple = entry.getValue(); ContainerDelta containerDelta = consolidateAssociation(rOcDef, discr, existingDelta, projCtx, addUnchangedValues, completeAccount, associationName, triple); if (containerDelta != null) { @@ -253,13 +253,13 @@ public Collection>> getMappin return objectDelta; } - private void fillInAssociationNames(Map>>> squeezedAssociations) throws SchemaException { + private void fillInAssociationNames(Map,PrismContainerDefinition>>> squeezedAssociations) throws SchemaException { PrismPropertyDefinition nameDefinition = prismContext.getSchemaRegistry() .findContainerDefinitionByCompileTimeClass(ShadowAssociationType.class) .findPropertyDefinition(ShadowAssociationType.F_NAME); - for (Entry>>> entry : squeezedAssociations.entrySet()) { - DeltaSetTriple>> deltaSetTriple = entry.getValue(); - for (ItemValueWithOrigin> ivwo : deltaSetTriple.getAllValues()) { + for (Entry,PrismContainerDefinition>>> entry : squeezedAssociations.entrySet()) { + DeltaSetTriple,PrismContainerDefinition>> deltaSetTriple = entry.getValue(); + for (ItemValueWithOrigin,PrismContainerDefinition> ivwo : deltaSetTriple.getAllValues()) { PrismContainerValue value = ivwo.getItemValue(); if (value != null && value.findProperty(ShadowAssociationType.F_NAME) == null) { // just for safety PrismProperty nameProperty = value.createProperty(nameDefinition); @@ -273,7 +273,7 @@ private void fillInAssociationNames(Map PropertyDelta consolidateAttribute(RefinedObjectClassDefinition rOcDef, ResourceShadowDiscriminator discr, ObjectDelta existingDelta, LensProjectionContext projCtx, boolean addUnchangedValues, boolean completeShadow, QName itemName, - DeltaSetTriple>> triple) throws SchemaException, ExpressionEvaluationException, PolicyViolationException { + DeltaSetTriple,PrismPropertyDefinition>> triple) throws SchemaException, ExpressionEvaluationException, PolicyViolationException { ItemPath itemPath = new ItemPath(ShadowType.F_ATTRIBUTES, itemName); RefinedAttributeDefinition attributeDefinition = rOcDef.findAttributeDefinition(itemName); @@ -309,7 +309,7 @@ private PropertyDelta consolidateAttribute(RefinedOb private ContainerDelta consolidateAssociation(RefinedObjectClassDefinition rOcDef, ResourceShadowDiscriminator discr, ObjectDelta existingDelta, LensProjectionContext projCtx, boolean addUnchangedValues, boolean completeShadow, QName associationName, - DeltaSetTriple>> triple) throws SchemaException, ExpressionEvaluationException, PolicyViolationException { + DeltaSetTriple,PrismContainerDefinition>> triple) throws SchemaException, ExpressionEvaluationException, PolicyViolationException { ItemPath itemPath = new ItemPath(ShadowType.F_ASSOCIATION); PrismContainerDefinition asspcContainerDef = getAssociationDefinition(); @@ -370,15 +370,15 @@ private PrismContainerDefinition getAssociationDefinition return associationDefinition; } - private ItemDelta consolidateItem(RefinedObjectClassDefinition rOcDef, + private ItemDelta consolidateItem(RefinedObjectClassDefinition rOcDef, ResourceShadowDiscriminator discr, ObjectDelta existingDelta, LensProjectionContext projCtx, boolean addUnchangedValues, boolean completeShadow, boolean isExclusiveStrong, - ItemPath itemPath, ItemDefinition itemDefinition, - DeltaSetTriple> triple, ValueMatcher valueMatcher, Comparator comparator, String itemDesc) + ItemPath itemPath, D itemDefinition, + DeltaSetTriple> triple, ValueMatcher valueMatcher, Comparator comparator, String itemDesc) throws SchemaException, ExpressionEvaluationException, PolicyViolationException { boolean forceAddUnchangedValues = false; - ItemDelta existingItemDelta = null; + ItemDelta existingItemDelta = null; if (existingDelta != null) { existingItemDelta = existingDelta.findItemDelta(itemPath); } @@ -392,7 +392,7 @@ private ItemDelta consolidateItem(RefinedObjectClassDe new Object[]{ itemDesc, discr, completeShadow, addUnchangedValues, forceAddUnchangedValues}); // Use this common utility method to do the computation. It does most of the work. - ItemDelta itemDelta = LensUtil.consolidateTripleToDelta( + ItemDelta itemDelta = LensUtil.consolidateTripleToDelta( itemPath, (DeltaSetTriple)triple, itemDefinition, existingItemDelta, projCtx.getObjectNew(), valueMatcher, comparator, addUnchangedValues || forceAddUnchangedValues, completeShadow, isExclusiveStrong, discr.toHumanReadableString(), completeShadow); @@ -423,7 +423,7 @@ private ItemDelta consolidateItem(RefinedObjectClassDe // Validate the delta. i.e. make sure it conforms to schema (that it does not have more values than allowed, etc.) if (existingItemDelta != null) { // Let's make sure that both the previous delta and this delta makes sense - ItemDelta mergedDelta = existingItemDelta.clone(); + ItemDelta mergedDelta = existingItemDelta.clone(); mergedDelta.merge(itemDelta); mergedDelta.validate(); } else { @@ -435,13 +435,13 @@ private ItemDelta consolidateItem(RefinedObjectClassDe return null; } - private boolean hasActiveWeakMapping( - Map>> squeezedAttributes, LensProjectionContext accCtx) throws SchemaException { - for (Map.Entry>> entry : squeezedAttributes.entrySet()) { - DeltaSetTriple> ivwoTriple = entry.getValue(); + private boolean hasActiveWeakMapping( + Map>> squeezedAttributes, LensProjectionContext accCtx) throws SchemaException { + for (Map.Entry>> entry : squeezedAttributes.entrySet()) { + DeltaSetTriple> ivwoTriple = entry.getValue(); boolean hasWeak = false; - for (ItemValueWithOrigin ivwo: ivwoTriple.getAllValues()) { - Mapping mapping = ivwo.getMapping(); + for (ItemValueWithOrigin ivwo: ivwoTriple.getAllValues()) { + Mapping mapping = ivwo.getMapping(); if (mapping.getStrength() == MappingStrengthType.WEAK) { // We only care about mappings that change something. If the weak mapping is not // changing anything then it will not be applied in this step anyway. Therefore @@ -462,16 +462,16 @@ private boolean hasActiveWeakMapping( // In that case we should apply the weak mapping. But we will not know this // unless we fetch the real values. if (ivwoTriple.hasMinusSet()) { - for (ItemValueWithOrigin ivwo: ivwoTriple.getMinusSet()) { - Mapping mapping = ivwo.getMapping(); + for (ItemValueWithOrigin ivwo: ivwoTriple.getMinusSet()) { + Mapping mapping = ivwo.getMapping(); PrismValueDeltaSetTriple outputTriple = mapping.getOutputTriple(); if (outputTriple != null && !outputTriple.isEmpty()) { return true; } } } - for (ItemValueWithOrigin ivwo: ivwoTriple.getNonNegativeValues()) { - Mapping mapping = ivwo.getMapping(); + for (ItemValueWithOrigin ivwo: ivwoTriple.getNonNegativeValues()) { + Mapping mapping = ivwo.getMapping(); PrismValueDeltaSetTriple outputTriple = mapping.getOutputTriple(); if (outputTriple != null && outputTriple.hasMinusSet()) { return true; @@ -514,13 +514,13 @@ private void consolidateValuesModifyProjection(LensContext } } - private ItemDelta consolidateItemWithSync(LensProjectionContext accCtx, ItemDelta delta, + private ItemDelta consolidateItemWithSync(LensProjectionContext accCtx, ItemDelta delta, ValueMatcher valueMatcher) { if (delta == null) { return null; } if (delta instanceof PropertyDelta) { - return (ItemDelta) consolidatePropertyWithSync(accCtx, (PropertyDelta) delta, valueMatcher); + return (ItemDelta) consolidatePropertyWithSync(accCtx, (PropertyDelta) delta, valueMatcher); } return delta; } @@ -640,12 +640,12 @@ private void cleanupValues(Collection> values, Propert } } - private Map>> sqeeze( - LensProjectionContext accCtx, MappingExtractor extractor) { - Map>> squeezedMap - = new HashMap>>(); + private Map>> sqeeze( + LensProjectionContext accCtx, MappingExtractor extractor) { + Map>> squeezedMap + = new HashMap>>(); if (accCtx.getConstructionDeltaSetTriple() != null) { - sqeezeAttributesFromConstructionTriple(squeezedMap, accCtx.getConstructionDeltaSetTriple(), extractor); + sqeezeAttributesFromConstructionTriple(squeezedMap, (PrismValueDeltaSetTriple)accCtx.getConstructionDeltaSetTriple(), extractor); } if (accCtx.getOutboundConstruction() != null) { // The plus-minus-zero status of outbound account construction is determined by the type of account delta @@ -660,9 +660,9 @@ private Map void sqeezeAttributesFromConstructionTriple( - Map>> squeezedMap, - PrismValueDeltaSetTriple> constructionDeltaSetTriple, MappingExtractor extractor) { + private void sqeezeAttributesFromConstructionTriple( + Map>> squeezedMap, + PrismValueDeltaSetTriple>> constructionDeltaSetTriple, MappingExtractor extractor) { // Zero account constructions go normally, plus to plus, minus to minus sqeezeAttributesFromAccountConstructionSet(squeezedMap, constructionDeltaSetTriple.getZeroSet(), extractor); // Plus accounts: zero and plus values go to plus @@ -671,103 +671,103 @@ private void sqeezeAttributesFromCon sqeezeAttributesFromConstructionSetNonminusToMinus(squeezedMap, constructionDeltaSetTriple.getMinusSet(), extractor); } - private void sqeezeAttributesFromAccountConstructionSet( - Map>> squeezedMap, - Collection> constructionSet, MappingExtractor extractor) { + private void sqeezeAttributesFromAccountConstructionSet( + Map>> squeezedMap, + Collection>> constructionSet, MappingExtractor extractor) { if (constructionSet == null) { return; } - for (PrismPropertyValue construction: constructionSet) { + for (PrismPropertyValue> construction: constructionSet) { sqeezeAttributesFromConstruction(squeezedMap, construction.getValue(), extractor); } } - private void sqeezeAttributesFromAccountConstructionSetNonminusToPlus( - Map>> squeezedMap, - Collection> constructionSet, MappingExtractor extractor) { + private void sqeezeAttributesFromAccountConstructionSetNonminusToPlus( + Map>> squeezedMap, + Collection>> constructionSet, MappingExtractor extractor) { if (constructionSet == null) { return; } - for (PrismPropertyValue construction: constructionSet) { + for (PrismPropertyValue> construction: constructionSet) { sqeezeAttributesFromConstructionNonminusToPlus(squeezedMap, construction.getValue(), extractor); } } - private void sqeezeAttributesFromConstructionSetNonminusToMinus( - Map>> squeezedMap, - Collection> constructionSet, MappingExtractor extractor) { + private void sqeezeAttributesFromConstructionSetNonminusToMinus( + Map>> squeezedMap, + Collection>> constructionSet, MappingExtractor extractor) { if (constructionSet == null) { return; } - for (PrismPropertyValue construction: constructionSet) { + for (PrismPropertyValue> construction: constructionSet) { sqeezeAttributesFromConstructionNonminusToMinus(squeezedMap, construction.getValue(), extractor); } } - private void sqeezeAttributesFromConstruction( - Map>> squeezedMap, - Construction construction, MappingExtractor extractor) { - for (Mapping mapping: extractor.getMappings(construction)) { + private void sqeezeAttributesFromConstruction( + Map>> squeezedMap, + Construction construction, MappingExtractor extractor) { + for (Mapping mapping: extractor.getMappings(construction)) { PrismValueDeltaSetTriple vcTriple = mapping.getOutputTriple(); if (vcTriple == null) { continue; } QName name = mapping.getMappingQName(); - DeltaSetTriple> squeezeTriple = getSqueezeMapTriple(squeezedMap, name); + DeltaSetTriple> squeezeTriple = getSqueezeMapTriple(squeezedMap, name); convertSqueezeSet(vcTriple.getZeroSet(), squeezeTriple.getZeroSet(), mapping, construction); convertSqueezeSet(vcTriple.getPlusSet(), squeezeTriple.getPlusSet(), mapping, construction); convertSqueezeSet(vcTriple.getMinusSet(), squeezeTriple.getMinusSet(), mapping, construction); } } - private void sqeezeAttributesFromConstructionNonminusToPlus( - Map>> squeezedMap, - Construction construction, MappingExtractor extractor) { - for (Mapping mapping: extractor.getMappings(construction)) { + private void sqeezeAttributesFromConstructionNonminusToPlus( + Map>> squeezedMap, + Construction construction, MappingExtractor extractor) { + for (Mapping mapping: extractor.getMappings(construction)) { PrismValueDeltaSetTriple vcTriple = mapping.getOutputTriple(); if (vcTriple == null) { continue; } QName name = mapping.getMappingQName(); - DeltaSetTriple> squeezeTriple = getSqueezeMapTriple(squeezedMap, name); + DeltaSetTriple> squeezeTriple = getSqueezeMapTriple(squeezedMap, name); convertSqueezeSet(vcTriple.getZeroSet(), squeezeTriple.getPlusSet(), mapping, construction); convertSqueezeSet(vcTriple.getPlusSet(), squeezeTriple.getPlusSet(), mapping, construction); // Ignore minus set } } - private void sqeezeAttributesFromConstructionNonminusToMinus( - Map>> squeezedMap, - Construction construction, MappingExtractor extractor) { - for (Mapping mapping: extractor.getMappings(construction)) { + private void sqeezeAttributesFromConstructionNonminusToMinus( + Map>> squeezedMap, + Construction construction, MappingExtractor extractor) { + for (Mapping mapping: extractor.getMappings(construction)) { PrismValueDeltaSetTriple vcTriple = mapping.getOutputTriple(); if (vcTriple == null) { continue; } QName name = mapping.getMappingQName(); - DeltaSetTriple> squeezeTriple + DeltaSetTriple> squeezeTriple = getSqueezeMapTriple(squeezedMap, name); convertSqueezeSet(vcTriple.getZeroSet(), squeezeTriple.getMinusSet(), mapping, construction); convertSqueezeSet(vcTriple.getPlusSet(), squeezeTriple.getMinusSet(), mapping, construction); } } - private void convertSqueezeSet(Collection fromSet, - Collection> toSet, - Mapping valueConstruction, Construction accountConstruction) { + private void convertSqueezeSet(Collection fromSet, + Collection> toSet, + Mapping valueConstruction, Construction accountConstruction) { if (fromSet != null) { for (V from: fromSet) { - ItemValueWithOrigin pvwo = new ItemValueWithOrigin(from, valueConstruction, accountConstruction); + ItemValueWithOrigin pvwo = new ItemValueWithOrigin(from, valueConstruction, accountConstruction); toSet.add(pvwo); } } } - private DeltaSetTriple> getSqueezeMapTriple( - Map>> squeezedMap, QName itemName) { - DeltaSetTriple> triple = squeezedMap.get(itemName); + private DeltaSetTriple> getSqueezeMapTriple( + Map>> squeezedMap, QName itemName) { + DeltaSetTriple> triple = squeezedMap.get(itemName); if (triple == null) { - triple = new DeltaSetTriple>(); + triple = new DeltaSetTriple>(); squeezedMap.put(itemName, triple); } return triple; diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/CredentialsProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/CredentialsProcessor.java index 8bdbb3d805a..bd5726eadc3 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/CredentialsProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/CredentialsProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -151,15 +151,15 @@ public void processCredentialsFocal(LensContext context return; } - Mapping> passwordMapping = valueConstructionFactory.createMapping(outboundMappingType, + Mapping,PrismPropertyDefinition> passwordMapping = valueConstructionFactory.createMapping(outboundMappingType, "outbound password mapping in account type " + rat); if (!passwordMapping.isApplicableToChannel(context.getChannel())) { return; } passwordMapping.setDefaultTargetDefinition(accountPasswordPropertyDefinition); - ItemDeltaItem> userPasswordIdi = focusContext.getObjectDeltaObject().findIdi(SchemaConstants.PATH_PASSWORD_VALUE); - Source> source = new Source>(userPasswordIdi, ExpressionConstants.VAR_INPUT); + ItemDeltaItem,PrismPropertyDefinition> userPasswordIdi = focusContext.getObjectDeltaObject().findIdi(SchemaConstants.PATH_PASSWORD_VALUE); + Source,PrismPropertyDefinition> source = new Source<>(userPasswordIdi, ExpressionConstants.VAR_INPUT); passwordMapping.setDefaultSource(source); passwordMapping.setOriginType(OriginType.OUTBOUND); passwordMapping.setOriginObject(accCtx.getResource()); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/InboundProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/InboundProcessor.java index adc1e5bd406..b35d58823f6 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/InboundProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/InboundProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -327,7 +327,7 @@ private ObjectDelta getAPrioriDelta(LensConte return null; } - private boolean checkWeakSkip(Mapping inbound, PrismObject newUser) throws SchemaException { + private boolean checkWeakSkip(Mapping inbound, PrismObject newUser) throws SchemaException { if (inbound.getStrength() != MappingStrengthType.WEAK) { return false; } @@ -350,14 +350,14 @@ private PropertyDelta evaluateInboundMapping(final throw new SystemException("Property "+oldAccountProperty+" has raw parsing state, such property cannot be used in inbound expressions"); } - Mapping> mapping = mappingFactory.createMapping(inboundMappingType, + Mapping,PrismPropertyDefinition> mapping = mappingFactory.createMapping(inboundMappingType, "inbound expression for "+accountAttributeName+" in "+resource); if (!mapping.isApplicableToChannel(context.getChannel())) { return null; } - Source> defaultSource = new Source>(oldAccountProperty, accountAttributeDelta, null, ExpressionConstants.VAR_INPUT); + Source,PrismPropertyDefinition> defaultSource = new Source<>(oldAccountProperty, accountAttributeDelta, null, ExpressionConstants.VAR_INPUT); defaultSource.recompute(); mapping.setDefaultSource(defaultSource); mapping.setTargetContext(LensUtil.getFocusDefinition(context)); @@ -612,15 +612,15 @@ public void initialize(Mapping mapping) throws SchemaException { } ObjectDelta aPrioriShadowDelta = getAPrioriDelta(context, accContext); - ItemDelta> specialAttributeDelta = null; + ItemDelta,PrismPropertyDefinition> specialAttributeDelta = null; if (aPrioriShadowDelta != null){ specialAttributeDelta = aPrioriShadowDelta.findItemDelta(sourcePath); } - ItemDeltaItem> sourceIdi = accContext.getObjectDeltaObject().findIdi(sourcePath); + ItemDeltaItem,PrismPropertyDefinition> sourceIdi = accContext.getObjectDeltaObject().findIdi(sourcePath); if (specialAttributeDelta == null){ specialAttributeDelta = sourceIdi.getDelta(); } - Source> source = new Source>(sourceIdi.getItemOld(), specialAttributeDelta, + Source,PrismPropertyDefinition> source = new Source<>(sourceIdi.getItemOld(), specialAttributeDelta, sourceIdi.getItemOld(), ExpressionConstants.VAR_INPUT); mapping.setDefaultSource(source); @@ -672,7 +672,7 @@ public void process(ItemPath mappingOutputPath, PrismValueDeltaSetTriple params = new MappingEvaluatorHelperParams<>(); + MappingEvaluatorHelperParams params = new MappingEvaluatorHelperParams<>(); params.setMappingTypes(inboundMappingTypes); params.setMappingDesc("inbound mapping for " + sourcePath + " in " + accContext.getResource()); params.setNow(now); @@ -697,7 +697,7 @@ private Collection getMappingApplicableToChannel( Collection inboundMappingTypes, String description, String channelUri) { Collection inboundMappings = new ArrayList(); for (MappingType inboundMappingType : inboundMappingTypes){ - Mapping> mapping = mappingFactory.createMapping(inboundMappingType, + Mapping,PrismPropertyDefinition> mapping = mappingFactory.createMapping(inboundMappingType, description); if (mapping.isApplicableToChannel(channelUri)){ diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluationHelper.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluationHelper.java index 4c8f2725450..758dc23115f 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluationHelper.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluationHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Evolveum + * Copyright (c) 2013-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,8 +100,8 @@ public class MappingEvaluationHelper { // Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { - public void evaluateMappingSetProjection( - MappingEvaluatorHelperParams params, + public void evaluateMappingSetProjection( + MappingEvaluatorHelperParams params, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { String mappingDesc = params.getMappingDesc(); @@ -112,11 +112,11 @@ public void ev Map> outputTripleMap = new HashMap<>(); XMLGregorianCalendar nextRecomputeTime = null; Collection mappingTypes = params.getMappingTypes(); - Collection> mappings = new ArrayList>(mappingTypes.size()); + Collection> mappings = new ArrayList<>(mappingTypes.size()); for (MappingType mappingType: mappingTypes) { - Mapping mapping = mappingFactory.createMapping(mappingType, mappingDesc); + Mapping mapping = mappingFactory.createMapping(mappingType, mappingDesc); if (!mapping.isApplicableToChannel(params.getContext().getChannel())) { continue; @@ -124,7 +124,7 @@ public void ev mapping.setNow(params.getNow()); if (defaultTargetItemPath != null && targetObjectDefinition != null) { - ItemDefinition defaultTargetItemDef = targetObjectDefinition.findItemDefinition(defaultTargetItemPath); + D defaultTargetItemDef = targetObjectDefinition.findItemDefinition(defaultTargetItemPath); mapping.setDefaultTargetDefinition(defaultTargetItemDef); mapping.setDefaultTargetPath(defaultTargetItemPath); } else { @@ -150,7 +150,7 @@ public void ev mappings.add(mapping); } - for (Mapping mapping: mappings) { + for (Mapping mapping: mappings) { if (mapping.getStrength() == MappingStrengthType.WEAK) { // Evaluate weak mappings in a second run. @@ -163,7 +163,7 @@ public void ev } if (params.getAPrioriTargetDelta() != null && mappingOutputPath != null) { - ItemDelta aPrioriItemDelta = params.getAPrioriTargetDelta().findItemDelta(mappingOutputPath); + ItemDelta aPrioriItemDelta = params.getAPrioriTargetDelta().findItemDelta(mappingOutputPath); if (mapping.getStrength() != MappingStrengthType.STRONG) { if (aPrioriItemDelta != null && !aPrioriItemDelta.isEmpty()) { continue; @@ -198,7 +198,7 @@ public void ev // Second pass, evaluate only weak mappings - for (Mapping mapping: mappings) { + for (Mapping mapping: mappings) { ItemPath mappingOutputPath = mapping.getOutputPath(); if (params.isFixTarget() && mappingOutputPath != null && defaultTargetItemPath != null && !mappingOutputPath.equivalent(defaultTargetItemPath)) { @@ -213,7 +213,7 @@ public void ev PrismValueDeltaSetTriple outputTriple = mappingOutputStruct.getOutputTriple(); - Item aPrioriTargetItem = null; + Item aPrioriTargetItem = null; PrismObject aPrioriTargetObject = params.getAPrioriTargetObject(); if (aPrioriTargetObject != null && mappingOutputPath != null) { aPrioriTargetItem = aPrioriTargetObject.findItem(mappingOutputPath); @@ -262,12 +262,12 @@ public void ev } else { targetItemDefinition = params.getTargetItemDefinition(); } - ItemDelta targetItemDelta = targetItemDefinition.createEmptyDelta(mappingOutputPath); + ItemDelta targetItemDelta = targetItemDefinition.createEmptyDelta(mappingOutputPath); - Item aPrioriTargetItem = null; + Item aPrioriTargetItem = null; PrismObject aPrioriTargetObject = params.getAPrioriTargetObject(); if (aPrioriTargetObject != null) { - aPrioriTargetItem = (Item) aPrioriTargetObject.findItem(mappingOutputPath); + aPrioriTargetItem = aPrioriTargetObject.findItem(mappingOutputPath); } if (targetContext.isAdd()) { @@ -325,7 +325,7 @@ public void ev // Figure out recompute time - for (Mapping mapping: mappings) { + for (Mapping mapping: mappings) { XMLGregorianCalendar mappingNextRecomputeTime = mapping.getNextRecomputeTime(); if (mappingNextRecomputeTime != null) { if (nextRecomputeTime == null || nextRecomputeTime.compare(mappingNextRecomputeTime) == DatatypeConstants.GREATER) { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluatorHelperParams.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluatorHelperParams.java index d3060d2df34..837d758c62b 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluatorHelperParams.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluatorHelperParams.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2014 Evolveum + * Copyright (c) 2014-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,19 +34,19 @@ * @author semancik * */ -public class MappingEvaluatorHelperParams { +public class MappingEvaluatorHelperParams { private Collection mappingTypes; private String mappingDesc; private XMLGregorianCalendar now; - private MappingInitializer initializer; + private MappingInitializer initializer; private MappingOutputProcessor processor; private PrismObject aPrioriTargetObject; private ObjectDelta aPrioriTargetDelta; private LensElementContext targetContext; private ItemPath defaultTargetItemPath; // Only needed if defaultTargetItemPath == null - private ItemDefinition targetItemDefinition; + private D targetItemDefinition; private Boolean evaluateCurrent; private LensContext context; private boolean hasFullTargetObject; @@ -72,10 +72,10 @@ public XMLGregorianCalendar getNow() { public void setNow(XMLGregorianCalendar now) { this.now = now; } - public MappingInitializer getInitializer() { + public MappingInitializer getInitializer() { return initializer; } - public void setInitializer(MappingInitializer initializer) { + public void setInitializer(MappingInitializer initializer) { this.initializer = initializer; } public MappingOutputProcessor getProcessor() { @@ -139,11 +139,11 @@ public void setFixTarget(boolean fixTarget) { this.fixTarget = fixTarget; } - public ItemDefinition getTargetItemDefinition() { + public D getTargetItemDefinition() { return targetItemDefinition; } - public void setTargetItemDefinition(ItemDefinition targetItemDefinition) { + public void setTargetItemDefinition(D targetItemDefinition) { this.targetItemDefinition = targetItemDefinition; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingExtractor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingExtractor.java index 8f9822beb7e..0561a5277e3 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingExtractor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Evolveum + * Copyright (c) 2014-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,12 @@ import com.evolveum.midpoint.model.common.mapping.Mapping; import com.evolveum.midpoint.model.impl.lens.Construction; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -public interface MappingExtractor { +public interface MappingExtractor { - Collection> getMappings(Construction construction); + Collection> getMappings(Construction construction); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingInitializer.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingInitializer.java index 11d5c42d558..a52c4a5aacd 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingInitializer.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Evolveum + * Copyright (c) 2013-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.evolveum.midpoint.model.impl.lens.projector; import com.evolveum.midpoint.model.common.mapping.Mapping; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; @@ -24,8 +25,8 @@ * @author Radovan Semancik * */ -public interface MappingInitializer { +public interface MappingInitializer { - void initialize(Mapping mapping) throws SchemaException; + void initialize(Mapping mapping) throws SchemaException; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ObjectTemplateProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ObjectTemplateProcessor.java index 220305c02b3..6820d64035a 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ObjectTemplateProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ObjectTemplateProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ import com.evolveum.midpoint.model.impl.lens.LensFocusContext; import com.evolveum.midpoint.model.impl.lens.LensUtil; import com.evolveum.midpoint.model.impl.trigger.RecomputeTriggerHandler; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismContext; @@ -132,12 +133,12 @@ public void processTemplate(LensContext context, Object LOGGER.trace("Applying {} to {}, iteration {} ({}), phase {}", new Object[]{objectTemplate, focusContext.getObjectNew(), iteration, iterationToken, phase}); - Map>> outputTripleMap = new HashMap<>(); + Map>> outputTripleMap = new HashMap<>(); XMLGregorianCalendar nextRecomputeTime = collectTripleFromTemplate(context, objectTemplate, phase, focusOdo, outputTripleMap, iteration, iterationToken, now, objectTemplate.toString(), task, result); - Collection> itemDeltas = computeItemDeltas(outputTripleMap, focusOdo, focusDefinition, "object template "+objectTemplate+ " for focus "+focusOdo.getAnyObject()); + Collection> itemDeltas = computeItemDeltas(outputTripleMap, focusOdo, focusDefinition, "object template "+objectTemplate+ " for focus "+focusOdo.getAnyObject()); focusContext.applyProjectionWaveSecondaryDeltas(itemDeltas); @@ -171,20 +172,20 @@ public void processTemplate(LensContext context, Object } - Collection> computeItemDeltas(Map>> outputTripleMap, + Collection> computeItemDeltas(Map>> outputTripleMap, ObjectDeltaObject focusOdo, PrismObjectDefinition focusDefinition, String contextDesc) throws ExpressionEvaluationException, PolicyViolationException, SchemaException { - Collection> itemDeltas = new ArrayList<>(); - for (Entry>> entry: outputTripleMap.entrySet()) { + Collection> itemDeltas = new ArrayList<>(); + for (Entry>> entry: outputTripleMap.entrySet()) { ItemPath itemPath = entry.getKey(); - DeltaSetTriple> outputTriple = entry.getValue(); + DeltaSetTriple> outputTriple = entry.getValue(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Computed triple for {}:\n{}", itemPath, outputTriple.debugDump()); } - ItemDelta apropriItemDelta = null; + ItemDelta apropriItemDelta = null; // boolean addUnchangedValues = focusContext.isAdd(); // We need to add unchanged values otherwise the unconditional mappings will not be applied boolean addUnchangedValues = true; - ItemDelta itemDelta = LensUtil.consolidateTripleToDelta(itemPath, (DeltaSetTriple)outputTriple, + ItemDelta itemDelta = LensUtil.consolidateTripleToDelta(itemPath, (DeltaSetTriple)outputTriple, focusDefinition.findItemDefinition(itemPath), apropriItemDelta, focusOdo.getNewObject(), null, null, addUnchangedValues, true, false, contextDesc, true); @@ -200,7 +201,7 @@ Collection> computeItemDel private XMLGregorianCalendar collectTripleFromTemplate(LensContext context, ObjectTemplateType objectTemplateType, ObjectTemplateMappingEvaluationPhaseType phase, ObjectDeltaObject userOdo, - Map>> outputTripleMap, + Map>> outputTripleMap, int iteration, String iterationToken, XMLGregorianCalendar now, String contextDesc, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { @@ -260,10 +261,10 @@ private Collection collectMapings(ObjectTemplateType return mappings; } - private XMLGregorianCalendar collectTripleFromMappings( + private XMLGregorianCalendar collectTripleFromMappings( Collection mappings, ObjectTemplateMappingEvaluationPhaseType phase, LensContext context, ObjectTemplateType objectTemplateType, ObjectDeltaObject userOdo, - Map>> outputTripleMap, + Map>> outputTripleMap, int iteration, String iterationToken, XMLGregorianCalendar now, String contextDesc, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { @@ -277,7 +278,7 @@ private XMLGregorianCalendar collect if (mappingPhase != phase) { continue; } - Mapping mapping = LensUtil.createFocusMapping(mappingFactory, context, mappingType, objectTemplateType, userOdo, + Mapping mapping = LensUtil.createFocusMapping(mappingFactory, context, mappingType, objectTemplateType, userOdo, null, iteration, iterationToken, context.getSystemConfiguration(), now, contextDesc, result); if (mapping == null) { continue; @@ -303,11 +304,11 @@ private XMLGregorianCalendar collect if (itemPath == null) { continue; } - DeltaSetTriple> outputTriple = ItemValueWithOrigin.createOutputTriple(mapping); + DeltaSetTriple> outputTriple = ItemValueWithOrigin.createOutputTriple(mapping); if (outputTriple == null) { continue; } - DeltaSetTriple> mapTriple = (DeltaSetTriple>) outputTripleMap.get(itemPath); + DeltaSetTriple> mapTriple = (DeltaSetTriple>) outputTripleMap.get(itemPath); if (mapTriple == null) { outputTripleMap.put(itemPath, outputTriple); } else { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/OutboundProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/OutboundProcessor.java index 5189c9ebf40..db128f2355d 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/OutboundProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/OutboundProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.delta.ChangeType; @@ -120,7 +121,7 @@ public void processOutbound(LensContext context, LensPr String operation = projCtx.getOperation().getValue(); for (QName attributeName : rOcDef.getNamesOfAttributesWithOutboundExpressions()) { - RefinedAttributeDefinition refinedAttributeDefinition = rOcDef.getAttributeDefinition(attributeName); + RefinedAttributeDefinition refinedAttributeDefinition = rOcDef.getAttributeDefinition(attributeName); final MappingType outboundMappingType = refinedAttributeDefinition.getOutboundMappingType(); if (outboundMappingType == null) { @@ -132,11 +133,11 @@ public void processOutbound(LensContext context, LensPr continue; } - Mapping> mapping = mappingFactory.createMapping(outboundMappingType, + Mapping,RefinedAttributeDefinition> mapping = mappingFactory.createMapping(outboundMappingType, "outbound mapping for " + PrettyPrinter.prettyPrint(refinedAttributeDefinition.getName()) + " in " + rOcDef.getResourceType()); - Mapping> evaluatedMapping = evaluateMapping(mapping, attributeName, refinedAttributeDefinition, + Mapping,RefinedAttributeDefinition> evaluatedMapping = evaluateMapping(mapping, attributeName, refinedAttributeDefinition, focusOdo, projectionOdo, operation, rOcDef, null, context, projCtx, task, result); if (evaluatedMapping != null) { @@ -157,12 +158,12 @@ public void processOutbound(LensContext context, LensPr // continue; // } - Mapping> mapping = mappingFactory.createMapping(outboundMappingType, + Mapping,PrismContainerDefinition> mapping = mappingFactory.createMapping(outboundMappingType, "outbound mapping for " + PrettyPrinter.prettyPrint(associationDefinition.getName()) + " in " + rOcDef.getResourceType()); PrismContainerDefinition outputDefinition = getAssociationContainerDefinition(); - Mapping> evaluatedMapping = (Mapping) evaluateMapping(mapping, + Mapping,PrismContainerDefinition> evaluatedMapping = (Mapping) evaluateMapping(mapping, assocName, outputDefinition, focusOdo, projectionOdo, operation, rOcDef, associationDefinition.getAssociationTarget(), context, projCtx, task, result); @@ -174,8 +175,8 @@ public void processOutbound(LensContext context, LensPr projCtx.setOutboundConstruction(outboundConstruction); } - private Mapping evaluateMapping(final Mapping mapping, QName mappingQName, - ItemDefinition targetDefinition, ObjectDeltaObject focusOdo, ObjectDeltaObject projectionOdo, + private Mapping evaluateMapping(final Mapping mapping, QName mappingQName, + D targetDefinition, ObjectDeltaObject focusOdo, ObjectDeltaObject projectionOdo, String operation, RefinedObjectClassDefinition rOcDef, RefinedObjectClassDefinition assocTargetObjectClassDefinition, LensContext context, LensProjectionContext projCtx, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/PasswordPolicyProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/PasswordPolicyProcessor.java index 9fa6e908f3e..8e939ce5e74 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/PasswordPolicyProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/PasswordPolicyProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -205,7 +205,7 @@ private ValuePolicyType determineValuePolicy(ObjectDelta userDelta, Op PrismReferenceValue orgRefValue = orgDelta.getAnyValue(); try { - PrismObject org = (PrismObject) resolver.resolve(orgRefValue, + PrismObject org = resolver.resolve(orgRefValue, "resolving parent org ref", null, null, result); OrgType orgType = org.asObjectable(); ObjectReferenceType ref = orgType.getPasswordPolicyRef(); @@ -248,7 +248,7 @@ private ValuePolicyType determineValuePolicy(PrismObject object, OperationResult "Found more than one policy while trying to validate user's password. Please check your configuration"); } - PrismObject org = (PrismObject) resolver.resolve(orgRefValue, + PrismObject org = resolver.resolve(orgRefValue, "resolving parent org ref", null, null, result); orgs.add(org); valuePolicy = resolvePolicy(org, result); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java index 5c922bd1931..5d0bbee3bff 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -575,7 +575,7 @@ public void checkSchemaAndPolicies(LensContext context } } } else if (primaryDelta.isModify()) { - for(ItemDelta modification: primaryDelta.getModifications()) { + for(ItemDelta modification: primaryDelta.getModifications()) { if (modification.getParentPath().equivalent(SchemaConstants.PATH_ATTRIBUTES)) { PropertyDelta attrDelta = (PropertyDelta) modification; RefinedAttributeDefinition rAttrDef = rAccountDef.findAttributeDefinition(attrDelta.getElementName()); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ReconciliationProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ReconciliationProcessor.java index dfb676a6773..962bada5ae8 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ReconciliationProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ReconciliationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import com.evolveum.midpoint.prism.delta.ContainerDelta; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -48,6 +49,7 @@ import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.DeltaSetTriple; import com.evolveum.midpoint.prism.delta.ItemDelta; @@ -157,7 +159,7 @@ void processReconciliationFocus(LensContext context, RefinedObjectClassDefinition accountDefinition = accContext.getRefinedAccountDefinition(); - Map>>> squeezedAttributes = accContext + Map,PrismPropertyDefinition>>> squeezedAttributes = accContext .getSqueezedAttributes(); if (squeezedAttributes != null && !squeezedAttributes.isEmpty()) { if (LOGGER.isTraceEnabled()) { @@ -166,7 +168,7 @@ void processReconciliationFocus(LensContext context, reconcileProjectionAttributes(accContext, squeezedAttributes, accountDefinition); } - Map>>> squeezedAssociations = accContext.getSqueezedAssociations(); + Map,PrismContainerDefinition>>> squeezedAssociations = accContext.getSqueezedAssociations(); if (squeezedAssociations != null && !squeezedAssociations.isEmpty()) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Association reconciliation processing {}", accContext.getHumanReadableName()); @@ -187,7 +189,7 @@ void processReconciliationFocus(LensContext context, private void reconcileProjectionAttributes( LensProjectionContext projCtx, - Map>>> squeezedAttributes, + Map,PrismPropertyDefinition>>> squeezedAttributes, RefinedObjectClassDefinition accountDefinition) throws SchemaException { PrismObject shadowNew = projCtx.getObjectNew(); @@ -205,7 +207,7 @@ private void reconcileProjectionAttributes( + projCtx.getResourceShadowDiscriminator()); } - DeltaSetTriple>> pvwoTriple = squeezedAttributes + DeltaSetTriple,PrismPropertyDefinition>> pvwoTriple = squeezedAttributes .get(attrName); if (attributeDefinition.isIgnored(LayerType.MODEL)) { @@ -230,15 +232,15 @@ private void reconcileProjectionAttributes( } } - Collection>> shouldBePValues = null; + Collection,PrismPropertyDefinition>> shouldBePValues = null; if (pvwoTriple == null) { - shouldBePValues = new ArrayList>>(); + shouldBePValues = new ArrayList,PrismPropertyDefinition>>(); } else { shouldBePValues = pvwoTriple.getNonNegativeValues(); } boolean hasStrongShouldBePValue = false; - for (ItemValueWithOrigin> shouldBePValue : shouldBePValues) { + for (ItemValueWithOrigin,PrismPropertyDefinition> shouldBePValue : shouldBePValues) { if (shouldBePValue.getMapping() != null && shouldBePValue.getMapping().getStrength() == MappingStrengthType.STRONG) { hasStrongShouldBePValue = true; @@ -283,8 +285,8 @@ private void reconcileProjectionAttributes( matchingRuleRegistry); boolean hasValue = false; - for (ItemValueWithOrigin> shouldBePvwo : shouldBePValues) { - Mapping shouldBeMapping = shouldBePvwo.getMapping(); + for (ItemValueWithOrigin,PrismPropertyDefinition> shouldBePvwo : shouldBePValues) { + Mapping shouldBeMapping = shouldBePvwo.getMapping(); if (shouldBeMapping == null) { continue; } @@ -330,7 +332,7 @@ private void reconcileProjectionAttributes( private void reconcileProjectionAssociations( LensProjectionContext projCtx, - Map>>> squeezedAssociations, + Map,PrismContainerDefinition>>> squeezedAssociations, RefinedObjectClassDefinition accountDefinition) throws SchemaException { PrismObject shadowNew = projCtx.getObjectNew(); @@ -347,7 +349,7 @@ private void reconcileProjectionAssociations( + projCtx.getResourceShadowDiscriminator()); } - DeltaSetTriple>> cvwoTriple = squeezedAssociations.get(assocName); + DeltaSetTriple,PrismContainerDefinition>> cvwoTriple = squeezedAssociations.get(assocName); // note: actually isIgnored is not implemented yet if (associationDefinition.isIgnored()) { @@ -373,7 +375,7 @@ private void reconcileProjectionAssociations( // } // } - Collection>> shouldBeCValues; + Collection,PrismContainerDefinition>> shouldBeCValues; if (cvwoTriple == null) { shouldBeCValues = new ArrayList<>(); } else { @@ -385,14 +387,14 @@ private void reconcileProjectionAssociations( // (and we clone them not to mess anything) PrismContainer fakeParent = prismContext.getSchemaRegistry().findContainerDefinitionByCompileTimeClass(ShadowAssociationType.class).instantiate(); - for (ItemValueWithOrigin> cvwo : shouldBeCValues) { + for (ItemValueWithOrigin,PrismContainerDefinition> cvwo : shouldBeCValues) { PrismContainerValue cvalue = cvwo.getItemValue().clone(); cvalue.setParent(fakeParent); cvwo.setItemValue(cvalue); } boolean hasStrongShouldBeCValue = false; - for (ItemValueWithOrigin> shouldBeCValue : shouldBeCValues) { + for (ItemValueWithOrigin,PrismContainerDefinition> shouldBeCValue : shouldBeCValues) { if (shouldBeCValue.getMapping() != null && shouldBeCValue.getMapping().getStrength() == MappingStrengthType.STRONG) { hasStrongShouldBeCValue = true; @@ -417,10 +419,10 @@ private void reconcileProjectionAssociations( StringBuilder sb = new StringBuilder(); sb.append("Reconciliation\nASSOCIATION: ").append(PrettyPrinter.prettyPrint(assocName)); sb.append("\n Should be:"); - for (ItemValueWithOrigin> shouldBeCValue : shouldBeCValues) { + for (ItemValueWithOrigin,PrismContainerDefinition> shouldBeCValue : shouldBeCValues) { sb.append("\n "); sb.append(shouldBeCValue.getItemValue()); - Mapping shouldBeMapping = shouldBeCValue.getMapping(); + Mapping shouldBeMapping = shouldBeCValue.getMapping(); if (shouldBeMapping.getStrength() == MappingStrengthType.STRONG) { sb.append(" STRONG"); } @@ -491,8 +493,8 @@ private void checkType(Object o) { } }; - for (ItemValueWithOrigin> shouldBeCvwo : shouldBeCValues) { - Mapping shouldBeMapping = shouldBeCvwo.getMapping(); + for (ItemValueWithOrigin,PrismContainerDefinition> shouldBeCvwo : shouldBeCValues) { + Mapping shouldBeMapping = shouldBeCvwo.getMapping(); if (shouldBeMapping == null) { continue; } @@ -518,7 +520,7 @@ private void checkType(Object o) { private void decideIfTolerate(LensProjectionContext accCtx, RefinedAttributeDefinition attributeDefinition, Collection> arePValues, - Collection>> shouldBePValues, + Collection,PrismPropertyDefinition>> shouldBePValues, ValueMatcher valueMatcher) throws SchemaException { for (PrismPropertyValue isPValue : arePValues){ @@ -548,7 +550,7 @@ private void decideIfTolerate(LensProjectionContext accCtx, private void decideIfTolerateAssociation(LensProjectionContext accCtx, RefinedAssociationDefinition associationDefinition, Collection> areCValues, - Collection>> shouldBeCValues, + Collection,PrismContainerDefinition>> shouldBeCValues, ValueMatcher valueMatcher) throws SchemaException { for (PrismContainerValue isCValue : areCValues){ @@ -694,8 +696,8 @@ private boolean isInAssociationValues(ValueMatcher valueMatcher, ShadowAssociati } private boolean isInPvwoValues(Object value, - Collection>> shouldBePvwos) { - for (ItemValueWithOrigin> shouldBePvwo : shouldBePvwos) { + Collection,PrismPropertyDefinition>> shouldBePvwos) { + for (ItemValueWithOrigin,PrismPropertyDefinition> shouldBePvwo : shouldBePvwos) { PrismPropertyValue shouldBePPValue = shouldBePvwo.getPropertyValue(); Object shouldBeValue = shouldBePPValue.getValue(); if (shouldBeValue.equals(value)) { @@ -706,13 +708,13 @@ private boolean isInPvwoValues(Object value, } private boolean isInPvwoValues(ValueMatcher valueMatcher, Object value, - Collection>> shouldBePvwos) { + Collection,PrismPropertyDefinition>> shouldBePvwos) { if (shouldBePvwos == null || shouldBePvwos.isEmpty()) { return false; } - for (ItemValueWithOrigin> shouldBePvwo : shouldBePvwos) { + for (ItemValueWithOrigin,PrismPropertyDefinition> shouldBePvwo : shouldBePvwos) { PrismPropertyValue shouldBePPValue = shouldBePvwo.getPropertyValue(); Object shouldBeValue = shouldBePPValue.getValue(); if (valueMatcher.match(value, shouldBeValue)) { @@ -726,13 +728,13 @@ private boolean isInPvwoValues(ValueMatcher valueMatcher, Object value, } private boolean isInCvwoAssociationValues(ValueMatcher valueMatcher, ShadowAssociationType value, - Collection>> shouldBeCvwos) { + Collection,PrismContainerDefinition>> shouldBeCvwos) { if (shouldBeCvwos == null || shouldBeCvwos.isEmpty()) { return false; } - for (ItemValueWithOrigin> shouldBeCvwo : shouldBeCvwos) { + for (ItemValueWithOrigin,PrismContainerDefinition> shouldBeCvwo : shouldBeCvwos) { PrismContainerValue shouldBePCValue = shouldBeCvwo.getItemValue(); ShadowAssociationType shouldBeValue = shouldBePCValue.getValue(); if (valueMatcher.match(value, shouldBeValue)) { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/scripting/actions/DiscoverConnectorsExecutor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/scripting/actions/DiscoverConnectorsExecutor.java index 9c265222177..e0b433c4e07 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/scripting/actions/DiscoverConnectorsExecutor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/scripting/actions/DiscoverConnectorsExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,8 +77,8 @@ public Data execute(ActionExpressionType expression, Data input, ExecutionContex PrismObject connectorHostTypePrismObject = (PrismObject) item; Set newConnectors; try { - newConnectors = modelService.discoverConnectors(connectorHostTypePrismObject.asObjectable(), result); - } catch (CommunicationException | SecurityViolationException | SchemaException e) { + newConnectors = modelService.discoverConnectors(connectorHostTypePrismObject.asObjectable(), context.getTask(), result); + } catch (CommunicationException | SecurityViolationException | SchemaException | ConfigurationException | ObjectNotFoundException e) { throw new ScriptExecutionException("Couldn't discover connectors from " + connectorHostTypePrismObject, e); } context.println("Discovered " + newConnectors.size() + " new connector(s) from " + connectorHostTypePrismObject); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/UserProfileServiceImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/UserProfileServiceImpl.java index d1dcb1fe9e5..d7f6d727b4f 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/UserProfileServiceImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/security/UserProfileServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import com.evolveum.midpoint.model.impl.lens.LensContext; import com.evolveum.midpoint.model.impl.lens.LensContextPlaceholder; import com.evolveum.midpoint.model.impl.lens.LensUtil; +import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; @@ -187,7 +188,7 @@ private void addAuthorizations(MidPointPrincipal principal) { OperationResult result = task.getResult(); for(AssignmentType assignmentType: userType.getAssignment()) { try { - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.recompute(); EvaluatedAssignment assignment = assignmentEvaluator.evaluate(assignmentIdi, false, userType, userType.toString(), task, result); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/CorrelationConfirmationEvaluator.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/CorrelationConfirmationEvaluator.java index 427c6ccd5a6..84db2f41f89 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/CorrelationConfirmationEvaluator.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/CorrelationConfirmationEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -380,9 +380,9 @@ public boolean evaluateConfirmationExpression(Class foc ExpressionVariables variables = Utils.getDefaultExpressionVariables(user, shadow, resource, configuration); String shortDesc = "confirmation expression for "+resource.asPrismObject(); - PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition(ExpressionConstants.OUTPUT_ELMENT_NAME, + PrismPropertyDefinition outputDefinition = new PrismPropertyDefinition<>(ExpressionConstants.OUTPUT_ELMENT_NAME, DOMUtil.XSD_BOOLEAN, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, outputDefinition, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, variables, shortDesc, task, result); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java index 57d56ad2c75..0ec49103b93 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -193,7 +193,7 @@ public void visit(Visitable visitable) { if (objectDelta.isAdd()) { objectDelta.getObjectToAdd().accept(visitor); } else if (objectDelta.isModify()) { - for (ItemDelta delta : objectDelta.getModifications()) { + for (ItemDelta delta : objectDelta.getModifications()) { applyVisitorToValues(delta.getValuesToAdd(), delta, visitor); applyVisitorToValues(delta.getValuesToReplace(), delta, visitor); } @@ -201,8 +201,8 @@ public void visit(Visitable visitable) { } // see description in caller - private static void applyVisitorToValues(Collection values, ItemDelta delta, Visitor visitor) { - Collection valuesToDelete = delta.getValuesToDelete(); + private static void applyVisitorToValues(Collection values, ItemDelta delta, Visitor visitor) { + Collection valuesToDelete = delta.getValuesToDelete(); if (valuesToDelete == null) { valuesToDelete = new ArrayList<>(0); // just to simplify the code below } @@ -212,7 +212,7 @@ private static void applyVisitorToValues(Collection values, ItemDelt pval.accept(visitor); if (!isToBeDeleted && valuesToDelete.contains(pval)) { // value becomes 'to be deleted' -> we remove it from toBeDeleted list - delta.removeValueToDelete(pval); + ((ItemDelta)delta).removeValueToDelete(pval); } } } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentEvaluator.java index 81669ef800d..877479fe8ca 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentEvaluator.java @@ -37,6 +37,7 @@ import com.evolveum.midpoint.prism.delta.PlusMinusZero; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -57,6 +58,7 @@ import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; @@ -121,7 +123,7 @@ public void testDirect() throws Exception { ObjectDeltaObject userOdo = new ObjectDeltaObject<>(userTypeJack.asPrismObject(), null, null); userOdo.recompute(); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.recompute(); @@ -161,7 +163,7 @@ public void testDirectExpression() throws Exception { userOdo.recompute(); AssignmentEvaluator assignmentEvaluator = createAssignmentEvaluator(userOdo); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.recompute(); @@ -212,7 +214,7 @@ public void testDirectExpressionReplaceDescription() throws Exception { userOdo.recompute(); AssignmentEvaluator assignmentEvaluator = createAssignmentEvaluator(userOdo); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.setSubItemDeltas((Collection)userDelta.getModifications()); assignmentIdi.recompute(); @@ -235,7 +237,7 @@ public void testDirectExpressionReplaceDescription() throws Exception { Construction construction = evaluatedAssignment.getConstructions().getZeroSet().iterator().next(); assertNotNull("No object class definition in construction", construction.getRefinedObjectClassDefinition()); assertEquals(1,construction.getAttributeMappings().size()); - Mapping> attributeMapping = (Mapping>) construction.getAttributeMappings().iterator().next(); + Mapping,PrismPropertyDefinition> attributeMapping = (Mapping,PrismPropertyDefinition>) construction.getAttributeMappings().iterator().next(); PrismValueDeltaSetTriple> outputTriple = attributeMapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); PrismAsserts.assertTriplePlus(outputTriple, "The best captain the world has ever seen"); @@ -279,7 +281,7 @@ public void testDirectExpressionReplaceDescriptionFromNull() throws Exception { userOdo.recompute(); AssignmentEvaluator assignmentEvaluator = createAssignmentEvaluator(userOdo); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.setSubItemDeltas((Collection)userDelta.getModifications()); assignmentIdi.recompute(); @@ -302,7 +304,7 @@ public void testDirectExpressionReplaceDescriptionFromNull() throws Exception { Construction construction = evaluatedAssignment.getConstructions().getZeroSet().iterator().next(); assertNotNull("No object class definition in construction", construction.getRefinedObjectClassDefinition()); assertEquals(1,construction.getAttributeMappings().size()); - Mapping> attributeMapping = (Mapping>) construction.getAttributeMappings().iterator().next(); + Mapping,PrismPropertyDefinition> attributeMapping = (Mapping,PrismPropertyDefinition>) construction.getAttributeMappings().iterator().next(); PrismValueDeltaSetTriple> outputTriple = attributeMapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); PrismAsserts.assertTriplePlus(outputTriple, "The best sailor the world has ever seen"); @@ -356,7 +358,7 @@ public void testRoleVisitor() throws Exception { ObjectDeltaObject userOdo = new ObjectDeltaObject<>(userTypeJack.asPrismObject(), null, null); userOdo.recompute(); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.recompute(); @@ -403,7 +405,7 @@ public void testRoleEngineer() throws Exception { ObjectDeltaObject userOdo = new ObjectDeltaObject<>(userTypeJack.asPrismObject(), null, null); userOdo.recompute(); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.recompute(); @@ -455,7 +457,7 @@ public void testAddRoleEngineer() throws Exception { AssignmentEvaluator assignmentEvaluator = createAssignmentEvaluator(userOdo); PrismAsserts.assertParentConsistency(userTypeJack.asPrismObject()); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.recompute(); @@ -529,7 +531,7 @@ public void testRoleManagerChangeCostCenter() throws Exception { AssignmentEvaluator assignmentEvaluator = createAssignmentEvaluator(userOdo); PrismAsserts.assertParentConsistency(userTypeJack.asPrismObject()); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.recompute(); @@ -595,7 +597,7 @@ public void testRoleManagerRemoveCostCenter() throws Exception { AssignmentEvaluator assignmentEvaluator = createAssignmentEvaluator(userOdo); PrismAsserts.assertParentConsistency(userTypeJack.asPrismObject()); - ItemDeltaItem> assignmentIdi = new ItemDeltaItem<>(); + ItemDeltaItem,PrismContainerDefinition> assignmentIdi = new ItemDeltaItem<>(); assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType)); assignmentIdi.recompute(); @@ -632,7 +634,7 @@ public void testRoleManagerRemoveCostCenter() throws Exception { private void assertNoConstruction(EvaluatedAssignmentImpl evaluatedAssignment, PlusMinusZero constructionSet, String attributeName) { Collection> constructions = evaluatedAssignment.getConstructionSet(constructionSet); for (Construction construction : constructions) { - Mapping> mapping = construction.getAttributeMapping(new QName(MidPointConstants.NS_RI, attributeName)); + Mapping,? extends PrismPropertyDefinition> mapping = construction.getAttributeMapping(new QName(MidPointConstants.NS_RI, attributeName)); assertNull("Unexpected mapping for " + attributeName, mapping); } } @@ -641,7 +643,7 @@ private void assertConstruction(EvaluatedAssignmentImpl evaluatedAssig Collection> constructions = evaluatedAssignment.getConstructionSet(constructionSet); Set realValues = new HashSet<>(); for (Construction construction : constructions) { - Mapping> mapping = construction.getAttributeMapping(new QName(MidPointConstants.NS_RI, attributeName)); + Mapping,? extends PrismPropertyDefinition> mapping = construction.getAttributeMapping(new QName(MidPointConstants.NS_RI, attributeName)); if (mapping != null && mapping.getOutputTriple() != null) { Collection> valsInMapping = mapping.getOutputTriple().getSet(attributeSet); if (valsInMapping != null) { diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java index 8ea9c96470d..e94c4b6f9ec 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.evolveum.midpoint.model.common.mapping.Mapping; import com.evolveum.midpoint.model.impl.lens.projector.AssignmentProcessor; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.ChangeType; import com.evolveum.midpoint.prism.delta.ContainerDelta; @@ -658,7 +659,7 @@ private void assertAttributeValues(Collection Set getAttributeValues(Collection> accountConstructions, QName attrName, PlusMinusZero attributeSet) { Set retval = new HashSet<>(); for (PrismPropertyValue constructionPropVal : accountConstructions) { - Mapping> mapping = constructionPropVal.getValue().getAttributeMapping(attrName); + Mapping,? extends PrismPropertyDefinition> mapping = constructionPropVal.getValue().getAttributeMapping(attrName); if (mapping != null && mapping.getOutputTriple() != null) { Collection> values = (Collection) mapping.getOutputTriple().getSet(attributeSet); if (values != null) { @@ -672,7 +673,7 @@ private Set getAttributeValues(Collection void assertPlusAttributeValues(Construction accountConstruction, QName attrName, T... expectedValue) { - Mapping> vc = accountConstruction.getAttributeMapping(attrName); + Mapping,? extends PrismPropertyDefinition> vc = accountConstruction.getAttributeMapping(attrName); assertNotNull("No value construction for attribute "+attrName+" in plus set", vc); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); Collection actual = getMultiValueFromDeltaSetTriple(triple, triple.getPlusSet()); @@ -680,7 +681,7 @@ private void assertPlusAttributeValues(Construction accountConstruction, QNa } private void assertZeroAttributeValues(Construction accountConstruction, QName attrName, T... expectedValue) { - Mapping> vc = accountConstruction.getAttributeMapping(attrName); + Mapping,? extends PrismPropertyDefinition> vc = accountConstruction.getAttributeMapping(attrName); assertNotNull("No value construction for attribute "+attrName+" in zero set", vc); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); Collection actual = getMultiValueFromDeltaSetTriple(triple, triple.getZeroSet()); @@ -688,7 +689,7 @@ private void assertZeroAttributeValues(Construction accountConstruction, QNa } private void assertMinusAttributeValues(Construction accountConstruction, QName attrName, T... expectedValue) { - Mapping> vc = accountConstruction.getAttributeMapping(attrName); + Mapping,? extends PrismPropertyDefinition> vc = accountConstruction.getAttributeMapping(attrName); assertNotNull("No value construction for attribute "+attrName+" in minus set", vc); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); Collection actual = getMultiValueFromDeltaSetTriple(triple, triple.getMinusSet()); @@ -696,19 +697,19 @@ private void assertMinusAttributeValues(Construction accountConstruction, QN } private void assertNoPlusAttributeValues(Construction accountConstruction, QName attrName) { - Mapping> vc = accountConstruction.getAttributeMapping(attrName); + Mapping,? extends PrismPropertyDefinition> vc = accountConstruction.getAttributeMapping(attrName); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); PrismAsserts.assertTripleNoPlus(triple); } private void assertNoZeroAttributeValues(Construction accountConstruction, QName attrName) { - Mapping> vc = accountConstruction.getAttributeMapping(attrName); + Mapping,? extends PrismPropertyDefinition> vc = accountConstruction.getAttributeMapping(attrName); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); PrismAsserts.assertTripleNoZero(triple); } private void assertNoMinusAttributeValues(Construction accountConstruction, QName attrName) { - Mapping> vc = accountConstruction.getAttributeMapping(attrName); + Mapping,? extends PrismPropertyDefinition> vc = accountConstruction.getAttributeMapping(attrName); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); PrismAsserts.assertTripleNoMinus(triple); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/util/mock/MockLensDebugListener.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/util/mock/MockLensDebugListener.java index d236454ee15..e55a8855dd2 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/util/mock/MockLensDebugListener.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/util/mock/MockLensDebugListener.java @@ -63,22 +63,19 @@ public void afterSync(LensContext context) { @Override public void beforeProjection( LensContext context) { - // TODO Auto-generated method stub } @Override public void afterProjection( LensContext context) { - // TODO Auto-generated method stub } @Override public void afterMappingEvaluation( LensContext context, - Mapping evaluatedMapping) { - // TODO Auto-generated method stub + Mapping evaluatedMapping) { } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java index e6d2b4a2c42..b4e1fd60a87 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java @@ -123,7 +123,7 @@ public void test100ModifyUserAddAccount() throws Exception { PrismObject account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); PrismReferenceValue accountRefVal = new PrismReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountDelta = ReferenceDelta.createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); @@ -171,7 +171,7 @@ public void test119ModifyUserDeleteAccount() throws SchemaException, ObjectNotFo PrismObject account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE); account.setOid(accountOid); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); PrismReferenceValue accountRefVal = new PrismReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), account); @@ -245,7 +245,7 @@ public void test121ModifyUserAddAccountRef() throws SchemaException, ObjectNotFo OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); ReferenceDelta accountDelta = ReferenceDelta.createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountOid); modifications.add(accountDelta); @@ -285,7 +285,7 @@ public void test128ModifyUserDeleteAccountRef() throws SchemaException, ObjectNo PrismObject account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); PrismReferenceValue accountRefVal = new PrismReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountOid); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOrgStruct.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOrgStruct.java index 9b90be722d8..1c81a0596ca 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOrgStruct.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOrgStruct.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -193,7 +193,7 @@ public void test201JackAssignScummBarAndSaveElaine() throws Exception { Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(ORG_SCUMM_BAR_OID, OrgType.COMPLEX_TYPE, null, null, null, true)); modifications.add(createAssignmentModification(ORG_SAVE_ELAINE_OID, OrgType.COMPLEX_TYPE, null, null, null, true)); ObjectDelta userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); @@ -283,7 +283,7 @@ public void test210JackAssignMinistryOfOffenseMember() throws Exception { Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, null, null, null, true)); modifications.add(createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, true)); ObjectDelta userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); @@ -407,7 +407,7 @@ public void test221JackAssignScummBarAndSaveElaine() throws Exception { Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(ORG_SCUMM_BAR_OID, OrgType.COMPLEX_TYPE, null, null, null, true)); modifications.add(createAssignmentModification(ORG_SAVE_ELAINE_OID, OrgType.COMPLEX_TYPE, null, null, null, true)); ObjectDelta userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); @@ -437,7 +437,7 @@ public void test223JackChangeMinistryOfOffenseMemberToManager() throws Exception PrismObject jack = getUser(USER_JACK_OID); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); // this is now forbidden // Long id = findAssignmentIdForTarget(jack, ORG_MINISTRY_OF_OFFENSE_OID); @@ -513,7 +513,7 @@ public void test300JackUnassignAllOrgs() throws Exception { OperationResult result = task.getResult(); // WHEN - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, SchemaConstants.ORG_MANAGER, null, null, false))); modifications.add((createAssignmentModification(ORG_SCUMM_BAR_OID, OrgType.COMPLEX_TYPE, null, null, null, false))); modifications.add((createAssignmentModification(ORG_SAVE_ELAINE_OID, OrgType.COMPLEX_TYPE, null, null, null, false))); @@ -568,7 +568,7 @@ public void test305JackConflictZeroAndMinus() throws Exception { Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, false))); ObjectDelta userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); Collection> deltas = MiscSchemaUtil.createCollection(userDelta); @@ -603,7 +603,7 @@ protected void executeConflictPlusAndMinus(String TEST_NAME) throws Exception { Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, true))); modifications.add((createAssignmentModification(ORG_MINISTRY_OF_DEFENSE_OID, OrgType.COMPLEX_TYPE, null, null, null, false))); ObjectDelta userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); @@ -638,7 +638,7 @@ public void test308JackUnassignRoleDefender() throws Exception { OperationResult result = task.getResult(); // WHEN - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, false))); ObjectDelta userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); Collection> deltas = MiscSchemaUtil.createCollection(userDelta); @@ -1088,7 +1088,7 @@ public void test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAss PrismObject jack = getUser(USER_JACK_OID); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, null, null, null, false)); modifications.add(createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, SchemaConstants.ORG_MANAGER, null, null, true)); @@ -1123,7 +1123,7 @@ public void test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAss PrismObject jack = getUser(USER_JACK_OID); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, SchemaConstants.ORG_MANAGER, null, null, false)); modifications.add(createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, null, null, null, true)); @@ -1199,7 +1199,7 @@ public void test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignme PrismObject jack = getUser(USER_JACK_OID); Long id = findAssignmentIdForTarget(jack, ORG_MINISTRY_OF_OFFENSE_OID); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); PrismReferenceDefinition referenceDefinition = getUserDefinition() .findItemDefinition( diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOrgStructMeta.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOrgStructMeta.java index 3a5b3122a51..bfcfbc68b16 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOrgStructMeta.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOrgStructMeta.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Evolveum + * Copyright (c) 2014-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -274,7 +274,7 @@ public void test810JackAssignScummBarOrganized() throws Exception { // Precondition assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(ROLE_ORGANIZED_OID, RoleType.COMPLEX_TYPE, null, null, null, true))); modifications.add((createAssignmentModification(ORG_SCUMM_BAR_OID, OrgType.COMPLEX_TYPE, null, null, null, true))); ObjectDelta userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRbac.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRbac.java index f268741cad4..f539a72a7aa 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRbac.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRbac.java @@ -1017,7 +1017,7 @@ public void test521JackUnassignRolePirateDeleteAccount() throws Exception { Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, false)); ObjectDelta userDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java index 4dc41eab41f..42bbe048cdd 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -322,7 +322,7 @@ private void singleRandomModify(int iteration, Task task, OperationResult result private void singleModify(CarefulAnt ant, int iteration, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { // GIVEN - ItemDelta itemDelta = ant.createDelta(iteration); + ItemDelta itemDelta = ant.createDelta(iteration); ObjectDelta objectDelta = ObjectDelta.createModifyDelta(RESOURCE_DUMMY_OID, itemDelta, ResourceType.class, prismContext); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index 822f7c0d37a..92068d993f4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -22,12 +22,14 @@ import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.IdItemPathSegment; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.path.NameItemPathSegment; +import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectPaging; import com.evolveum.midpoint.prism.query.OrderDirection; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -41,6 +43,7 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.Validator; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; @@ -51,9 +54,11 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -64,6 +69,8 @@ import java.io.File; import java.util.Collection; +import javax.xml.namespace.QName; + import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; @@ -1003,17 +1010,17 @@ public void test200EditSchemaUser() throws Exception { // THEN TestUtil.displayThen(TEST_NAME); - PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); + PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); assertNotNull("No definition for additionalName in user", additionalNameDef); assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); assertTrue("additionalName not readable", additionalNameDef.canRead()); - PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); + PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); assertNotNull("No definition for costCenter in user", costCenterDef); assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); assertTrue("costCenter not readable", costCenterDef.canRead()); - PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); + PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); @@ -1026,16 +1033,89 @@ public void test200EditSchemaUser() throws Exception { assertTrue("Credentials not readable", credentialsDef.canRead()); ItemPath passwdValPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); - PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); + PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); assertTrue("Password not readable", passwdValDef.canRead()); assertSteadyResources(); } - + @Test - public void test210EditSchemaRole() throws Exception { - final String TEST_NAME="test210EditSchemaRole"; + public void test210UserDefinition() throws Exception { + final String TEST_NAME="test210UserDefinition"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertProperty(user, UserType.F_ADDITIONAL_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue("additionalName not readable", propDef.canRead()); + } + }); + + assertProperty(user, UserType.F_COST_CENTER, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue("costCenter not readable", propDef.canRead()); + } + }); + + assertProperty(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + assertTrue("preferredLanguage not readable", propDef.canRead()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + } + }); + + +// PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); +// assertNotNull("No definition for credentials in user", credentialsDef); +// assertTrue("Credentials not readable", credentialsDef.canRead()); +// +// ItemPath passwdValPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); +// PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); +// assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); +// assertTrue("Password not readable", passwdValDef.canRead()); + + assertSteadyResources(); + } + + private void assertProperty(PrismObject object, QName propName, + Validator> validator) throws Exception { + PrismProperty prop = object.findProperty(propName); + PrismPropertyDefinition propDef = prop.getDefinition(); + assertNotNull("No definition in property "+propName, propDef); + validator.validate(propDef, propName.toString()); + + PrismPropertyDefinition objPropDef = object.getDefinition().findPropertyDefinition(propName); + assertNotNull("No definition of property "+propName+" in object "+object, objPropDef); + validator.validate(objPropDef, propName.toString()); + } + + @Test + public void test250EditSchemaRole() throws Exception { + final String TEST_NAME="test250EditSchemaRole"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/util/ProfilingLensDebugListener.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/util/ProfilingLensDebugListener.java index b24c7de60e4..7d942efb47d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/util/ProfilingLensDebugListener.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/util/ProfilingLensDebugListener.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2010-2015 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.evolveum.midpoint.model.intest.util; import java.util.Collection; @@ -91,7 +107,7 @@ public LensContext getLastLensContext() { } @Override - public void afterMappingEvaluation(LensContext context, Mapping evaluatedMapping) { + public void afterMappingEvaluation(LensContext context, Mapping evaluatedMapping) { mappingTotalMillis += evaluatedMapping.getEtime(); projectorMappingTotalMillis += evaluatedMapping.getEtime(); projectorMappingTotalCount++; diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 7b1415b8c9d..34b640f0450 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -751,7 +751,7 @@ protected void unassignAllRoles(String userOid) throws ObjectNotFoundException, Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class+".unassignAllRoles"); OperationResult result = task.getResult(); PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); for (AssignmentType assignment: user.asObjectable().getAssignment()) { ObjectReferenceType targetRef = assignment.getTargetRef(); if (targetRef != null) { @@ -858,7 +858,7 @@ protected ObjectDelta createAssignmentUserDelta(String userOid, String protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); ObjectDelta userDelta = ObjectDelta.createModifyDelta(userOid, modifications, UserType.class, prismContext); return userDelta; @@ -926,7 +926,7 @@ protected ObjectDelta createReplaceAccountConstructionUserDelta(String // ppd, // newValue); - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add(acDelta); ObjectDelta userDelta = ObjectDelta.createModifyDelta(userOid, modifications, UserType.class, prismContext); return userDelta; @@ -938,7 +938,7 @@ protected ObjectDelta createAccountAssignmentUserDelta(String userOid, protected ObjectDelta createAssignmentDelta(Class type, String focusOid, String resourceOid, ShadowKindType kind, String intent, boolean add) throws SchemaException { - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(resourceOid, kind, intent, add)); ObjectDelta userDelta = ObjectDelta.createModifyDelta(focusOid, modifications, type, prismContext); return userDelta; @@ -1958,7 +1958,7 @@ protected void assertSideEffectiveDeltasOnly(String desc, } int expectedModifications = 0; // There may be metadata modification, we tolerate that - Collection> metadataDelta = focusDelta.findItemDeltasSubPath(new ItemPath(UserType.F_METADATA)); + Collection> metadataDelta = focusDelta.findItemDeltasSubPath(new ItemPath(UserType.F_METADATA)); if (metadataDelta != null && !metadataDelta.isEmpty()) { expectedModifications++; } @@ -1990,7 +1990,7 @@ protected void assertSideEffectiveDeltasOnly(ObjectDelta> metadataDelta = focusDelta.findItemDeltasSubPath(new ItemPath(UserType.F_METADATA)); + Collection> metadataDelta = focusDelta.findItemDeltasSubPath(new ItemPath(UserType.F_METADATA)); if (metadataDelta != null && !metadataDelta.isEmpty()) { expectedModifications++; } diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/SimpleSmsTransport.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/SimpleSmsTransport.java index ce586bbf173..14442648feb 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/SimpleSmsTransport.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/SimpleSmsTransport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -228,9 +228,9 @@ private String evaluateExpression(ExpressionType expressionType, ExpressionVaria String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { QName resultName = new QName(SchemaConstants.NS_C, "result"); - PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_STRING, prismContext); + PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_STRING, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResult = expression.evaluate(params); diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/handlers/BaseHandler.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/handlers/BaseHandler.java index 0286b7a810f..ccfd54b16a3 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/handlers/BaseHandler.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/handlers/BaseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,8 +128,8 @@ protected boolean evaluateBooleanExpression(ExpressionType expressionType, Expre Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { QName resultName = new QName(SchemaConstants.NS_C, "result"); - PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_BOOLEAN, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); + PrismPropertyDefinition resultDef = new PrismPropertyDefinition<>(resultName, DOMUtil.XSD_BOOLEAN, prismContext); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResultTriple = expression.evaluate(params); @@ -166,9 +166,9 @@ private List evaluateExpression(ExpressionType expressionType, Expressio String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { QName resultName = new QName(SchemaConstants.NS_C, "result"); - PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_STRING, prismContext); + PrismPropertyDefinition resultDef = new PrismPropertyDefinition<>(resultName, DOMUtil.XSD_STRING, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResult = expression.evaluate(params); diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/helpers/BaseHelper.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/helpers/BaseHelper.java index 93dbc1401fb..ef4bb7ac1b2 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/helpers/BaseHelper.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/helpers/BaseHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,8 +121,8 @@ protected boolean evaluateBooleanExpression(ExpressionType expressionType, Expre Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { QName resultName = new QName(SchemaConstants.NS_C, "result"); - PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_BOOLEAN, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); + PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_BOOLEAN, prismContext); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResultTriple = expression.evaluate(params); @@ -159,9 +159,9 @@ private List evaluateExpression(ExpressionType expressionType, Expressio String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException { QName resultName = new QName(SchemaConstants.NS_C, "result"); - PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_STRING, prismContext); + PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_STRING, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResult = expression.evaluate(params); diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/GeneralNotifier.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/GeneralNotifier.java index f46c4dbb609..68ba26bf618 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/GeneralNotifier.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/GeneralNotifier.java @@ -287,7 +287,7 @@ protected boolean isWatchAuxiliaryAttributes(GeneralNotifierType generalNotifier protected void appendModifications(StringBuilder body, ObjectDelta delta, List hiddenPaths, Boolean showValuesBoolean) { boolean showValues = !Boolean.FALSE.equals(showValuesBoolean); - for (ItemDelta itemDelta : delta.getModifications()) { + for (ItemDelta itemDelta : delta.getModifications()) { if (NotificationsUtil.isAmongHiddenPaths(itemDelta.getPath(), hiddenPaths)) { continue; } diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportFunctions.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportFunctions.java index fec41d9332a..77199d57007 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportFunctions.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportFunctions.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2010-2015 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.evolveum.midpoint.report.impl; import java.util.ArrayList; @@ -196,7 +212,7 @@ public UserType getShadowOwner(String shadowOid){ try { PrismObject owner = model.findShadowOwner(shadowOid, task, task.getResult()); return owner.asObjectable(); - } catch (ObjectNotFoundException | SecurityViolationException | SchemaException e) { + } catch (ObjectNotFoundException | SecurityViolationException | SchemaException | ConfigurationException e) { // TODO Auto-generated catch block LOGGER.error("Could not find owner for shadow with oid " + shadowOid + ". Reason: " + e.getMessage()); } diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportManagerImpl.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportManagerImpl.java index 82d4b809c0e..dc17b169379 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportManagerImpl.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,6 +85,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType; import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportParameterType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType; @@ -243,7 +244,7 @@ public HookOperationMode invoke(ModelContext context, Task task, OperationResult if (reportType.getTemplate() == null) { PrismSchema reportSchema = null; - PrismContainer parameterConfiguration = null; + PrismContainer parameterConfiguration = null; try { reportSchema = ReportUtils.getParametersSchema(reportType, prismContext); diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportUtils.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportUtils.java index 53c05669ea6..dfd2b201382 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportUtils.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/ReportUtils.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2010-2015 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.evolveum.midpoint.report.impl; @@ -303,10 +319,10 @@ public static PrismSchema getParametersSchema(ReportType reportType, PrismContex return parametersSchema; } - public static PrismContainer getParametersContainer(ReportType reportType, PrismSchema schema) + public static PrismContainer getParametersContainer(ReportType reportType, PrismSchema schema) throws SchemaException, ObjectNotFoundException { - PrismContainer configuration = reportType.asPrismObject().findContainer(ReportType.F_CONFIGURATION); + PrismContainer configuration = reportType.asPrismObject().findContainer(ReportType.F_CONFIGURATION); if (configuration == null) { return null; // throw new SchemaException("No configuration container in " + reportType); @@ -355,7 +371,7 @@ public static PrismContainer getParametersContainer(ReportType re return configuration; } - public static JasperReport getJasperReport(ReportType reportType, PrismContainer parameterConfiguration, PrismSchema reportSchema) throws JRException + public static JasperReport getJasperReport(ReportType reportType, PrismContainer parameterConfiguration, PrismSchema reportSchema) throws JRException { JasperDesign jasperDesign; JasperReport jasperReport; @@ -503,7 +519,7 @@ public static Class getObjectTypeClass(Object objectClass) } - public static PrismProperty getParameter(String parameterName, PrismContainer parameterConfiguration, String namespace) + public static PrismProperty getParameter(String parameterName, PrismContainer parameterConfiguration, String namespace) { if (parameterConfiguration == null){ return null; @@ -738,7 +754,7 @@ private static void createStyles(JasperDesign jasperDesign) throws JRException jasperDesign.addStyle(pageFooterStyle); } - private static JRDesignBand createTitleBand(int height, int reportColumn, int secondColumn, PrismContainer parameterConfiguration, PrismSchema reportSchema) + private static JRDesignBand createTitleBand(int height, int reportColumn, int secondColumn, PrismContainer parameterConfiguration, PrismSchema reportSchema) { JRDesignBand titleBand = createBand(height); JRDesignFrame frame = createFrame(0, 0, 70, reportColumn, "Title"); @@ -859,7 +875,7 @@ private static JRDesignBand createPageFooterBand(int height, int reportColumn) return pageFooterBand; } - public static JasperDesign createJasperDesign(ReportType reportType, PrismContainer parameterConfiguration, PrismSchema reportSchema) throws JRException + public static JasperDesign createJasperDesign(ReportType reportType, PrismContainer parameterConfiguration, PrismSchema reportSchema) throws JRException { //JasperDesign diff --git a/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processes/itemApproval/InitializeLoopThroughApproversInLevel.java b/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processes/itemApproval/InitializeLoopThroughApproversInLevel.java index 323e0e665ea..14c30c5041f 100644 --- a/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processes/itemApproval/InitializeLoopThroughApproversInLevel.java +++ b/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processes/itemApproval/InitializeLoopThroughApproversInLevel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -140,8 +140,8 @@ private Collection evaluateExpression(ExpressionType appro PrismContext prismContext = expressionFactory.getPrismContext(); QName approverOidName = new QName(SchemaConstants.NS_C, "approverOid"); - PrismPropertyDefinition approverOidDef = new PrismPropertyDefinition(approverOidName, DOMUtil.XSD_STRING, prismContext); - Expression> expression = expressionFactory.makeExpression(approverExpression, approverOidDef, "approverExpression", result); + PrismPropertyDefinition approverOidDef = new PrismPropertyDefinition(approverOidName, DOMUtil.XSD_STRING, prismContext); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(approverExpression, approverOidDef, "approverExpression", result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, "approverExpression", task, result); PrismValueDeltaSetTriple> exprResult = expression.evaluate(params); @@ -163,8 +163,8 @@ private boolean evaluateBooleanExpression(ExpressionType expressionType, Express PrismContext prismContext = expressionFactory.getPrismContext(); QName resultName = new QName(SchemaConstants.NS_C, "result"); - PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_BOOLEAN, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, resultDef, "automatic approval expression", result); + PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_BOOLEAN, prismContext); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, "automatic approval expression", result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, "automatic approval expression", task, result); PrismValueDeltaSetTriple> exprResultTriple = expression.evaluate(params); diff --git a/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processors/general/GcpExpressionHelper.java b/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processors/general/GcpExpressionHelper.java index 1384bd0495c..a902ea6ac66 100644 --- a/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processors/general/GcpExpressionHelper.java +++ b/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processors/general/GcpExpressionHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,8 +81,8 @@ private boolean evaluateBooleanExpression(ExpressionType expressionType, Express PrismContext prismContext = expressionFactory.getPrismContext(); QName resultName = new QName(SchemaConstants.NS_C, "result"); - PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_BOOLEAN, prismContext); - Expression> expression = expressionFactory.makeExpression(expressionType, resultDef, opContext, result); + PrismPropertyDefinition resultDef = new PrismPropertyDefinition(resultName, DOMUtil.XSD_BOOLEAN, prismContext); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, opContext, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, opContext, taskFromModel, result); PrismValueDeltaSetTriple> exprResultTriple = expression.evaluate(params); diff --git a/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processors/primary/assignments/AddAssignmentAspect.java b/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processors/primary/assignments/AddAssignmentAspect.java index c2e675fda0c..40c90b1815a 100644 --- a/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processors/primary/assignments/AddAssignmentAspect.java +++ b/model/workflow-impl/src/main/java/com/evolveum/midpoint/wf/impl/processors/primary/assignments/AddAssignmentAspect.java @@ -265,7 +265,7 @@ private ObjectDelta assignmentToDelta(ModelContext mode PrismObject focus = (PrismObject) modelContext.getFocusContext().getObjectNew(); PrismContainerDefinition prismContainerDefinition = focus.getDefinition().findContainerDefinition(FocusType.F_ASSIGNMENT); - ItemDelta> addRoleDelta = new ContainerDelta<>(new ItemPath(), FocusType.F_ASSIGNMENT, prismContainerDefinition, prismContext); + ItemDelta,PrismContainerDefinition> addRoleDelta = new ContainerDelta<>(new ItemPath(), FocusType.F_ASSIGNMENT, prismContainerDefinition, prismContext); PrismContainerValue assignmentValue = assignmentType.asPrismContainerValue().clone(); addRoleDelta.addValueToAdd(assignmentValue); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/TestUserChangeApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/TestUserChangeApproval.java index cacdfed3506..04e18c11008 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/TestUserChangeApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/TestUserChangeApproval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -791,19 +791,21 @@ protected void modifyAssignmentValidity(LensContext context, UserType assertNotNull("no activationDef", activationDef); Long assignmentId = jack.getAssignment().get(0).getId(); + PrismPropertyDefinition validFromDef = activationDef.findPropertyDefinition(ActivationType.F_VALID_FROM); PropertyDelta validFromDelta = new PropertyDelta<>( new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(assignmentId), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_VALID_FROM)), - activationDef.findPropertyDefinition(ActivationType.F_VALID_FROM), prismContext); + validFromDef, prismContext); validFromDelta.setValueToReplace(new PrismPropertyValue<>(validFrom)); + PrismPropertyDefinition validToDef = activationDef.findPropertyDefinition(ActivationType.F_VALID_TO); PropertyDelta validToDelta = new PropertyDelta<>( new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(assignmentId), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_VALID_TO)), - activationDef.findPropertyDefinition(ActivationType.F_VALID_TO), prismContext); + validToDef, prismContext); validToDelta.setValueToReplace(new PrismPropertyValue<>(validTo)); ObjectDelta userDelta = new ObjectDelta<>(UserType.class, ChangeType.MODIFY, prismContext); diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java index 66c4b2741d1..a7f78b275f3 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,9 @@ import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismReferenceDefinition; import com.evolveum.midpoint.prism.PrismReferenceValue; +import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.delta.ContainerDelta; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ObjectDelta; @@ -401,7 +403,7 @@ private void completeSchemaAndCapabilities(PrismObject resource, R return; } - Collection> modifications = new ArrayList>(); + Collection> modifications = new ArrayList<>(); // Schema if (fetchedSchema) { @@ -441,7 +443,7 @@ private void completeSchemaAndCapabilities(PrismObject resource, R ObjectDelta capabilitiesReplaceDelta = ObjectDelta.createModificationReplaceContainer(ResourceType.class, resource.getOid(), ResourceType.F_CAPABILITIES, prismContext, capType.asPrismContainerValue().clone()); - modifications.addAll((Collection>) capabilitiesReplaceDelta.getModifications()); + modifications.addAll(capabilitiesReplaceDelta.getModifications()); if (fetchedSchema) { // We have successfully fetched the resource schema. Therefore the resource must be up. @@ -522,7 +524,7 @@ private void applyConnectorSchemaToResource(PrismObject resource, if (configurationContainerDefintion == null) { throw new SchemaException("No configuration container definition in schema of " + connectorType); } - PrismContainer configurationContainer = ResourceTypeUtil + PrismContainer configurationContainer = ResourceTypeUtil .getConfigurationContainer(resource); if (configurationContainer == null) { throw new SchemaException("No configuration container in " + resource); @@ -863,7 +865,7 @@ public void applyDefinition(ObjectDelta delta, ResourceType resour ResourceType resourceType = resource.asObjectable(); // ResourceType resourceType = completeResource(resource.asObjectable(), null, objectResult); //TODO TODO TODO FIXME FIXME FIXME copied from ObjectImprted..union this two cases - PrismContainer configurationContainer = ResourceTypeUtil.getConfigurationContainer(resourceType); + PrismContainer configurationContainer = ResourceTypeUtil.getConfigurationContainer(resourceType); if (configurationContainer == null || configurationContainer.isEmpty()) { // Nothing to check objectResult.recordWarning("The resource has no configuration"); @@ -881,7 +883,7 @@ public void applyDefinition(ObjectDelta delta, ResourceType resour ReferenceDelta connectorRefDelta = ReferenceDelta.findReferenceModification(delta.getModifications(), ResourceType.F_CONNECTOR_REF); if (connectorRefDelta != null){ - Item connectorRefNew = connectorRefDelta.getItemNewMatchingPath(null); + Item connectorRefNew = connectorRefDelta.getItemNewMatchingPath(null); if (connectorRefNew.getValues().size() == 1){ PrismReferenceValue connectorRefValue = connectorRefNew.getValues().iterator().next(); if (connectorRefValue.getOid() != null && !connectorOid.equals(connectorRefValue.getOid())){ @@ -921,7 +923,7 @@ public void applyDefinition(ObjectDelta delta, ResourceType resour return; } QName configContainerQName = new QName(connectorType.getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart()); - PrismContainerDefinition configContainerDef = connectorSchema.findContainerDefinitionByElementName(configContainerQName); + PrismContainerDefinition configContainerDef = connectorSchema.findContainerDefinitionByElementName(configContainerQName); if (configContainerDef == null) { objectResult.recordFatalError("Definition of configuration container " + configContainerQName + " not found in the schema of of " + connector); return; @@ -936,33 +938,36 @@ public void applyDefinition(ObjectDelta delta, ResourceType resour resourceType.asPrismObject().findContainer(ResourceType.F_CONNECTOR_CONFIGURATION).applyDefinition(configContainerDef); - for (ItemDelta itemDelta : delta.getModifications()){ - if (itemDelta.getParentPath() == null){ - LOGGER.trace("No parent path defined for item delta {}", itemDelta); - continue; - } - - QName first = ItemPath.getName(itemDelta.getParentPath().first()); - - if (first == null){ - continue; - } - - if (itemDelta.getDefinition() == null && (ResourceType.F_CONNECTOR_CONFIGURATION.equals(first) || ResourceType.F_SCHEMA.equals(first))){ - ItemPath path = itemDelta.getPath().rest(); - ItemDefinition itemDef = configContainerDef.findItemDefinition(path); - if (itemDef == null){ - LOGGER.warn("No definition found for item {}. Check your namespaces?", path); - objectResult.recordWarning("No definition found for item delta: " + itemDelta +". Check your namespaces?" ); -// throw new SchemaException("No definition found for item " + path+ ". Check your namespaces?" ); - continue; - } - itemDelta.applyDefinition(itemDef); - - } + for (ItemDelta itemDelta : delta.getModifications()){ + applyItemDefinition(itemDelta, configContainerDef, objectResult); } - - + } + + private void applyItemDefinition(ItemDelta itemDelta, + PrismContainerDefinition configContainerDef, OperationResult objectResult) throws SchemaException { + if (itemDelta.getParentPath() == null){ + LOGGER.trace("No parent path defined for item delta {}", itemDelta); + return; + } + + QName first = ItemPath.getName(itemDelta.getParentPath().first()); + + if (first == null){ + return; + } + + if (itemDelta.getDefinition() == null && (ResourceType.F_CONNECTOR_CONFIGURATION.equals(first) || ResourceType.F_SCHEMA.equals(first))){ + ItemPath path = itemDelta.getPath().rest(); + D itemDef = configContainerDef.findItemDefinition(path); + if (itemDef == null){ + LOGGER.warn("No definition found for item {}. Check your namespaces?", path); + objectResult.recordWarning("No definition found for item delta: " + itemDelta +". Check your namespaces?" ); +// throw new SchemaException("No definition found for item " + path+ ". Check your namespaces?" ); + return; + } + itemDelta.applyDefinition(itemDef); + + } } public void applyDefinition(PrismObject resource, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java index 162cf61ee4a..aa027d4a1d2 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ import com.evolveum.midpoint.prism.PrismObjectDefinition; import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismPropertyValue; +import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.Visitable; import com.evolveum.midpoint.prism.Visitor; import com.evolveum.midpoint.prism.delta.ChangeType; @@ -1395,34 +1396,38 @@ private ObjectClassComplexTypeDefinition applyAttributesDefinition(ObjectDelta itemDelta: delta.getModifications()) { - ItemDefinition itemDef = itemDelta.getDefinition(); - if ((itemDef == null || !(itemDef instanceof ResourceAttributeDefinition)) && attributesPath.equivalent(itemDelta.getParentPath())) { - QName attributeName = itemDelta.getElementName(); - ResourceAttributeDefinition attributeDefinition = objectClassDefinition.findAttributeDefinition(attributeName); - if (attributeDefinition == null) { - throw new SchemaException("No definition for attribute "+attributeName+" in object delta "+delta); - } - if (itemDef != null) { - // We are going to rewrite the definition anyway. Let's just do some basic checks first - if (!QNameUtil.match(itemDef.getTypeName(),attributeDefinition.getTypeName())) { - throw new SchemaException("The value of type "+itemDef.getTypeName()+" cannot be applied to attribute "+attributeName+" which is of type "+attributeDefinition.getTypeName()); - } - } - itemDelta.applyDefinition(attributeDefinition); - } + for(ItemDelta itemDelta: delta.getModifications()) { + applyAttributeDefinition(delta, itemDelta, objectClassDefinition); } + } return objectClassDefinition; } + + private void applyAttributeDefinition(ObjectDelta delta, ItemDelta itemDelta, ObjectClassComplexTypeDefinition objectClassDefinition) throws SchemaException { + D itemDef = itemDelta.getDefinition(); + if ((itemDef == null || !(itemDef instanceof ResourceAttributeDefinition)) && SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getParentPath())) { + QName attributeName = itemDelta.getElementName(); + ResourceAttributeDefinition attributeDefinition = objectClassDefinition.findAttributeDefinition(attributeName); + if (attributeDefinition == null) { + throw new SchemaException("No definition for attribute "+attributeName+" in object delta "+delta); + } + if (itemDef != null) { + // We are going to rewrite the definition anyway. Let's just do some basic checks first + if (!QNameUtil.match(itemDef.getTypeName(),attributeDefinition.getTypeName())) { + throw new SchemaException("The value of type "+itemDef.getTypeName()+" cannot be applied to attribute "+attributeName+" which is of type "+attributeDefinition.getTypeName()); + } + } + itemDelta.applyDefinition((D) attributeDefinition); + } + } public RefinedObjectClassDefinition applyAttributesDefinition( PrismObject shadow, ResourceType resource) throws SchemaException, ConfigurationException { RefinedObjectClassDefinition objectClassDefinition = RefinedObjectClassDefinition.determineObjectClassDefinition(shadow, resource); - PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); + PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); if (attributesContainer != null) { if (attributesContainer instanceof ResourceAttributeContainer) { if (attributesContainer.getDefinition() == null) { diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java index d54961f95cb..7201583d5fd 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -674,10 +674,10 @@ private void normalizeAttribute(ResourceAttribute attribute, RefinedAttri } } - public void normalizeDeltas(Collection>> deltas, + public void normalizeDeltas(Collection,PrismPropertyDefinition>> deltas, RefinedObjectClassDefinition objectClassDefinition) throws SchemaException { // TODO Auto-generated method stub - for (ItemDelta> delta : deltas){ + for (ItemDelta,PrismPropertyDefinition> delta : deltas){ if (!ShadowType.F_ATTRIBUTES.equals(ItemPath.getName(delta.getPath().first()))){ continue; } @@ -691,7 +691,7 @@ public void normalizeDeltas(Collection void normalizeDelta(ItemDelta> delta, RefinedAttributeDefinition rAttrDef) throws SchemaException{ + private void normalizeDelta(ItemDelta,PrismPropertyDefinition> delta, RefinedAttributeDefinition rAttrDef) throws SchemaException{ MatchingRule matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName()); if (matchingRule != null) { if (delta.getValuesToReplace() != null){ diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/ProvisioningTestUtil.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/ProvisioningTestUtil.java index fcbc1cf9788..01aa03cc66a 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/ProvisioningTestUtil.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/ProvisioningTestUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,7 +138,7 @@ public static void checkRepoShadow(PrismObject repoShadow, ShadowKin assertEquals("Wrong kind in repo shadow "+repoShadow, kind, repoShadowType.getKind()); PrismContainer attributesContainer = repoShadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("No attributes in repo shadow "+repoShadow, attributesContainer); - List> attributes = attributesContainer.getValue().getItems(); + List> attributes = attributesContainer.getValue().getItems(); assertFalse("Empty attributes in repo shadow "+repoShadow, attributes.isEmpty()); assertEquals("Unexpected number of attributes in repo shadow "+repoShadow, 2, attributes.size()); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfDummy.java index 51e6d6ab6c2..dbe72652c31 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfDummy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -193,13 +193,13 @@ public void test001ResourceSanity() throws ObjectNotFoundException, SchemaExcept PrismContainer configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertContainerDefinition(configurationContainer, "configuration", ConnectorConfigurationType.COMPLEX_TYPE, 1, 1); PrismContainerValue configContainerValue = configurationContainer.getValue(); - List> configItems = configContainerValue.getItems(); + List> configItems = configContainerValue.getItems(); assertEquals("Wrong number of config items", 1, configItems.size()); PrismContainer dummyConfigPropertiesContainer = configurationContainer.findContainer( ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); assertNotNull("No icfc:configurationProperties container", dummyConfigPropertiesContainer); - List> dummyConfigPropItems = dummyConfigPropertiesContainer.getValue().getItems(); + List> dummyConfigPropItems = dummyConfigPropertiesContainer.getValue().getItems(); assertEquals("Wrong number of dummy ConfigPropItems items", 4, dummyConfigPropItems.size()); } diff --git a/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/CarefulAnt.java b/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/CarefulAnt.java index 5691b356b62..5be8e83bc39 100644 --- a/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/CarefulAnt.java +++ b/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/CarefulAnt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,6 @@ * */ public interface CarefulAnt { - ItemDelta createDelta(int iteration) throws SchemaException; + ItemDelta createDelta(int iteration) throws SchemaException; void assertModification(PrismObject object, int iteration); } diff --git a/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/ResourceCarefulAntUtil.java b/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/ResourceCarefulAntUtil.java index 176e161b28a..70d8b7cdf75 100644 --- a/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/ResourceCarefulAntUtil.java +++ b/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/ResourceCarefulAntUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public static void initAnts(List> ants, final File reso final PrismObjectDefinition resourceDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); ants.add(new CarefulAnt() { @Override - public ItemDelta createDelta(int iteration) { + public ItemDelta createDelta(int iteration) { return PropertyDelta.createModificationReplaceProperty(ResourceType.F_DESCRIPTION, resourceDef, "Blah "+iteration); } @@ -70,7 +70,7 @@ public void assertModification(PrismObject resource, int iteration ants.add(new CarefulAnt() { SchemaHandlingType schemaHandling; @Override - public ItemDelta createDelta(int iteration) throws SchemaException { + public ItemDelta createDelta(int iteration) throws SchemaException { schemaHandling = createNewSchemaHandling(resourceFile, iteration, prismContext); return ContainerDelta.createModificationReplace(ResourceType.F_SCHEMA_HANDLING, prismContext.getSchemaRegistry().findContainerDefinitionByCompileTimeClass(SchemaHandlingType.class), @@ -85,7 +85,7 @@ public void assertModification(PrismObject resource, int iteration ants.add(new CarefulAnt() { SchemaDefinitionType xmlSchemaDef; @Override - public ItemDelta createDelta(int iteration) throws SchemaException { + public ItemDelta createDelta(int iteration) throws SchemaException { xmlSchemaDef = createNewXmlSchemaDef(resourceFile, iteration, prismContext); return PropertyDelta.createModificationReplaceProperty( new ItemPath(ResourceType.F_SCHEMA, XmlSchemaType.F_DEFINITION), diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ResourceModifyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ResourceModifyTest.java index 475203c5605..284b55c172a 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ResourceModifyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ResourceModifyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -140,8 +140,8 @@ private void singleRandomModify(int iteration, OperationResult result) throws Ob private void singleModify(CarefulAnt ant, int iteration, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { // GIVEN - ItemDelta itemDelta = ant.createDelta(iteration); - Collection> modifications = MiscSchemaUtil.createCollection(itemDelta); + ItemDelta itemDelta = ant.createDelta(iteration); + Collection> modifications = MiscSchemaUtil.createCollection(itemDelta); System.out.println("itemDelta: " + itemDelta.debugDump()); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/util/SimpleTaskAdapter.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/util/SimpleTaskAdapter.java index 29289d20f70..57d2453ee59 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/util/SimpleTaskAdapter.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/util/SimpleTaskAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import com.evolveum.midpoint.prism.Containerable; import com.evolveum.midpoint.prism.Item; +import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; @@ -304,7 +305,7 @@ public PrismProperty getExtensionProperty(QName propertyName) { } @Override - public Item getExtensionItem(QName propertyName) { + public Item getExtensionItem(QName propertyName) { throw new UnsupportedOperationException("not implemented yet."); } @@ -520,12 +521,12 @@ public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding bindin @Override public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, - Collection> extensionDeltas) { + Collection> extensionDeltas) { throw new UnsupportedOperationException("not implemented yet."); } @Override - public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, ItemDelta delta) { + public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, ItemDelta delta) { throw new UnsupportedOperationException("not implemented yet."); } @@ -616,7 +617,7 @@ public List listSubtasksDeeply(OperationResult result) throws SchemaExcept } @Override - public Collection> getPendingModifications() { + public Collection> getPendingModifications() { throw new UnsupportedOperationException("not implemented yet."); } diff --git a/repo/repo-sql-impl-test/src/test/resources/logback-test.xml b/repo/repo-sql-impl-test/src/test/resources/logback-test.xml index b28ebc63259..5c9eb7a216f 100644 --- a/repo/repo-sql-impl-test/src/test/resources/logback-test.xml +++ b/repo/repo-sql-impl-test/src/test/resources/logback-test.xml @@ -33,7 +33,8 @@ - + + @@ -43,5 +44,8 @@ + + + diff --git a/repo/repo-sql-impl-test/src/test/resources/logging.properties b/repo/repo-sql-impl-test/src/test/resources/logging.properties new file mode 100644 index 00000000000..e9e945521f2 --- /dev/null +++ b/repo/repo-sql-impl-test/src/test/resources/logging.properties @@ -0,0 +1,4 @@ +// register SLF4JBridgeHandler as handler for the j.u.l. root logger +handlers = org.slf4j.bridge.SLF4JBridgeHandler +org.slf4j.bridge.SLF4JBridgeHandler.level=ALL +.level=ALL diff --git a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java index f0f4804284b..2c28d8324a3 100644 --- a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java +++ b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java @@ -1123,24 +1123,23 @@ private void applyShadowAttributeDefinitions(Class anyValue } for (Object[] value : values) { - ItemDefinition def; - QName name = RUtil.stringToQName((String) value[0]); + QName name = RUtil.stringToQName((String) value[0]); QName type = RUtil.stringToQName((String) value[1]); - - switch ((RValueType) value[2]) { - case PROPERTY: - def = new PrismPropertyDefinition(name, type, object.getPrismContext()); - break; - case REFERENCE: - def = new PrismReferenceDefinition(name, type, object.getPrismContext()); - break; - default: - throw new UnsupportedOperationException("Unsupported value type " + value[2]); - } - - Item item = attributes.findItem(def.getName()); + Item item = attributes.findItem(name); + + // A switch statement used to be here + // but that caused strange trouble with OpenJDK. This if-then-else works. if (item.getDefinition() == null) { - item.applyDefinition(def, true); + RValueType rValType = (RValueType) value[2]; + if (rValType == RValueType.PROPERTY) { + PrismPropertyDefinition def = new PrismPropertyDefinition(name, type, object.getPrismContext()); + item.applyDefinition(def, true); + } else if (rValType == RValueType.REFERENCE) { + PrismReferenceDefinition def = new PrismReferenceDefinition(name, type, object.getPrismContext()); + item.applyDefinition(def, true); + } else { + throw new UnsupportedOperationException("Unsupported value type " + rValType); + } } } } diff --git a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/RObject.java b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/RObject.java index a02efbfcb3f..9e5d9228117 100644 --- a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/RObject.java +++ b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/RObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -590,7 +590,7 @@ public static void copyFromJAXB(PrismContainerValue containerValue, RObject repo Set values = new HashSet(); try { - List> items = containerValue.getItems(); + List> items = containerValue.getItems(); //TODO: is this ehought??should we try items without definitions?? if (items != null) { for (Item item : items) { diff --git a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/any/RAnyConverter.java b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/any/RAnyConverter.java index e4094971fa8..54fef132e6f 100644 --- a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/any/RAnyConverter.java +++ b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/any/RAnyConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -255,7 +255,7 @@ public void convertFromRValue(RAnyValue value, PrismContainerValue any) throws D Validate.notNull(any, "Parent prism container value must not be null."); try { - Item item = any.findOrCreateItem(RUtil.stringToQName(value.getName()), value.getValueType().getItemClass()); + Item item = any.findOrCreateItem(RUtil.stringToQName(value.getName()), value.getValueType().getItemClass()); if (item == null) { throw new DtoTranslationException("Couldn't create item for value '" + value.getName() + "'."); } diff --git a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/any/RAssignmentExtension.java b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/any/RAssignmentExtension.java index 1038027fa6c..b3b10c23458 100644 --- a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/any/RAssignmentExtension.java +++ b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/data/common/any/RAssignmentExtension.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -278,7 +278,7 @@ private static void copyFromJAXB(PrismContainerValue containerValue, RAssignment Set values = new HashSet(); try { - List> items = containerValue.getItems(); + List> items = containerValue.getItems(); for (Item item : items) { values.addAll(converter.convertToRValue(item, true)); } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java index 8759822dce9..e06caae808e 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java @@ -581,7 +581,7 @@ protected void assertShadowRepo(PrismObject accountShadow, String oi QName objectClass, MatchingRule nameMatchingRule) { assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule); PrismContainer attributesContainer = accountShadow.findContainer(ShadowType.F_ATTRIBUTES); - List> attributes = attributesContainer.getValue().getItems(); + List> attributes = attributesContainer.getValue().getItems(); // Collection secIdentifiers = ShadowUtil.getSecondaryIdentifiers(accountShadow); if (attributes == null){ AssertJUnit.fail("No attributes in repo shadow"); diff --git a/repo/security-impl/src/main/java/com/evolveum/midpoint/security/impl/SecurityEnforcerImpl.java b/repo/security-impl/src/main/java/com/evolveum/midpoint/security/impl/SecurityEnforcerImpl.java index 31b487c174d..418b8ab5f1f 100644 --- a/repo/security-impl/src/main/java/com/evolveum/midpoint/security/impl/SecurityEnforcerImpl.java +++ b/repo/security-impl/src/main/java/com/evolveum/midpoint/security/impl/SecurityEnforcerImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2014 Evolveum + * Copyright (c) 2014-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -500,14 +500,14 @@ private boolean isApplicableItem(Au for (ItemPathType itemPathType: itemPaths) { ItemPath itemPath = itemPathType.getItemPath(); if (object != null) { - Item item = object.findItem(itemPath); + Item item = object.findItem(itemPath); if (item != null && !item.isEmpty()) { LOGGER.trace(" applicable object item "+itemPath); return true; } } if (delta != null) { - ItemDelta itemDelta = delta.findItemDelta(itemPath); + ItemDelta itemDelta = delta.findItemDelta(itemPath); if (itemDelta != null && !itemDelta.isEmpty()) { LOGGER.trace(" applicable delta item "+itemPath); return true; diff --git a/repo/system-init/src/main/java/com/evolveum/midpoint/init/RepositoryFactory.java b/repo/system-init/src/main/java/com/evolveum/midpoint/init/RepositoryFactory.java index 253dafef64c..17ec74bea7b 100644 --- a/repo/system-init/src/main/java/com/evolveum/midpoint/init/RepositoryFactory.java +++ b/repo/system-init/src/main/java/com/evolveum/midpoint/init/RepositoryFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,10 +111,17 @@ public Configuration getCurrentConfiguration() { public synchronized RepositoryService getRepositoryService() { if (repositoryService == null) { try { + LOGGER.debug("Creating repository service using factory {}", factory); repositoryService = factory.getRepositoryService(); } catch (RepositoryServiceFactoryException ex) { - LoggingUtils.logException(LOGGER, "Failed to get repository service from factory", ex); - throw new SystemException("Failed to get repository service from factory", ex); + LoggingUtils.logException(LOGGER, "Failed to get repository service from factory " + factory, ex); + throw new SystemException("Failed to get repository service from factory " + factory, ex); + } catch (RuntimeException ex) { + LoggingUtils.logException(LOGGER, "Failed to get repository service from factory " + factory, ex); + throw new SystemException("Failed to get repository service from factory " + factory, ex); + } catch (Error ex) { + LoggingUtils.logException(LOGGER, "Failed to get repository service from factory " + factory, ex); + throw ex; } } return repositoryService; diff --git a/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/Task.java b/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/Task.java index f927e1f5a4c..c0ca59e7642 100644 --- a/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/Task.java +++ b/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/Task.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -441,7 +441,7 @@ void setBindingImmediate(TaskBinding value, OperationResult parentResult) * @param binding Binding to be used to run the handler. * @param extensionDeltas The feature is EXPERIMENTAL, do not use if not absolutely necessary. */ - void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, Collection> extensionDeltas); + void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, Collection> extensionDeltas); /** * Same as above, with one extension delta (not a collection of them). @@ -451,7 +451,7 @@ void setBindingImmediate(TaskBinding value, OperationResult parentResult) * @param binding * @param delta EXPERIMENTAL, do not use if not absolutely necessary. */ - void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, ItemDelta delta); + void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, ItemDelta delta); /** * Same as above, with no extension deltas. @@ -528,7 +528,7 @@ void setBindingImmediate(TaskBinding value, OperationResult parentResult) * @param propertyName * @return null if extension or item does not exist */ - public Item getExtensionItem(QName itemName); + public Item getExtensionItem(QName itemName); // -------------------------------------------------------------------------- Task extension - SET (replace values) @@ -915,7 +915,7 @@ void savePendingModifications(OperationResult parentResult) throws ObjectNotFoun * Returns a list of pending modifications for this task. * @return */ - Collection> getPendingModifications(); + Collection> getPendingModifications(); LightweightTaskHandler getLightweightTaskHandler(); diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/TaskQuartzImpl.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/TaskQuartzImpl.java index ed8cc108374..c27bd3427c6 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/TaskQuartzImpl.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/TaskQuartzImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -281,9 +281,9 @@ public void setRecreateQuartzTrigger(boolean recreateQuartzTrigger) { this.recreateQuartzTrigger = recreateQuartzTrigger; } - private Collection> pendingModifications = null; + private Collection> pendingModifications = null; - public void addPendingModification(ItemDelta delta) { + public void addPendingModification(ItemDelta delta) { if (pendingModifications == null) { pendingModifications = new ArrayList<>(); } @@ -312,7 +312,7 @@ public void savePendingModifications(OperationResult parentResult) } @Override - public Collection> getPendingModifications() { + public Collection> getPendingModifications() { return pendingModifications; } @@ -329,12 +329,12 @@ public void synchronizeWithQuartz(OperationResult parentResult) { quartzRelatedProperties.add(TaskType.F_HANDLER_URI); } - private void synchronizeWithQuartzIfNeeded(Collection> deltas, OperationResult parentResult) { + private void synchronizeWithQuartzIfNeeded(Collection> deltas, OperationResult parentResult) { if (isRecreateQuartzTrigger()) { synchronizeWithQuartz(parentResult); return; } - for (ItemDelta delta : deltas) { + for (ItemDelta delta : deltas) { if (delta.getParentPath().isEmpty() && quartzRelatedProperties.contains(delta.getElementName())) { synchronizeWithQuartz(parentResult); return; @@ -342,17 +342,17 @@ private void synchronizeWithQuartzIfNeeded(Collection> deltas, Oper } } - private void processModificationNow(ItemDelta delta, OperationResult parentResult) + private void processModificationNow(ItemDelta delta, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { if (delta != null) { - Collection> deltas = new ArrayList>(1); + Collection> deltas = new ArrayList>(1); deltas.add(delta); repositoryService.modifyObject(TaskType.class, getOid(), deltas, parentResult); synchronizeWithQuartzIfNeeded(deltas, parentResult); } } - private void processModificationBatched(ItemDelta delta) { + private void processModificationBatched(ItemDelta delta) { if (delta != null) { addPendingModification(delta); } @@ -646,14 +646,14 @@ private UriStackEntry popFromOtherHandlersUriStack() { @Override public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding) { - pushHandlerUri(uri, schedule, binding, (Collection>) null); + pushHandlerUri(uri, schedule, binding, (Collection>) null); } @Override - public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, ItemDelta delta) { - Collection> deltas = null; + public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, ItemDelta delta) { + Collection> deltas = null; if (delta != null) { - deltas = new ArrayList>(); + deltas = new ArrayList>(); deltas.add(delta); } pushHandlerUri(uri, schedule, binding, deltas); @@ -668,7 +668,7 @@ public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding bindin * @param binding New binding */ @Override - public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, Collection> extensionDeltas) { + public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding binding, Collection> extensionDeltas) { Validate.notNull(uri); if (binding == null) { @@ -704,7 +704,7 @@ public void pushHandlerUri(String uri, ScheduleType schedule, TaskBinding bindin this.setRecreateQuartzTrigger(true); // will be applied on modifications save } - public ItemDelta createExtensionDelta(PrismPropertyDefinition definition, Object realValue) { + public ItemDelta createExtensionDelta(PrismPropertyDefinition definition, Object realValue) { PrismProperty property = (PrismProperty) definition.instantiate(); property.setRealValue(realValue); PropertyDelta propertyDelta = PropertyDelta.createModificationReplaceProperty(new ItemPath(TaskType.F_EXTENSION, property.getElementName()), definition, realValue); @@ -713,7 +713,7 @@ public ItemDelta createExtensionDelta(PrismPropertyDefinition definition, Obj return propertyDelta; } - private void storeExtensionDeltas(List result, Collection> extensionDeltas) { + private void storeExtensionDeltas(List result, Collection> extensionDeltas) { for (ItemDelta itemDelta : extensionDeltas) { Collection deltaTypes = null; @@ -1680,7 +1680,7 @@ public PrismProperty getExtensionProperty(QName propertyName) { } @Override - public Item getExtensionItem(QName propertyName) { + public Item getExtensionItem(QName propertyName) { if (getExtension() != null) { return getExtension().findItem(propertyName); } else { @@ -1783,77 +1783,77 @@ public void setExtensionPropertyImmediate(PrismProperty property, OperationRe } } - private ItemDelta setExtensionPropertyAndPrepareDelta(QName itemName, PrismPropertyDefinition definition, Collection values) throws SchemaException { + private ItemDelta setExtensionPropertyAndPrepareDelta(QName itemName, PrismPropertyDefinition definition, Collection values) throws SchemaException { ItemDelta delta = new PropertyDelta(new ItemPath(TaskType.F_EXTENSION, itemName), definition, getPrismContext()); return setExtensionItemAndPrepareDeltaCommon(delta, values); } - private ItemDelta setExtensionReferenceAndPrepareDelta(QName itemName, PrismReferenceDefinition definition, Collection values) throws SchemaException { + private ItemDelta setExtensionReferenceAndPrepareDelta(QName itemName, PrismReferenceDefinition definition, Collection values) throws SchemaException { ItemDelta delta = new ReferenceDelta(new ItemPath(TaskType.F_EXTENSION, itemName), definition, getPrismContext()); return setExtensionItemAndPrepareDeltaCommon(delta, values); } - private ItemDelta addExtensionReferenceAndPrepareDelta(QName itemName, PrismReferenceDefinition definition, Collection values) throws SchemaException { + private ItemDelta addExtensionReferenceAndPrepareDelta(QName itemName, PrismReferenceDefinition definition, Collection values) throws SchemaException { ItemDelta delta = new ReferenceDelta(new ItemPath(TaskType.F_EXTENSION, itemName), definition, getPrismContext()); return addExtensionItemAndPrepareDeltaCommon(delta, values); } - private ItemDelta setExtensionContainerAndPrepareDelta(QName itemName, PrismContainerDefinition definition, Collection values) throws SchemaException { + private ItemDelta setExtensionContainerAndPrepareDelta(QName itemName, PrismContainerDefinition definition, Collection values) throws SchemaException { ItemDelta delta = new ContainerDelta(new ItemPath(TaskType.F_EXTENSION, itemName), definition, getPrismContext()); return setExtensionItemAndPrepareDeltaCommon(delta, values); } - private ItemDelta setExtensionItemAndPrepareDeltaCommon(ItemDelta delta, Collection values) throws SchemaException { + private ItemDelta setExtensionItemAndPrepareDeltaCommon(ItemDelta delta, Collection values) throws SchemaException { // these values should have no parent, otherwise the following will fail delta.setValuesToReplace(values); - Collection> modifications = new ArrayList>(1); + Collection> modifications = new ArrayList<>(1); modifications.add(delta); PropertyDelta.applyTo(modifications, taskPrism); // i.e. here we apply changes only locally (in memory) return isPersistent() ? delta : null; } - private ItemDelta addExtensionItemAndPrepareDeltaCommon(ItemDelta delta, Collection values) throws SchemaException { + private ItemDelta addExtensionItemAndPrepareDeltaCommon(ItemDelta delta, Collection values) throws SchemaException { // these values should have no parent, otherwise the following will fail delta.addValuesToAdd(values); - Collection> modifications = new ArrayList>(1); + Collection> modifications = new ArrayList<>(1); modifications.add(delta); PropertyDelta.applyTo(modifications, taskPrism); // i.e. here we apply changes only locally (in memory) return isPersistent() ? delta : null; } - private ItemDelta modifyExtensionAndPrepareDelta(ItemDelta delta) throws SchemaException { + private ItemDelta modifyExtensionAndPrepareDelta(ItemDelta delta) throws SchemaException { - Collection> modifications = new ArrayList>(1); + Collection> modifications = new ArrayList>(1); modifications.add(delta); PropertyDelta.applyTo(modifications, taskPrism); // i.e. here we apply changes only locally (in memory) return isPersistent() ? delta : null; } - private ItemDelta addExtensionPropertyAndPrepareDelta(QName itemName, PrismPropertyDefinition definition, Collection values) throws SchemaException { + private ItemDelta addExtensionPropertyAndPrepareDelta(QName itemName, PrismPropertyDefinition definition, Collection values) throws SchemaException { ItemDelta delta = new PropertyDelta(new ItemPath(TaskType.F_EXTENSION, itemName), definition, getPrismContext()); delta.addValuesToAdd(values); - Collection> modifications = new ArrayList>(1); + Collection> modifications = new ArrayList<>(1); modifications.add(delta); PropertyDelta.applyTo(modifications, taskPrism); // i.e. here we apply changes only locally (in memory) return isPersistent() ? delta : null; } - private ItemDelta deleteExtensionPropertyAndPrepareDelta(QName itemName, PrismPropertyDefinition definition, Collection values) throws SchemaException { + private ItemDelta deleteExtensionPropertyAndPrepareDelta(QName itemName, PrismPropertyDefinition definition, Collection values) throws SchemaException { ItemDelta delta = new PropertyDelta(new ItemPath(TaskType.F_EXTENSION, itemName), definition, getPrismContext()); delta.addValuesToDelete(values); - Collection> modifications = new ArrayList>(1); + Collection> modifications = new ArrayList<>(1); modifications.add(delta); PropertyDelta.applyTo(modifications, taskPrism); // i.e. here we apply changes only locally (in memory) @@ -2311,7 +2311,7 @@ public TaskRunResult waitForSubtasks(Integer interval, OperationResult parentRes } @Deprecated - public TaskRunResult waitForSubtasks(Integer interval, Collection> extensionDeltas, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + public TaskRunResult waitForSubtasks(Integer interval, Collection> extensionDeltas, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { OperationResult result = parentResult.createSubresult(DOT_INTERFACE + "waitForSubtasks"); result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, TaskQuartzImpl.class); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/MockSingleTaskHandler.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/MockSingleTaskHandler.java index 53a7e15decf..ac3c1fdc9ec 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/MockSingleTaskHandler.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/MockSingleTaskHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -144,7 +144,7 @@ public TaskRunResult run(Task task) { taskManager.switchToBackground(t2, opResult); try { - ArrayList> deltas = new ArrayList>(); + ArrayList> deltas = new ArrayList<>(); deltas.add(((TaskQuartzImpl) task).createExtensionDelta(wfsFlagDefinition, true)); runResult = ((TaskQuartzImpl) task).waitForSubtasks(2, deltas, opResult); runResult.setProgress(1); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java index bbee3e9755f..73b24fc7f4e 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -402,7 +402,7 @@ public void test004TaskProperties() throws Exception { //delta.addV(property.getValues()); delta.setValuesToReplace(PrismValue.cloneCollection(property.getValues())); - Collection> modifications = new ArrayList>(1); + Collection> modifications = new ArrayList<>(1); modifications.add(delta); // TODO fix this code diff --git a/testing/consistency-mechanism/src/test/java/com/evolveum/midpoint/testing/consistency/ConsistencyTest.java b/testing/consistency-mechanism/src/test/java/com/evolveum/midpoint/testing/consistency/ConsistencyTest.java index 7977d487c37..b0c92c3005a 100644 --- a/testing/consistency-mechanism/src/test/java/com/evolveum/midpoint/testing/consistency/ConsistencyTest.java +++ b/testing/consistency-mechanism/src/test/java/com/evolveum/midpoint/testing/consistency/ConsistencyTest.java @@ -543,7 +543,7 @@ private void checkOpenResourceConfiguration(PrismObject resource, .findContainer(SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES); assertNotNull("No configuration properties container in " + resource + " from " + source, configPropsContainer); - List> configProps = configPropsContainer.getValue().getItems(); + List> configProps = configPropsContainer.getValue().getItems(); assertEquals("Wrong number of config properties in " + resource + " from " + source, numConfigProps, configProps.size()); PrismProperty credentialsProp = configPropsContainer.findProperty(new QName( diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index 52b86787f03..ef9539aebdf 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -631,7 +631,7 @@ private void checkOpenResourceConfiguration(PrismObject resource, assertNotNull("No configuration container in "+resource+" from "+source, configurationContainer); PrismContainer configPropsContainer = configurationContainer.findContainer(SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES); assertNotNull("No configuration properties container in "+resource+" from "+source, configPropsContainer); - List> configProps = configPropsContainer.getValue().getItems(); + List> configProps = configPropsContainer.getValue().getItems(); assertEquals("Wrong number of config properties in "+resource+" from "+source, numConfigProps, configProps.size()); PrismProperty credentialsProp = configPropsContainer.findProperty(new QName(connectorNamespace,credentialsPropertyName)); if (credentialsProp == null) {