Skip to content

Commit

Permalink
Merge branch 'feature/manual-connectors'
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Apr 10, 2017
2 parents 77535e5 + cf3c922 commit 93670c7
Show file tree
Hide file tree
Showing 19 changed files with 407 additions and 82 deletions.
Expand Up @@ -56,6 +56,7 @@ public abstract class SchemaConstants {
public static final String NS_MATCHING_RULE = NS_MIDPOINT_PUBLIC + "/common/matching-rule-3";
public static final String NS_FAULT = "http://midpoint.evolveum.com/xml/ns/public/common/fault-3";
public static final String NS_SAMPLES_EXTENSION = "http://midpoint.evolveum.com/xml/ns/samples/extension-3";
public static final String NS_CASE = "http://midpoint.evolveum.com/xml/ns/public/common/case-3";

/**
* Namespace for default (bult-in) object collections, such as "all objects", "all roles", ...
Expand Down Expand Up @@ -425,6 +426,12 @@ public abstract class SchemaConstants {
public static final String LIFECYCLE_ARCHIVED = "archived";
public static final String LIFECYCLE_FAILED = "failed";

// Case: generic reusable case states

public static final String CASE_STATE_OPEN = "open";
public static final QName CASE_STATE_OPEN_QNAME = new QName(NS_CASE, CASE_STATE_OPEN);
public static final String CASE_STATE_CLOSED = "closed";
public static final QName CASE_STATE_CLOSED_QNAME = new QName(NS_CASE, CASE_STATE_CLOSED);

// Object collections

Expand Down
Expand Up @@ -15,13 +15,16 @@
*/
package com.evolveum.midpoint.schema.result;

import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;

/**
* Interface that provide ability to query status of asynchronous operation.
*
* @author Radovan Semancik
*/
public interface AsynchronousOperationQueryable {

OperationResultStatus queryOperationStatus(String asyncronousOperationReference);
OperationResultStatus queryOperationStatus(String asyncronousOperationReference, OperationResult parentResult) throws ObjectNotFoundException, SchemaException;

}
Expand Up @@ -516,6 +516,9 @@ public void computeStatus() {
} else {
message = message + ": " + sub.getMessage();
}
if (asyncronousOperationReference == null) {
asyncronousOperationReference = sub.getAsyncronousOperationReference();
}
return;
}
if (sub.getStatus() == OperationResultStatus.PARTIAL_ERROR) {
Expand Down
Expand Up @@ -315,14 +315,38 @@
<xsd:element name="liveSync" type="tns:LiveSyncCapabilityType"/>


<xsd:complexType name="AbstractWriteCapabilityType" abstract="true">
<xsd:annotation>
<xsd:documentation>
Base type for all write capabilities.
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:CapabilityType">
<xsd:sequence>
<xsd:element name="manual" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
If set to true then there is NO online connection to the resource.
The operations are executed manually by a human operator. The resource
provides ability to execute the operations in an asynchronous way. But
this asynchronous operation contains a human in the loop.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="CreateCapabilityType">
<xsd:annotation>
<xsd:documentation>
Describes create capability.
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:CapabilityType">
<xsd:extension base="tns:AbstractWriteCapabilityType">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand All @@ -337,6 +361,17 @@
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:CapabilityType">
<xsd:sequence>
<xsd:element name="cachingOnly" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
If set to true then the resource does NOT have native read capability.
However, the resource suggests that the native read capability has to be
approximated by the use of midPoint caching.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand All @@ -350,7 +385,7 @@
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:CapabilityType">
<xsd:extension base="tns:AbstractWriteCapabilityType">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand All @@ -364,7 +399,7 @@
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:CapabilityType">
<xsd:extension base="tns:AbstractWriteCapabilityType">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down
Expand Up @@ -228,6 +228,15 @@ public static boolean match(QName a, QName b, boolean caseInsensitive) {
}

}

/**
* Matches QName with a URI representation. The URL may in fact be just the local
* part.
*/
public static boolean matchWithUri(QName qname, String uri) {
return match(qname, uriToQName(uri, true));
}


