Skip to content

Commit

Permalink
Added flexibility to bulk actions, changes in SelectorQualifiedGetOpt…
Browse files Browse the repository at this point in the history
…ionType

added 'hideOperationResults' option for bulk actions
added options for 'search' bulk action
moved SelectorQualifiedGetOptionType from api-types-3 to common-3
addded missing GetOperationOption fields to GetOperationOptionsType
org: prefix declared at the root level
  • Loading branch information
mederly committed May 31, 2017
1 parent 99e0268 commit cf439da
Show file tree
Hide file tree
Showing 28 changed files with 422 additions and 196 deletions.
Expand Up @@ -96,7 +96,7 @@ public <T> XNode marshall(@Nullable T bean, @Nullable SerializationContext ctx)
}

if (bean instanceof Containerable) {
return prismContext.xnodeSerializer().serializeRealValue(bean, new QName("dummy")).getSubnode();
return prismContext.xnodeSerializer().context(ctx).serializeRealValue(bean, new QName("dummy")).getSubnode();
} else if (bean instanceof Enum) {
return marshalEnum((Enum) bean, ctx);
} else if (bean.getClass().getAnnotation(XmlType.class) != null) {
Expand Down
Expand Up @@ -33,26 +33,26 @@
*/
public interface DynamicNamespacePrefixMapper extends DebugDumpable {

public void registerPrefix(String namespace, String prefix, boolean defaultNamespace);
void registerPrefix(String namespace, String prefix, boolean defaultNamespace);

public void registerPrefixLocal(String namespace, String prefix);
void registerPrefixLocal(String namespace, String prefix);

public String getPrefix(String namespace);
String getPrefix(String namespace);

public QName setQNamePrefix(QName qname);
QName setQNamePrefix(QName qname);

/**
* Makes sure that there is explicit prefix and not a default namespace prefix.
*/
public QName setQNamePrefixExplicit(QName qname);
QName setQNamePrefixExplicit(QName qname);

public DynamicNamespacePrefixMapper clone();
DynamicNamespacePrefixMapper clone();

// Follwing two methods are kind of a hack to force JAXB to always use prefixes.
// This works around the JAXB bug with default namespaces
public boolean isAlwaysExplicit();
boolean isAlwaysExplicit();

public void setAlwaysExplicit(boolean alwaysExplicit);
void setAlwaysExplicit(boolean alwaysExplicit);

// Specifies that this prefix should be declared by default (at top of XML files)
void addDeclaredByDefault(String prefix);
Expand Down
Expand Up @@ -16,7 +16,7 @@
package com.evolveum.midpoint.schema;

import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.GetOperationOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GetOperationOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.commons.collections.CollectionUtils;

Expand Down
Expand Up @@ -178,6 +178,7 @@ private void registerBuiltinSchemas(SchemaRegistryImpl schemaRegistry) throws Sc
schemaRegistry.getNamespacePrefixMapper().addDeclaredByDefault(MidPointConstants.PREFIX_NS_RI); // declared by default

schemaRegistry.getNamespacePrefixMapper().registerPrefix(SchemaConstants.NS_ORG, SchemaConstants.PREFIX_NS_ORG, false);
schemaRegistry.getNamespacePrefixMapper().addDeclaredByDefault(SchemaConstants.PREFIX_NS_ORG); // declared by default
}

private void setupDebug() {
Expand Down
Expand Up @@ -15,6 +15,8 @@
*/
package com.evolveum.midpoint.schema;

import com.evolveum.midpoint.xml.ns._public.common.common_3.PointInTimeTypeType;

/**
* Specifies the point in time for the returned data. This option controls whether fresh or cached data will
* be returned or whether future data projection will be returned. MidPoint usually deals with fresh data
Expand Down Expand Up @@ -48,4 +50,27 @@ public enum PointInTimeType {
*/
FUTURE;

public static PointInTimeTypeType toPointInTimeTypeType(PointInTimeType value) {
if (value == null) {
return null;
}
switch (value) {
case CACHED: return PointInTimeTypeType.CACHED;
case CURRENT: return PointInTimeTypeType.CURRENT;
case FUTURE: return PointInTimeTypeType.FUTURE;
default: throw new IllegalArgumentException("value: " + value);
}
}

public static PointInTimeType toPointInTimeType(PointInTimeTypeType value) {
if (value == null) {
return null;
}
switch (value) {
case CACHED: return PointInTimeType.CACHED;
case CURRENT: return PointInTimeType.CURRENT;
case FUTURE: return PointInTimeType.FUTURE;
default: throw new IllegalArgumentException("value: " + value);
}
}
}
@@ -1,6 +1,6 @@
package com.evolveum.midpoint.schema;

import com.evolveum.midpoint.xml.ns._public.common.api_types_3.RetrieveOptionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RetrieveOptionType;

public enum RetrieveOption {

Expand Down
Expand Up @@ -113,6 +113,7 @@ public T getOptions() {
//region Methods for accessing content (findRoot, hasToLoadPath, ...)
/**
* Returns options that apply to the "root" object. I.e. options that have null selector, null path, empty path, ...
* Must return 'live object' that could be modified.
*/
public static <T> T findRootOptions(Collection<SelectorOptions<T>> options) {
if (options == null) {
Expand Down
Expand Up @@ -31,40 +31,22 @@
import com.evolveum.midpoint.prism.marshaller.BeanMarshaller;
import com.evolveum.midpoint.prism.xnode.RootXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.schema.RetrieveOption;
import com.evolveum.midpoint.schema.*;

import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ObjectDeltaOperation;
import com.evolveum.midpoint.schema.ObjectSelector;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.GetOperationOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectSelectorType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
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.ProjectionPolicyType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
Expand Down Expand Up @@ -167,43 +149,50 @@ public static SelectorQualifiedGetOptionsType optionsToOptionsType(Collection<Se
}

private static SelectorQualifiedGetOptionType selectorOptionToSelectorQualifiedGetOptionType(SelectorOptions<GetOperationOptions> selectorOption){
ObjectSelectorType selectorType = selectorToSelectorType(selectorOption.getSelector());
OptionObjectSelectorType selectorType = selectorToSelectorType(selectorOption.getSelector());
GetOperationOptionsType getOptionsType = getOptionsToGetOptionsType(selectorOption.getOptions());
SelectorQualifiedGetOptionType selectorOptionType = new SelectorQualifiedGetOptionType();
selectorOptionType.setOptions(getOptionsType);
selectorOptionType.setSelector(selectorType);
return selectorOptionType;
}

private static ObjectSelectorType selectorToSelectorType(ObjectSelector selector) {
private static OptionObjectSelectorType selectorToSelectorType(ObjectSelector selector) {
if (selector == null) {
return null;
}
ObjectSelectorType selectorType = new ObjectSelectorType();
OptionObjectSelectorType selectorType = new OptionObjectSelectorType();
selectorType.setPath(new ItemPathType(selector.getPath()));
return selectorType;
}

private static GetOperationOptionsType getOptionsToGetOptionsType(GetOperationOptions options) {
GetOperationOptionsType optionsType = new GetOperationOptionsType();
optionsType.setRetrieve(RetrieveOption.toRetrieveOptionType(options.getRetrieve()));
optionsType.setResolve(options.getResolve());
optionsType.setNoFetch(options.getNoFetch());
optionsType.setRaw(options.getRaw());
optionsType.setNoDiscovery(options.getDoNotDiscovery());
return optionsType;
}

GetOperationOptionsType optionsType = new GetOperationOptionsType();
optionsType.setRetrieve(RetrieveOption.toRetrieveOptionType(options.getRetrieve()));
optionsType.setResolve(options.getResolve());
optionsType.setResolveNames(options.getResolveNames());
optionsType.setNoFetch(options.getNoFetch());
optionsType.setRaw(options.getRaw());
optionsType.setTolerateRawData(options.getTolerateRawData());
optionsType.setNoDiscovery(options.getDoNotDiscovery());
// TODO relational value search query (but it might become obsolete)
optionsType.setAllowNotFound(options.getAllowNotFound());
optionsType.setPointInTimeType(PointInTimeType.toPointInTimeTypeType(options.getPointInTimeType()));
optionsType.setStaleness(options.getStaleness());
optionsType.setDistinct(options.getDistinct());
return optionsType;
}

public static List<SelectorOptions<GetOperationOptions>> optionsTypeToOptions(SelectorQualifiedGetOptionsType objectOptionsType) {
if (objectOptionsType == null) {
return null;
}
List<SelectorOptions<GetOperationOptions>> retval = new ArrayList<>();
for (SelectorQualifiedGetOptionType optionType : objectOptionsType.getOption()) {
retval.add(selectorQualifiedGetOptionTypeToSelectorOption(optionType));
}
return retval;
}
if (objectOptionsType == null) {
return null;
}
List<SelectorOptions<GetOperationOptions>> retval = new ArrayList<>();
for (SelectorQualifiedGetOptionType optionType : objectOptionsType.getOption()) {
retval.add(selectorQualifiedGetOptionTypeToSelectorOption(optionType));
}
return retval;
}

private static SelectorOptions<GetOperationOptions> selectorQualifiedGetOptionTypeToSelectorOption(SelectorQualifiedGetOptionType objectOptionsType) {
ObjectSelector selector = selectorTypeToSelector(objectOptionsType.getSelector());
Expand All @@ -215,13 +204,20 @@ private static GetOperationOptions getOptionsTypeToGetOptions(GetOperationOption
GetOperationOptions options = new GetOperationOptions();
options.setRetrieve(RetrieveOption.fromRetrieveOptionType(optionsType.getRetrieve()));
options.setResolve(optionsType.isResolve());
options.setResolveNames(optionsType.isResolveNames());
options.setNoFetch(optionsType.isNoFetch());
options.setRaw(optionsType.isRaw());
options.setDoNotDiscovery(optionsType.isNoDiscovery());
options.setTolerateRawData(optionsType.isTolerateRawData());
options.setDoNotDiscovery(optionsType.isNoDiscovery());
// TODO relational value search query (but it might become obsolete)
options.setAllowNotFound(optionsType.isAllowNotFound());
options.setPointInTimeType(PointInTimeType.toPointInTimeType(optionsType.getPointInTimeType()));
options.setStaleness(optionsType.getStaleness());
options.setDistinct(optionsType.isDistinct());
return options;
}

private static ObjectSelector selectorTypeToSelector(ObjectSelectorType selectorType) {
private static ObjectSelector selectorTypeToSelector(OptionObjectSelectorType selectorType) {
if (selectorType == null) {
return null;
}
Expand Down
Expand Up @@ -280,74 +280,6 @@
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="SelectorQualifiedGetOptionsType">
<xsd:annotation>
<xsd:documentation>
Selector-qualified options for a get-like operation.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="option" type="tns:SelectorQualifiedGetOptionType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="SelectorQualifiedGetOptionType">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="selector" type="tns:ObjectSelectorType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="options" type="tns:GetOperationOptionsType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ObjectSelectorType">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="path" type="t:ItemPathType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>

<xsd:simpleType name="RetrieveOptionType">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="default">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="DEFAULT"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="include">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="INCLUDE"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="exclude">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="EXCLUDE"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<!-- the following types are related to script execution; these are experimental for now -->
<xsd:complexType name="XmlScriptsType">
<xsd:sequence>
Expand Down Expand Up @@ -431,23 +363,6 @@
</xsd:restriction>
</xsd:simpleType>


<xsd:complexType name="GetOperationOptionsType">
<xsd:annotation>
<xsd:documentation>
See GetOperationOptions for a description.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="retrieve" type="tns:RetrieveOptionType" minOccurs="0"/>
<xsd:element name="resolve" type="xsd:boolean" minOccurs="0"/>
<xsd:element name="resolveNames" type="xsd:boolean" minOccurs="0"/>
<xsd:element name="noFetch" type="xsd:boolean" minOccurs="0"/>
<xsd:element name="raw" type="xsd:boolean" minOccurs="0"/>
<xsd:element name="noDiscovery" type="xsd:boolean" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ObjectDeltaListType">
<xsd:annotation>
<xsd:documentation>
Expand Down

0 comments on commit cf439da

Please sign in to comment.