Skip to content

Commit

Permalink
Rename prismContext.misc() to hacks()
Browse files Browse the repository at this point in the history
...to better reflect the nature of this interface.
  • Loading branch information
mederly committed Dec 7, 2018
1 parent 8060c52 commit c8e0578
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 26 deletions.
Expand Up @@ -99,7 +99,7 @@ public GenericHandlerDto(TaskDto taskDto, @NotNull List<Item> items, PageBase pa
clonedDefinition.setCanAdd(false);
clonedDefinition.setCanModify(false);
clonedDefinition.setDisplayOrder(displayOrder);
prismContext.misc().addToDefinition(ctd, clonedDefinition);
prismContext.hacks().addToDefinition(ctd, clonedDefinition);
}
displayOrder++;
}
Expand Down
Expand Up @@ -349,7 +349,7 @@ public static void removeShadowRefEvaluatorValue(ExpressionType expression, Stri
if (node instanceof MapXNode && ((MapXNode) node).containsKey(SHADOW_REF_KEY)) {
XNode shadowRefNodes = ((MapXNode) node).get(SHADOW_REF_KEY);
if (shadowRefNodes instanceof MapXNode && shadowRefOid.equals(getShadowRefNodeOid((MapXNode) shadowRefNodes))) {
prismContext.misc().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, null);
prismContext.hacks().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, null);
//todo don't get why while using removeEvaluatorByName no changes are saved
// removeEvaluatorByName(expression, SchemaConstantsGenerated.C_VALUE);
} else if (shadowRefNodes instanceof ListXNode) {
Expand Down Expand Up @@ -416,7 +416,7 @@ public static MapXNode getOrCreateAssociationTargetSearchValues(ExpressionType e
filterClauseNode = prismContext.xnodeFactory().map();
}
if (!filterClauseNode.containsKey(new QName("equal"))) {
prismContext.misc().putToMapXNode(filterClauseNode, new QName("equal"), null);
prismContext.hacks().putToMapXNode(filterClauseNode, new QName("equal"), null);
}
MapXNode values = (MapXNode)filterClauseNode.get(new QName("equal"));
if (values == null) {
Expand All @@ -429,7 +429,7 @@ public static void updateAssociationTargetSearchPath(ExpressionType expression,
MapXNode values = getOrCreateAssociationTargetSearchValues(expression, prismContext);
PrimitiveXNode<ItemPathType> pathValue = (PrimitiveXNode<ItemPathType>)values.get(new QName("path"));
if (pathValue != null) {
prismContext.misc().setPrimitiveXNodeValue(pathValue, path, null);
prismContext.hacks().setPrimitiveXNodeValue(pathValue, path, null);
}
}

Expand Down Expand Up @@ -499,16 +499,16 @@ public static ListXNode getShadowRefNodesList(ExpressionType expression, boolean
} else if (createIfNotExist && ((MapXNode) node).get(SHADOW_REF_KEY) instanceof MapXNode) {
MapXNode shadowRef = (MapXNode) ((MapXNode) node).get(SHADOW_REF_KEY);
shadowRefNodes = prismContext.xnodeFactory().list(shadowRef);
prismContext.misc().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, shadowRefNodes);
prismContext.hacks().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, shadowRefNodes);
}
} else if (createIfNotExist) {
shadowRefNodes = prismContext.xnodeFactory().list();
prismContext.misc().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, shadowRefNodes);
prismContext.hacks().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, shadowRefNodes);
}
} else if (createIfNotExist) {
shadowRefNodes = prismContext.xnodeFactory().list();
node = prismContext.xnodeFactory().map();
prismContext.misc().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, shadowRefNodes);
prismContext.hacks().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, shadowRefNodes);
raw = new RawType(node, prismContext);
element.setValue(raw);
}
Expand All @@ -532,7 +532,7 @@ public static void addShadowRefEvaluatorValue(ExpressionType expression, String
Map<QName, XNode> shadowRefNodeSource = new HashMap<>();
shadowRefNodeSource.put(SHADOW_OID_KEY, factory.primitive(oid));
shadowRefNodeSource.put(SHADOW_TYPE_KEY, factory.primitive(ShadowType.COMPLEX_TYPE.getLocalPart()));
prismContext.misc().addToListXNode(shadowRefNodes, factory.map(shadowRefNodeSource));
prismContext.hacks().addToListXNode(shadowRefNodes, factory.map(shadowRefNodeSource));
}