public static QName resolveNs(QName a, Collection<QName> col){
if (col == null) {
Expand Down
Expand Up @@ -3494,10 +3494,7 @@ protected PrismObject<UserType> getDefaultActor() {
}

protected Task createTask(String operationName) {
if (!operationName.contains(".")) {
operationName = this.getClass().getName() + "." + operationName;
}
Task task = taskManager.createTaskInstance(operationName);
Task task = super.createTask(operationName);
PrismObject<UserType> defaultActor = getDefaultActor();
if (defaultActor != null) {
task.setOwner(defaultActor);
Expand Down
Expand Up @@ -1197,8 +1197,10 @@ private PrismObject<ShadowType> fetchResourceObject(ProvisioningContext ctx,
@SuppressWarnings({ "rawtypes", "unchecked" })
private void applyAfterOperationAttributes(PrismObject<ShadowType> shadow,
Collection<ResourceAttribute<?>> resourceAttributesAfterAdd) throws SchemaException {
ResourceAttributeContainer attributesContainer = ShadowUtil
.getAttributesContainer(shadow);
if (resourceAttributesAfterAdd == null) {
return;
}
ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadow);
for (ResourceAttribute attributeAfter : resourceAttributesAfterAdd) {
ResourceAttribute attributeBefore = attributesContainer.findAttribute(attributeAfter.getElementName());
if (attributeBefore != null) {
Expand Down
Expand Up @@ -47,6 +47,7 @@
import com.evolveum.midpoint.schema.result.OperationResultStatus;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.schema.util.SchemaDebugUtil;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.task.api.Task;
Expand All @@ -60,6 +61,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsSimulateType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -178,11 +180,6 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep
throw new IllegalArgumentException("Provided OID is not equal to OID of repository shadow");
}

if (canReturnCached(options, repositoryShadow)) {
applyDefinition(repositoryShadow, parentResult);
return repositoryShadow;
}

ProvisioningContext ctx = ctxFactory.create(repositoryShadow, task, parentResult);
ctx.setGetOperationOptions(options);
try {
Expand All @@ -198,6 +195,15 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep
}
ResourceType resource = ctx.getResource();

if (!ResourceTypeUtil.isReadCapabilityEnabled(resource)) {
throw new UnsupportedOperationException("Resource does not support 'read' operation");
}

if (canReturnCached(options, repositoryShadow, resource)) {
applyDefinition(repositoryShadow, parentResult);
return repositoryShadow;
}

PrismObject<ShadowType> resourceShadow = null;
try {

Expand All @@ -222,7 +228,7 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep

Collection<? extends ResourceAttribute<?>> identifiers = ShadowUtil
.getAllIdentifiers(repositoryShadow);

resourceShadow = resouceObjectConverter.getResourceObject(ctx, identifiers, true, parentResult);

// Resource shadow may have different auxiliary object classes than
Expand Down Expand Up @@ -295,10 +301,14 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep

}
}

}

private boolean canReturnCached(Collection<SelectorOptions<GetOperationOptions>> options, PrismObject<ShadowType> repositoryShadow) throws ConfigurationException {
private boolean canReturnCached(Collection<SelectorOptions<GetOperationOptions>> options, PrismObject<ShadowType> repositoryShadow, ResourceType resource) throws ConfigurationException {
ReadCapabilityType readCapabilityType = ResourceTypeUtil.getEffectiveCapability(resource, ReadCapabilityType.class);
Boolean cachingOnly = readCapabilityType.isCachingOnly();
if (cachingOnly == Boolean.TRUE) {
return true;
}
long stalenessOption = GetOperationOptions.getStaleness(SelectorOptions.findRootOptions(options));
if (stalenessOption == 0L) {
return false;
Expand Down
Expand Up @@ -63,6 +63,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType;

import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
Expand Down Expand Up @@ -453,11 +454,14 @@ public static void checkShadowActivationConsistency(PrismObject<ShadowType> shad

public static CachingStategyType getCachingStrategy(ProvisioningContext ctx)
throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
CachingPolicyType caching = ctx.getResource().getCaching();
if (caching == null) {
return CachingStategyType.NONE;
}
if (caching.getCachingStategy() == null) {
ResourceType resource = ctx.getResource();
CachingPolicyType caching = resource.getCaching();
if (caching == null || caching.getCachingStategy() == null) {
ReadCapabilityType readCapabilityType = ResourceTypeUtil.getEffectiveCapability(resource, ReadCapabilityType.class);
Boolean cachingOnly = readCapabilityType.isCachingOnly();
if (cachingOnly == Boolean.TRUE) {
return CachingStategyType.PASSIVE;
}
return CachingStategyType.NONE;
}
return caching.getCachingStategy();
Expand Down
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.prism.xnode.PrimitiveXNode;
import com.evolveum.midpoint.provisioning.api.ProvisioningService;
import com.evolveum.midpoint.provisioning.impl.dummy.TestDummy;
import com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock;
import com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj;
import com.evolveum.midpoint.schema.CapabilityUtil;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
Expand All @@ -59,6 +60,7 @@
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.test.AbstractIntegrationTest;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.util.TestUtil;
Expand Down Expand Up @@ -97,7 +99,10 @@ public abstract class AbstractProvisioningIntegrationTest extends AbstractIntegr

@Autowired(required=true)
protected ProvisioningService provisioningService;


@Autowired(required = true)
protected SynchornizationServiceMock syncServiceMock;

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
provisioningService.postInit(initResult);
Expand Down

0 comments on commit 93670c7

Please sign in to comment.