Skip to content

Commit

Permalink
Merge branch 'master' into feature/commons-lang2-out
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed May 18, 2020
2 parents 7c164c4 + 8a6eb5d commit 0743f9c
Show file tree
Hide file tree
Showing 11 changed files with 1,013 additions and 211 deletions.
7 changes: 0 additions & 7 deletions gui/admin-gui/src/main/resources/application.yml
Expand Up @@ -11,13 +11,6 @@ spring:
file-size-threshold: 256KB
thymeleaf:
cache: false
# REST error handling TODO new-rest, investigate impact
# mvc:
# throw-exception-if-no-handler-found: true
# TODO: resources.add-mappings=false breaks images (all static content?) serving for Wicket app!
# but without it RestExceptionHandler is not found, alternative solution needs to be found
# resources:
# add-mappings: false

server:
tomcat:
Expand Down
Expand Up @@ -68,7 +68,9 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.*;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptOutputType;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingExpressionType;
import com.evolveum.prism.xml.ns._public.query_3.QueryType;

/**
Expand Down Expand Up @@ -140,7 +142,6 @@ public ModelRestService() {
// nothing to do
}

// Migrated to ModelRestController
@POST
@Path("/{type}/{oid}/generate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, RestServiceUtil.APPLICATION_YAML })
Expand Down Expand Up @@ -168,7 +169,6 @@ public Response generateValue(@PathParam("type") String type,

}

// Migrated to ModelRestController
@POST
@Path("/rpc/generate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, RestServiceUtil.APPLICATION_YAML })
Expand Down Expand Up @@ -207,7 +207,6 @@ private <O extends ObjectType> Response generateValue(PrismObject<O> object, Pol
return response;
}

// Migrated to ModelRestController
@POST
@Path("/{type}/{oid}/validate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, RestServiceUtil.APPLICATION_YAML })
Expand All @@ -231,7 +230,6 @@ public Response validateValue(@PathParam("type") String type, @PathParam("oid")
return response;
}

// Migrated to ModelRestController
@POST
@Path("/rpc/validate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, RestServiceUtil.APPLICATION_YAML })
Expand Down Expand Up @@ -318,7 +316,6 @@ public Response getValuePolicyForUser(@PathParam("id") String oid, @Context Mess
return response;
}

// Migrated to ModelRestController
@GET
@Path("/{type}/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, RestServiceUtil.APPLICATION_YAML })
Expand Down Expand Up @@ -725,8 +722,11 @@ public Response importFromResource(@PathParam("resourceOid") String resourceOid,
Response response;
try {
modelService.importFromResource(resourceOid, objClass, task, parentResult);
response = RestServiceUtil.createResponse(Response.Status.SEE_OTHER, (uriInfo.getBaseUriBuilder().path(this.getClass(), "getObject")
.build(ObjectTypes.TASK.getRestType(), task.getOid())), parentResult);
response = RestServiceUtil.createResponse(
Response.Status.SEE_OTHER,
uriInfo.getBaseUriBuilder().path(this.getClass(), "getObject")
.build(ObjectTypes.TASK.getRestType(), task.getOid()),
parentResult);
} catch (Exception ex) {
response = RestServiceUtil.handleException(parentResult, ex);
}
Expand Down
Expand Up @@ -6,6 +6,38 @@
*/
package com.evolveum.midpoint.model.impl.expr;

import static java.util.Collections.emptySet;
import static java.util.Collections.singleton;
import static org.apache.commons.collections4.CollectionUtils.emptyIfNull;

import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD;
import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE;
import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createObjectRef;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType.RUNNABLE;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.evolveum.midpoint.common.LocalizationService;
import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition;
import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition;
Expand All @@ -25,10 +57,9 @@
import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.model.impl.lens.LensFocusContext;
import com.evolveum.midpoint.model.impl.lens.LensProjectionContext;
import com.evolveum.midpoint.model.api.context.SynchronizationIntent;
import com.evolveum.midpoint.model.impl.messaging.MessageWrapper;
import com.evolveum.midpoint.model.impl.sync.SynchronizationExpressionsEvaluator;
import com.evolveum.midpoint.model.impl.sync.SynchronizationContext;
import com.evolveum.midpoint.model.impl.sync.SynchronizationExpressionsEvaluator;
import com.evolveum.midpoint.model.impl.sync.SynchronizationServiceUtils;
import com.evolveum.midpoint.model.impl.trigger.RecomputeTriggerHandler;
import com.evolveum.midpoint.prism.*;
Expand Down Expand Up @@ -72,42 +103,8 @@
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;

