Skip to content

Commit

Permalink
Move UniformItemPathImpl to prism-impl
Browse files Browse the repository at this point in the history
Not compilable now. One of the reasons is that path
serialization/deserialization would now require PrismContext.
  • Loading branch information
mederly committed Nov 29, 2018
1 parent e141aee commit 066cbc6
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 2 deletions.
Expand Up @@ -69,6 +69,8 @@ public class PrismContextImpl implements PrismContext {
@NotNull private final PrismMarshaller prismMarshaller;
@NotNull private final BeanMarshaller beanMarshaller;
@NotNull private final BeanUnmarshaller beanUnmarshaller;
@NotNull private final ItemPathParser itemPathParser;
@NotNull private final ItemPathSerializer itemPathSerializer;
private ParsingMigrator parsingMigrator;
private PrismMonitor monitor = null;

Expand Down Expand Up @@ -100,6 +102,8 @@ private PrismContextImpl(@NotNull SchemaRegistryImpl schemaRegistry) {
this.beanUnmarshaller = new BeanUnmarshaller(this, inspector);
this.prismMarshaller = new PrismMarshaller(beanMarshaller);
this.jaxbDomHack = new JaxbDomHack(lexicalProcessorRegistry.domProcessor(), this);
this.itemPathParser = new ItemPathParserImpl();
this.itemPathSerializer = new ItemPathSerializerImpl();

try {
configurePolyStringNormalizer(null);
Expand Down Expand Up @@ -327,6 +331,12 @@ public PrismParserNoIO parserFor(@NotNull Element data) {
return new PrismParserImplNoIO(new ParserElementSource(data), null, getDefaultParsingContext(), this, null, null, null, null);
}

@NotNull
@Override
public ItemPathParser itemPathParser() {
return itemPathParser;
}

@NotNull
@Override
public String detectLanguage(@NotNull File file) throws IOException {
Expand Down Expand Up @@ -413,6 +423,12 @@ public PrismSerializer<String> serializerFor(@NotNull String language) {
return new PrismSerializerImpl<>(new SerializerStringTarget(this, language), null, null, null, this);
}

@NotNull
@Override
public ItemPathSerializer itemPathSerializer() {
return itemPathSerializer;
}

@NotNull
@Override
public PrismSerializer<String> xmlSerializer() {
Expand Down
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2010-2018 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.marshaller;

import com.evolveum.midpoint.prism.path.UniformItemPath;
import org.w3c.dom.Element;

/**
*
*/
public class ItemPathParserImpl implements ItemPathParser {

@Override
public UniformItemPath parseFromString(String string) {
return ItemPathHolder.parseFromString(string);
}

@Override
public UniformItemPath parseFromElement(Element element) {
return ItemPathHolder.parseFromElement(element);
}
}
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2010-2018 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.marshaller;

/**
*
*/
public class ItemPathSerializerImpl implements ItemPathSerializer {
}
Expand Up @@ -18,6 +18,8 @@

import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.marshaller.ItemPathParser;
import com.evolveum.midpoint.prism.marshaller.ItemPathSerializer;
import com.evolveum.midpoint.prism.marshaller.JaxbDomHack;
import com.evolveum.midpoint.prism.marshaller.ParsingMigrator;
import com.evolveum.midpoint.prism.path.UniformItemPath;
Expand Down Expand Up @@ -121,6 +123,12 @@ public interface PrismContext {
@NotNull
PrismParserNoIO parserFor(@NotNull Element element);

/**
* Returns an item path parser. (EXPERIMENTAL / TEMPORARY)
*/
@NotNull
ItemPathParser itemPathParser();

@NotNull
String detectLanguage(@NotNull File file) throws IOException;

Expand Down Expand Up @@ -169,6 +177,12 @@ <C extends Containerable, O extends Objectable> void adopt(PrismContainerValue<C
@NotNull
PrismSerializer<String> serializerFor(@NotNull String language);

/**
* Returns an item path serializer. (EXPERIMENTAL / TEMPORARY)
*/
@NotNull
ItemPathSerializer itemPathSerializer();

/**
* Creates a serializer for XML language.
* @return The serializer.
Expand Down
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2010-2018 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.marshaller;

import com.evolveum.midpoint.prism.path.UniformItemPath;
import org.w3c.dom.Element;

/**
*
*/
public interface ItemPathParser {

UniformItemPath parseFromString(String string);

UniformItemPath parseFromElement(Element element);
}
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2010-2018 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.marshaller;

/**
*
*/
public interface ItemPathSerializer {
}
Expand Up @@ -623,7 +623,7 @@ public <T> boolean isUniquePropertyValue(ObjectType objectType, String propertyP
SecurityViolationException, ExpressionEvaluationException {
Validate.notEmpty(propertyPathString, "Empty property path");
OperationResult result = getCurrentResult(MidpointFunctions.class.getName() + ".isUniquePropertyValue");
UniformItemPath propertyPath = ItemPath.parseFromString(propertyPathString);
UniformItemPath propertyPath = prismContext.itemPathParser().parseFromString(propertyPathString);
return isUniquePropertyValue(objectType, propertyPath, propertyValue, getCurrentTask(), result);
}

Expand All @@ -650,7 +650,7 @@ public <O extends ObjectType, T> List<O> getObjectsInConflictOnPropertyValue(O o
SecurityViolationException, ExpressionEvaluationException {
Validate.notEmpty(propertyPathString, "Empty property path");
OperationResult result = getCurrentResult(MidpointFunctions.class.getName() + ".getObjectsInConflictOnPropertyValue");
UniformItemPath propertyPath = ItemPath.parseFromString(propertyPathString);
UniformItemPath propertyPath = prismContext.itemPathParser().parseFromString(propertyPathString);
QName matchingRuleQName = new QName(matchingRuleName); // no namespace for now
return getObjectsInConflictOnPropertyValue(objectType, propertyPath, propertyValue, matchingRuleQName, getAllConflicting,
getCurrentTask(), result);
Expand Down

0 comments on commit 066cbc6

Please sign in to comment.