public static List<String> getLiteralExpressionValues(ExpressionType expression) throws SchemaException{
Expand Down
Expand Up @@ -38,7 +38,7 @@
*
* Prism API and/or client code should be modified to get rid of these hacks.
*/
public interface Miscellaneous {
public interface Hacks {

@Nullable
Serializable guessFormattedValue(Serializable value) throws SchemaException;
Expand Down
Expand Up @@ -313,7 +313,7 @@ <C extends Containerable, O extends Objectable> void adopt(PrismContainerValue<C

UniformItemPath path(Object... namesOrIdsOrSegments);

Miscellaneous misc();
Hacks hacks();

XNodeFactory xnodeFactory();

Expand Down
Expand Up @@ -158,7 +158,7 @@ public Element getFilterClauseAsElement(@NotNull PrismContext prismContext) thro
if (filterClauseXNode == null) {
return null;
}
return prismContext.misc().serializeSingleElementMapToElement(filterClauseXNode);
return prismContext.hacks().serializeSingleElementMapToElement(filterClauseXNode);
}

// xnode should be correct (expecting it was just created by serializing something)
Expand Down
Expand Up @@ -259,7 +259,7 @@ public XNode serializeToXNode() throws SchemaException {
} else if (parsed != null) {
checkPrismContext();
XNode rv = prismContext.xnodeSerializer().root(new QName("dummy")).serialize(parsed).getSubnode();
prismContext.misc().setXNodeType(rv, explicitTypeName, explicitTypeDeclaration);
prismContext.hacks().setXNodeType(rv, explicitTypeName, explicitTypeDeclaration);
return rv;
} else {
return null; // or an exception here?
Expand Down
Expand Up @@ -35,11 +35,11 @@
/**
* TEMPORARY
*/
public class MiscellaneousImpl implements Miscellaneous {
public class HacksImpl implements Hacks {

@NotNull private final PrismContextImpl prismContext;

MiscellaneousImpl(@NotNull PrismContextImpl prismContext) {
HacksImpl(@NotNull PrismContextImpl prismContext) {
this.prismContext = prismContext;
}

Expand Down
Expand Up @@ -79,7 +79,7 @@ public class PrismContextImpl implements PrismContext {
@NotNull private final PrismMarshaller prismMarshaller;
@NotNull private final BeanMarshaller beanMarshaller;
@NotNull private final BeanUnmarshaller beanUnmarshaller;
@NotNull private final Miscellaneous miscellaneous;
@NotNull private final Hacks hacks;
@NotNull private final XNodeFactory xnodeFactory;
@NotNull private final DeltaFactory deltaFactory;
@NotNull private final QueryFactory queryFactory;
Expand Down Expand Up @@ -118,7 +118,7 @@ private PrismContextImpl(@NotNull SchemaRegistryImpl schemaRegistry) {
this.beanUnmarshaller = new BeanUnmarshaller(this, inspector);
this.prismMarshaller = new PrismMarshaller(beanMarshaller);
this.jaxbDomHack = new JaxbDomHackImpl(lexicalProcessorRegistry.domProcessor(), this);
this.miscellaneous = new MiscellaneousImpl(this);
this.hacks = new HacksImpl(this);
this.xnodeFactory = new XNodeFactoryImpl();
this.deltaFactory = new DeltaFactoryImpl(this);
this.queryFactory = new QueryFactoryImpl(this);
Expand Down Expand Up @@ -559,8 +559,8 @@ public UniformItemPath path(Object... namesOrIdsOrSegments) {
}

@Override
public Miscellaneous misc() {
return miscellaneous;
public Hacks hacks() {
return hacks;
}

@Override
Expand Down
Expand Up @@ -67,7 +67,7 @@ public void testParseProtectedStringEncrypted() throws Exception {

// THEN
ProtectedStringType unmarshalled = new ProtectedStringType();
prismContext.misc().parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, createDefaultParsingContext());
prismContext.hacks().parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, createDefaultParsingContext());
System.out.println("Unmarshalled value: " + unmarshalled);
assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled);
}
Expand All @@ -92,7 +92,7 @@ public void testParseProtectedStringHashed() throws Exception {

// THEN
ProtectedStringType unmarshalled = new ProtectedStringType();
prismContext.misc().parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, createDefaultParsingContext());
prismContext.hacks().parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, createDefaultParsingContext());
System.out.println("Unmarshalled value: " + unmarshalled);
assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled);
}
Expand Down
Expand Up @@ -69,7 +69,7 @@ public static Map<String, Serializable> fromParamsType(ParamsType paramsType, Pr
Serializable realValue;
if (entry.getEntryValue() != null) {
Serializable value = (Serializable) entry.getEntryValue().getValue();
realValue = prismContext.misc().guessFormattedValue(value);
realValue = prismContext.hacks().guessFormattedValue(value);
} else {
realValue = null;
}
Expand Down
Expand Up @@ -207,7 +207,7 @@ public DOMSource invokeAllowingFaults(DOMSource request) throws FaultMessage {
}

private void serializeFaultMessage(Detail detail, FaultMessage faultMessage) {
prismContext.misc()
prismContext.hacks()
.serializeFaultMessage(detail, faultMessage.getFaultInfo(), SchemaConstants.FAULT_MESSAGE_ELEMENT_NAME, LOGGER);
}

Expand Down
Expand Up @@ -330,7 +330,7 @@ public <O extends ObjectType> PrismObjectDefinition<O> getEditObjectDefinition(P
}
RefinedObjectClassDefinition refinedObjectClassDefinition = getEditObjectClassDefinition(shadow, resource, phase, task, result);
if (refinedObjectClassDefinition != null) {
prismContext.misc().replaceDefinition(objectDefinition.getComplexTypeDefinition(), ShadowType.F_ATTRIBUTES,
prismContext.hacks().replaceDefinition(objectDefinition.getComplexTypeDefinition(), ShadowType.F_ATTRIBUTES,
refinedObjectClassDefinition.toResourceAttributeContainerDefinition());
}
}
Expand Down
Expand Up @@ -143,7 +143,7 @@ public DOMSource invokeAllowingFaults(DOMSource request) throws FaultMessage {
}

private void serializeFaultMessage(Detail detail, FaultMessage faultMessage) {
prismContext.misc()
prismContext.hacks()
.serializeFaultMessage(detail, faultMessage.getFaultInfo(), SchemaConstants.FAULT_MESSAGE_ELEMENT_NAME, LOGGER);
}

Expand Down
Expand Up @@ -78,7 +78,6 @@
import com.evolveum.midpoint.prism.crypto.EncryptionException;
import com.evolveum.midpoint.prism.match.MatchingRule;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.path.UniformItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.schema.SchemaRegistry;
import com.evolveum.midpoint.prism.util.PrismAsserts;
Expand Down Expand Up @@ -625,7 +624,7 @@ private void checkOpenResourceConfiguration(PrismObject<ResourceType> resource,
MapXNode xmap = (MapXNode) rawElement;
try{
ProtectedStringType protectedType = new ProtectedStringType();
prismContext.misc().parseProtectedType(protectedType, xmap, prismContext, prismContext.getDefaultParsingContext());
prismContext.hacks().parseProtectedType(protectedType, xmap, prismContext, prismContext.getDefaultParsingContext());
// display("LDAP credentials raw element", DOMUtil.serializeDOMToString(rawDomElement));
// assertEquals("Wrong credentials element namespace in "+resource+" from "+source, connectorNamespace, rawDomElement.getNamespaceURI());
// assertEquals("Wrong credentials element local name in "+resource+" from "+source, credentialsPropertyName, rawDomElement.getLocalName());
Expand Down

0 comments on commit c8e0578

Please sign in to comment.