import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD;
import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE;
import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createObjectRef;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType.RUNNABLE;
import static java.util.Collections.emptySet;
import static java.util.Collections.singleton;
import static org.apache.commons.collections4.CollectionUtils.emptyIfNull;

/**
* @author semancik
*
*/
@Component
public class MidpointFunctionsImpl implements MidpointFunctions {
Expand All @@ -134,7 +131,6 @@ public class MidpointFunctionsImpl implements MidpointFunctions {
@Autowired private TriggerCreatorGlobalState triggerCreatorGlobalState;
@Autowired private TaskManager taskManager;
@Autowired private SchemaHelper schemaHelper;
@Context HttpServletRequest httpServletRequest;

@Autowired
@Qualifier("cacheRepositoryService")
Expand Down Expand Up @@ -762,7 +758,7 @@ public ModelProjectionContext getProjectionContext() {
}

@Override
public <V extends PrismValue, D extends ItemDefinition> Mapping<V,D> getMapping() {
public <V extends PrismValue, D extends ItemDefinition> Mapping<V, D> getMapping() {
return ModelExpressionThreadLocalHolder.getMapping();
}

Expand Down Expand Up @@ -863,7 +859,7 @@ private <T extends ObjectType> T resolveReferenceInternal(ObjectReferenceType re
if (reference == null) {
return null;
}
QName type = reference.getType(); // TODO what about implicitly specified types, like in resourceRef?
QName type = reference.getType(); // TODO what about implicitly specified types, like in resourceRef?
PrismObjectDefinition<T> objectDefinition = prismContext.getSchemaRegistry()
.findObjectDefinitionByType(reference.getType());
if (objectDefinition == null) {
Expand Down Expand Up @@ -1473,7 +1469,7 @@ public String createRegistrationConfirmationLink(UserType userType) {
if (securityPolicy != null && securityPolicy.getAuthentication() != null
&& securityPolicy.getAuthentication().getSequence() != null && !securityPolicy.getAuthentication().getSequence().isEmpty()) {
if (securityPolicy.getRegistration() != null && securityPolicy.getRegistration().getSelfRegistration() != null
&& securityPolicy.getRegistration().getSelfRegistration().getAdditionalAuthenticationName() != null) {
&& securityPolicy.getRegistration().getSelfRegistration().getAdditionalAuthenticationName() != null) {
String resetPasswordSequenceName = securityPolicy.getRegistration().getSelfRegistration().getAdditionalAuthenticationName();
String prefix = createPrefixLinkByAuthSequence(SchemaConstants.CHANNEL_GUI_SELF_REGISTRATION_URI, resetPasswordSequenceName, securityPolicy.getAuthentication().getSequence());
if (prefix != null) {
Expand Down Expand Up @@ -1517,24 +1513,24 @@ private String createTokenConfirmationLink(String prefix, UserType userType) {
return createBaseConfirmationLink(prefix, userType) + "&" + SchemaConstants.TOKEN + "=" + getNonce(userType);
}

private String createPrefixLinkByAuthSequence(String channel, String nameOfSequence, Collection<AuthenticationSequenceType> sequences){
AuthenticationSequenceType sequenceByName = null;
AuthenticationSequenceType defaultSequence = null;
for (AuthenticationSequenceType sequenceType : sequences) {
if (sequenceType.getName().equals(nameOfSequence)) {
sequenceByName = sequenceType;
break;
} else if (sequenceType.getChannel().getChannelId().equals(channel)
&& Boolean.TRUE.equals(sequenceType.getChannel().isDefault())) {
defaultSequence = sequenceType;
}
}
AuthenticationSequenceType usedSequence = sequenceByName != null ? sequenceByName : defaultSequence;
if (usedSequence != null) {
String sequecnceSuffix = usedSequence.getChannel().getUrlSuffix();
String prefix = (sequecnceSuffix.startsWith("/")) ? sequecnceSuffix : ("/" + sequecnceSuffix);
return SchemaConstants.AUTH_MODULE_PREFIX + prefix;
}
private String createPrefixLinkByAuthSequence(String channel, String nameOfSequence, Collection<AuthenticationSequenceType> sequences) {
AuthenticationSequenceType sequenceByName = null;
AuthenticationSequenceType defaultSequence = null;
for (AuthenticationSequenceType sequenceType : sequences) {
if (sequenceType.getName().equals(nameOfSequence)) {
sequenceByName = sequenceType;
break;
} else if (sequenceType.getChannel().getChannelId().equals(channel)
&& Boolean.TRUE.equals(sequenceType.getChannel().isDefault())) {
defaultSequence = sequenceType;
}
}
AuthenticationSequenceType usedSequence = sequenceByName != null ? sequenceByName : defaultSequence;
if (usedSequence != null) {
String sequecnceSuffix = usedSequence.getChannel().getUrlSuffix();
String prefix = (sequecnceSuffix.startsWith("/")) ? sequecnceSuffix : ("/" + sequecnceSuffix);
return SchemaConstants.AUTH_MODULE_PREFIX + prefix;
}
return null;
}

Expand Down Expand Up @@ -1622,7 +1618,7 @@ public ShadowType resolveEntitlement(ShadowAssociationType shadowAssociationType
LOGGER.trace("No shadowRef in association {}", shadowAssociationType);
return null;
}
if (shadowRef.asReferenceValue().getObject() != null){
if (shadowRef.asReferenceValue().getObject() != null) {
return (ShadowType) shadowAssociationType.getShadowRef().asReferenceValue().getObject().asObjectable();
}

Expand Down Expand Up @@ -1654,6 +1650,7 @@ public ExtensionType collectExtensions(AssignmentPathType path, int startAt)
ConfigurationException, ExpressionEvaluationException {
return AssignmentPath.collectExtensions(path, startAt, modelService, getCurrentTask(), getCurrentResult());
}

@Override
public TaskType executeChangesAsynchronously(Collection<ObjectDelta<?>> deltas, ModelExecuteOptions options,
String templateTaskOid) throws SecurityViolationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PolicyViolationException {
Expand All @@ -1676,7 +1673,7 @@ public TaskType executeChangesAsynchronously(Collection<ObjectDelta<?>> deltas,
newTask.setName(PolyStringType.fromOrig("Execute changes"));
newTask.setRecurrence(TaskRecurrenceType.SINGLE);
}
newTask.setName(PolyStringType.fromOrig(newTask.getName().getOrig() + " " + (int) (Math.random()*10000)));
newTask.setName(PolyStringType.fromOrig(newTask.getName().getOrig() + " " + (int) (Math.random() * 10000)));
newTask.setOid(null);
newTask.setTaskIdentifier(null);
newTask.setOwnerRef(createObjectRef(principal.getFocus(), prismContext));
Expand Down Expand Up @@ -1744,9 +1741,9 @@ public Object executeAdHocProvisioningScript(ResourceType resource, String langu

@Override
public Object executeAdHocProvisioningScript(String resourceOid, String language, String code)
throws SchemaException, ObjectNotFoundException,
ExpressionEvaluationException, CommunicationException, ConfigurationException,
SecurityViolationException, ObjectAlreadyExistsException {
throws SchemaException, ObjectNotFoundException,
ExpressionEvaluationException, CommunicationException, ConfigurationException,
SecurityViolationException, ObjectAlreadyExistsException {
OperationProvisioningScriptType script = new OperationProvisioningScriptType();
script.setCode(code);
script.setLanguage(language);
Expand Down Expand Up @@ -1905,7 +1902,7 @@ public <O extends ObjectType> boolean hasArchetype(O object, String archetypeOid
}
}

List<ObjectReferenceType> archetypeRefs = ((AssignmentHolderType)object).getArchetypeRef();
List<ObjectReferenceType> archetypeRefs = ((AssignmentHolderType) object).getArchetypeRef();
if (archetypeOid == null) {
return archetypeRefs.isEmpty();
}
Expand Down Expand Up @@ -2031,7 +2028,7 @@ public <T extends AssignmentHolderType> List<T> findAssignees(Class<T> type) thr
ExpressionEvaluationException {
ObjectQuery query = prismContext.queryFor(type)
.item(AssignmentHolderType.F_ROLE_MEMBERSHIP_REF)
.ref(getFocusObjectReference().asReferenceValue().clone())
.ref(getFocusObjectReference().asReferenceValue().clone())
.build();
return searchObjects(type, query, null);
}
Expand Down
9 changes: 6 additions & 3 deletions model/rest-impl/pom.xml
Expand Up @@ -49,7 +49,7 @@
<artifactId>schema</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<dependency>
<groupId>com.evolveum.midpoint.infra</groupId>
<artifactId>util</artifactId>
<version>${project.version}</version>
Expand All @@ -63,15 +63,14 @@
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand All @@ -85,5 +84,9 @@
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
</project>

0 comments on commit 0743f9c

Please sign in to comment.