diff --git a/infra/common/pom.xml b/infra/common/pom.xml index 539b76f4b09..6adc8368311 100644 --- a/infra/common/pom.xml +++ b/infra/common/pom.xml @@ -111,25 +111,6 @@ javax.annotation-api - - - org.apache.cxf - cxf-rt-rs-extension-providers - runtime - - - javax.ws.rs - javax.ws.rs-api - - - org.apache.cxf - cxf-rt-frontend-jaxrs - - - org.springframework - spring-beans - - org.testng diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/Converter.java b/infra/common/src/main/java/com/evolveum/midpoint/common/rest/Converter.java deleted file mode 100644 index d8c6c559274..00000000000 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/Converter.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2010-2017 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.common.rest; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author mederly - */ -@Target({ ElementType.PARAMETER}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Converter { - - Class value(); -} diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/ConverterInterface.java b/infra/common/src/main/java/com/evolveum/midpoint/common/rest/ConverterInterface.java deleted file mode 100644 index 373564c8279..00000000000 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/ConverterInterface.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2010-2017 Evolveum and contributors - * - * This work is dual-licensed under the Apache License 2.0 - * and European Union Public License. See LICENSE file for details. - */ - -package com.evolveum.midpoint.common.rest; - -import org.jetbrains.annotations.NotNull; - -/** - * @author mederly - */ -@FunctionalInterface -public interface ConverterInterface { - - /** - * Converts incoming object into a form that is consumable by the REST service. - * - * @param input Object to be converted (coming as input) - * @return Object to be passed to the REST service. - */ - Object convert(@NotNull Object input); -} diff --git a/infra/common/src/main/resources/ctx-common.xml b/infra/common/src/main/resources/ctx-common.xml index cf4d35d8e57..0e66f6a2925 100644 --- a/infra/common/src/main/resources/ctx-common.xml +++ b/infra/common/src/main/resources/ctx-common.xml @@ -45,8 +45,4 @@ - - - - diff --git a/infra/common/src/test/java/com/evolveum/midpoint/validator/test/BasicValidatorTest.java b/infra/common/src/test/java/com/evolveum/midpoint/validator/test/BasicValidatorTest.java index da313645e83..78bdd7fd558 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/validator/test/BasicValidatorTest.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/validator/test/BasicValidatorTest.java @@ -7,6 +7,7 @@ package com.evolveum.midpoint.validator.test; +import static org.assertj.core.api.Assertions.assertThat; import static org.testng.AssertJUnit.*; import java.io.File; @@ -146,10 +147,9 @@ public void notWellFormed() throws Exception { System.out.println(result.debugDump()); AssertJUnit.assertFalse(result.isSuccess()); String message = result.getMessage(); - AssertJUnit.assertTrue(message.contains("Unexpected close tag")); + assertThat(message).contains("The element type \"resource\" must be terminated by the matching end-tag"); // Check if line number is in the error - AssertJUnit.assertTrue("Line number not found in error message: " + message, message.contains("26")); - + AssertJUnit.assertTrue("Line number not found in error message: " + message, message.contains("25")); } @Test @@ -161,7 +161,7 @@ public void undeclaredPrefix() throws Exception { System.out.println(result.debugDump()); AssertJUnit.assertFalse(result.isSuccess()); String message = result.getMessage(); - AssertJUnit.assertTrue(message.contains("Undeclared namespace prefix")); + assertThat(message).contains("Element type \"ri:Account\" must be followed by either attribute specifications"); // Check if line number is in the error AssertJUnit.assertTrue("Line number not found in error message: " + message, message.contains("28")); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java index cc806a89e9b..6cc2ad80da8 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java @@ -19,7 +19,6 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.Validate; import org.apache.cxf.jaxrs.ext.MessageContext; -import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; @@ -29,16 +28,13 @@ import com.evolveum.midpoint.audit.api.AuditEventStage; import com.evolveum.midpoint.audit.api.AuditEventType; import com.evolveum.midpoint.audit.api.AuditService; -import com.evolveum.midpoint.common.rest.Converter; -import com.evolveum.midpoint.common.rest.ConverterInterface; import com.evolveum.midpoint.model.api.*; import com.evolveum.midpoint.model.api.validator.ResourceValidator; import com.evolveum.midpoint.model.api.validator.Scope; import com.evolveum.midpoint.model.api.validator.ValidationResult; import com.evolveum.midpoint.model.common.SystemObjectCache; -import com.evolveum.midpoint.model.impl.rest.PATCH; +import com.evolveum.midpoint.task.quartzimpl.rest.PATCH; import com.evolveum.midpoint.model.impl.scripting.PipelineData; -import com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator; import com.evolveum.midpoint.model.impl.security.SecurityHelper; import com.evolveum.midpoint.model.impl.util.RestServiceUtil; import com.evolveum.midpoint.prism.PrismContext; @@ -70,7 +66,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_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; /** @@ -821,22 +816,10 @@ public Response scheduleTaskNow(@PathParam("oid") String taskOid, @Context Messa return response; } - public static class ExecuteScriptConverter implements ConverterInterface { - public ExecuteScriptType convert(@NotNull Object input) { - if (input instanceof ExecuteScriptType) { - return (ExecuteScriptType) input; - } else if (input instanceof ScriptingExpressionType) { - return ScriptingExpressionEvaluator.createExecuteScriptCommand((ScriptingExpressionType) input); - } else { - throw new IllegalArgumentException("Wrong input value: " + input); - } - } - } - @POST @Path("/rpc/executeScript") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, RestServiceUtil.APPLICATION_YAML }) - public Response executeScript(@Converter(ExecuteScriptConverter.class) ExecuteScriptType command, + public Response executeScript(ExecuteScriptType command, @QueryParam("asynchronous") Boolean asynchronous, @Context UriInfo uriInfo, @Context MessageContext mc) { Task task = initRequest(mc); diff --git a/model/model-impl/src/main/resources/ctx-model.xml b/model/model-impl/src/main/resources/ctx-model.xml index c367c974e66..370b0029f56 100644 --- a/model/model-impl/src/main/resources/ctx-model.xml +++ b/model/model-impl/src/main/resources/ctx-model.xml @@ -279,22 +279,6 @@ - - - - - - - - - - - - - - - - diff --git a/model/model-test/src/main/resources/ctx-model-test.xml b/model/model-test/src/main/resources/ctx-model-test.xml index 165ce87603c..86c16f0dc4f 100644 --- a/model/model-test/src/main/resources/ctx-model-test.xml +++ b/model/model-test/src/main/resources/ctx-model-test.xml @@ -8,26 +8,13 @@ --> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.0.xsd" + default-lazy-init="false"> diff --git a/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java b/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java index 6e112bc2241..4ea8338bee8 100644 --- a/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java +++ b/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java @@ -306,7 +306,7 @@ public void test900HeapUsage() throws Exception { int size = 2_000_000; int count = 300; - // 50 is the default "step" in paged iterative search, so we can expect we always have 50 objects in memory + // 50 is the default "step" in paged iterative search, so we can expect we always have 50 objects in memory. // And "times 2" is the safety margin. It might or might not be sufficient, as System.gc() is not guaranteed to // really execute the garbage collection (only suggests JVM to do it). long tolerance = (50 * size) * 2; diff --git a/repo/task-quartz-impl/pom.xml b/repo/task-quartz-impl/pom.xml index 96fd84d0747..56427d40aeb 100644 --- a/repo/task-quartz-impl/pom.xml +++ b/repo/task-quartz-impl/pom.xml @@ -111,10 +111,6 @@ org.apache.cxf cxf-rt-rs-client - - org.apache.cxf - cxf-core - javax.ws.rs javax.ws.rs-api diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterExecutionHelperImpl.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterExecutionHelperImpl.java index 07ff4df46b3..44fd4a1459d 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterExecutionHelperImpl.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterExecutionHelperImpl.java @@ -7,9 +7,9 @@ package com.evolveum.midpoint.task.quartzimpl.cluster; -import com.evolveum.midpoint.common.rest.MidpointJsonProvider; -import com.evolveum.midpoint.common.rest.MidpointXmlProvider; -import com.evolveum.midpoint.common.rest.MidpointYamlProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointJsonProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointXmlProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointYamlProvider; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.crypto.EncryptionException; diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterManager.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterManager.java index 0ad67a7523f..75e33285f7d 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterManager.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterManager.java @@ -6,6 +6,10 @@ */ package com.evolveum.midpoint.task.quartzimpl.cluster; +import java.util.List; + +import org.jetbrains.annotations.Nullable; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.query.ObjectQuery; @@ -24,9 +28,6 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeOperationalStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType; -import org.jetbrains.annotations.Nullable; - -import java.util.List; /** * Responsible for keeping the cluster consistent. diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterStatusInformation.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterStatusInformation.java index 97c4bda690a..9d0d1cc6431 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterStatusInformation.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/ClusterStatusInformation.java @@ -7,13 +7,13 @@ package com.evolveum.midpoint.task.quartzimpl.cluster; +import java.io.Serializable; +import java.util.*; + import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SchedulerInformationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; -import java.io.Serializable; -import java.util.*; - /** * Provides information about tasks currently executing at particular nodes in the cluster. * diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/NodeRegistrar.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/NodeRegistrar.java index 5cb56b99af1..4d2d5073f71 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/NodeRegistrar.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/cluster/NodeRegistrar.java @@ -7,6 +7,23 @@ package com.evolveum.midpoint.task.quartzimpl.cluster; +import java.lang.management.ManagementFactory; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.*; +import javax.management.MBeanServer; +import javax.management.ObjectName; +import javax.management.Query; +import javax.management.QueryExp; +import javax.xml.datatype.XMLGregorianCalendar; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.RandomStringUtils; +import org.jetbrains.annotations.NotNull; + import com.evolveum.midpoint.common.LocalizationService; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; @@ -36,22 +53,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.*; 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.apache.commons.lang3.RandomStringUtils; -import org.jetbrains.annotations.NotNull; - -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.management.Query; -import javax.management.QueryExp; -import javax.xml.datatype.XMLGregorianCalendar; -import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.*; /** * Takes care about node registration in repository. diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/JobExecutor.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/JobExecutor.java index dc546f9754f..98d5a096624 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/JobExecutor.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/JobExecutor.java @@ -10,9 +10,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.task.api.*; diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/RemoteNodesManager.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/RemoteNodesManager.java index 82191544401..20968195d58 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/RemoteNodesManager.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/RemoteNodesManager.java @@ -6,13 +6,14 @@ */ package com.evolveum.midpoint.task.quartzimpl.execution; +import org.quartz.JobKey; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation; -import com.evolveum.midpoint.task.quartzimpl.TaskManagerConfiguration; import com.evolveum.midpoint.task.quartzimpl.TaskManagerQuartzImpl; import com.evolveum.midpoint.task.quartzimpl.cluster.ClusterManager; +import com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation; import com.evolveum.midpoint.task.quartzimpl.execution.remote.JmxConnector; import com.evolveum.midpoint.task.quartzimpl.execution.remote.RestConnector; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; @@ -22,8 +23,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeOperationalStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType; -import org.quartz.*; - /** * Manages remote nodes. Concerned mainly with * - stopping threads and querying their state, @@ -37,9 +36,9 @@ public class RemoteNodesManager { public static final JobKey STARTER_JOB_KEY = JobKey.jobKey("STARTER JOB"); - private TaskManagerQuartzImpl taskManager; - private JmxConnector jmxConnector; - private RestConnector restConnector; + private final TaskManagerQuartzImpl taskManager; + private final JmxConnector jmxConnector; + private final RestConnector restConnector; public RemoteNodesManager(TaskManagerQuartzImpl taskManager) { this.taskManager = taskManager; @@ -135,14 +134,6 @@ public void startRemoteScheduler(String nodeIdentifier, OperationResult parentRe } } - private TaskManagerConfiguration getConfiguration() { - return taskManager.getConfiguration(); - } - - private ExecutionManager getGlobalExecutionManager() { - return taskManager.getExecutionManager(); - } - // the task should be really running void stopRemoteTaskRun(String oid, NodeType node, OperationResult parentResult) { @@ -167,5 +158,4 @@ void stopRemoteTaskRun(String oid, NodeType node, OperationResult parentResult) private ClusterManager getClusterManager() { return taskManager.getClusterManager(); } - } diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/remote/JmxConnector.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/remote/JmxConnector.java index 2d408799113..6869f0134ed 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/remote/JmxConnector.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/execution/remote/JmxConnector.java @@ -45,7 +45,7 @@ public class JmxConnector { private static final Trace LOGGER = TraceManager.getTrace(JmxConnector.class); - private TaskManagerQuartzImpl taskManager; + private final TaskManagerQuartzImpl taskManager; public JmxConnector(TaskManagerQuartzImpl taskManager) { this.taskManager = taskManager; @@ -345,5 +345,4 @@ private QuartzSchedulerMBean getSchedulerBean(NodeType node, Holder extends AbstractConfigurableProvider implements MessageBodyReader, MessageBodyWriter{ +@Deprecated +public abstract class MidpointAbstractProvider extends AbstractConfigurableProvider + implements MessageBodyReader, MessageBodyWriter { private static final Trace LOGGER = TraceManager.getTrace(MidpointAbstractProvider.class); @@ -58,7 +58,8 @@ public void init(List cris) { @Override public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { - if (type.getPackage().getName().startsWith("com.evolveum.midpoint") || type.getPackage().getName().startsWith("com.evolveum.prism")){ + if (type.getPackage().getName().startsWith("com.evolveum.midpoint") + || type.getPackage().getName().startsWith("com.evolveum.prism")) { return true; } return false; @@ -110,7 +111,7 @@ public void writeTo(T object, Class type, Type genericType, @Override public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { - if (type.getPackage().getName().startsWith("com.evolveum.midpoint") || type.getPackage().getName().startsWith("com.evolveum.prism")){ + if (type.getPackage().getName().startsWith("com.evolveum.midpoint") || type.getPackage().getName().startsWith("com.evolveum.prism")) { return true; } return false; @@ -128,30 +129,37 @@ public T readFrom(Class type, Type genericType, PrismParser parser = getParser(entityStream); - T object; + Object object; try { if (PrismObject.class.isAssignableFrom(type)) { - object = (T) parser.parse(); + object = parser.parse(); } else { - object = parser.parseRealValue(); // TODO consider prescribing type here (if no converter is specified) + object = parser.parseRealValue(); } - if (object != null && !type.isAssignableFrom(object.getClass())) { // TODO treat multivalues here - Optional converterAnnotation = Arrays.stream(annotations).filter(a -> a instanceof Converter).findFirst(); - if (converterAnnotation.isPresent()) { - Class converterClass = ((Converter) converterAnnotation.get()).value(); - ConverterInterface converter; - try { - converter = converterClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - throw new SystemException("Couldn't instantiate converter class " + converterClass, e); - } - object = (T) converter.convert(object); - } + if (object != null && !type.isAssignableFrom(object.getClass())) { + // This code covers type migrations, eventually we'd like to drop old type support. + object = migrateType(object, type); } - return object; + return type.cast(object); } catch (SchemaException ex) { throw new WebApplicationException(ex); } } + + // this better be T after this is executed + private Object migrateType(Object object, Class clazz) { + if (clazz.equals(ExecuteScriptType.class)) { + // TODO: deprecate ScriptingExpressionType in favour of ExecuteScriptType (next LTS? 4.4? 5.0?) + if (object instanceof ExecuteScriptType) { + return object; + } else if (object instanceof ScriptingExpressionType) { + return ScriptingExpressionEvaluator.createExecuteScriptCommand((ScriptingExpressionType) object); + } else { + throw new IllegalArgumentException("Wrong input value for ExecuteScriptType: " + object); + } + } + // no other migrations + return object; + } } diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointJsonProvider.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointJsonProvider.java similarity index 85% rename from infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointJsonProvider.java rename to repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointJsonProvider.java index e3a70452be3..59b7c880724 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointJsonProvider.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointJsonProvider.java @@ -5,21 +5,23 @@ * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.common.rest; +package com.evolveum.midpoint.task.quartzimpl.rest; import java.io.InputStream; - import javax.ws.rs.Consumes; import javax.ws.rs.Produces; import javax.ws.rs.ext.Provider; +import org.springframework.stereotype.Component; + import com.evolveum.midpoint.prism.PrismParser; import com.evolveum.midpoint.prism.PrismSerializer; @Produces({"application/json"}) @Consumes({"application/json"}) @Provider -public class MidpointJsonProvider extends MidpointAbstractProvider{ +@Component("jsonProvider") +public class MidpointJsonProvider extends MidpointAbstractProvider { @Override protected PrismSerializer getSerializer() { diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointXmlProvider.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointXmlProvider.java similarity index 87% rename from infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointXmlProvider.java rename to repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointXmlProvider.java index 2489f1e9374..9e8737ad126 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointXmlProvider.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointXmlProvider.java @@ -5,20 +5,22 @@ * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.common.rest; +package com.evolveum.midpoint.task.quartzimpl.rest; import java.io.InputStream; - import javax.ws.rs.Consumes; import javax.ws.rs.Produces; import javax.ws.rs.ext.Provider; +import org.springframework.stereotype.Component; + import com.evolveum.midpoint.prism.PrismParser; import com.evolveum.midpoint.prism.PrismSerializer; @Produces({"application/xml", "application/*+xml", "text/xml"}) @Consumes({"application/xml", "application/*+xml", "text/xml"}) @Provider +@Component("jaxbProvider") public class MidpointXmlProvider extends MidpointAbstractProvider { @Override diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointYamlProvider.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointYamlProvider.java similarity index 72% rename from infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointYamlProvider.java rename to repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointYamlProvider.java index 2d9068a69f4..e07372979a4 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/rest/MidpointYamlProvider.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/MidpointYamlProvider.java @@ -5,20 +5,22 @@ * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.common.rest; +package com.evolveum.midpoint.task.quartzimpl.rest; import java.io.InputStream; - import javax.ws.rs.Consumes; import javax.ws.rs.Produces; import javax.ws.rs.ext.Provider; +import org.springframework.stereotype.Component; + import com.evolveum.midpoint.prism.PrismParser; import com.evolveum.midpoint.prism.PrismSerializer; -@Produces({"application/yaml", "application/x-yaml", "text/yaml", "text/x-yaml"}) -@Consumes({"application/yaml", "application/x-yaml", "text/yaml", "text/x-yaml"}) +@Produces({ "application/yaml", "application/x-yaml", "text/yaml", "text/x-yaml" }) +@Consumes({ "application/yaml", "application/x-yaml", "text/yaml", "text/x-yaml" }) @Provider +@Component("yamlProvider") public class MidpointYamlProvider extends MidpointAbstractProvider { @Override diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/rest/PATCH.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/PATCH.java similarity index 90% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/rest/PATCH.java rename to repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/PATCH.java index 322e7e35a0a..56af8fb10a1 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/rest/PATCH.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/rest/PATCH.java @@ -4,7 +4,7 @@ * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.rest; +package com.evolveum.midpoint.task.quartzimpl.rest; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/testing/rest/pom.xml b/testing/rest/pom.xml index 0626dfbaeaf..97a905c8b29 100644 --- a/testing/rest/pom.xml +++ b/testing/rest/pom.xml @@ -36,11 +36,6 @@ - - com.evolveum.midpoint.infra - common - 4.2-SNAPSHOT - com.evolveum.midpoint.infra prism-api diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/RestServiceInitializer.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/RestServiceInitializer.java index 5be109cd4d2..bb637ca2460 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/RestServiceInitializer.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/RestServiceInitializer.java @@ -21,13 +21,12 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; -import com.evolveum.midpoint.common.rest.MidpointAbstractProvider; -import com.evolveum.midpoint.common.rest.MidpointJsonProvider; -import com.evolveum.midpoint.common.rest.MidpointXmlProvider; -import com.evolveum.midpoint.common.rest.MidpointYamlProvider; import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication; import com.evolveum.midpoint.model.api.ModelExecuteOptions; import com.evolveum.midpoint.model.api.ModelService; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointAbstractProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointJsonProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointXmlProvider; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.provisioning.api.ProvisioningService; @@ -99,16 +98,13 @@ public abstract class RestServiceInitializer extends AbstractGuiIntegrationTest @Autowired protected MidpointJsonProvider jsonProvider; - @Autowired - protected MidpointYamlProvider yamlProvider; - protected abstract String getAcceptHeader(); protected abstract String getContentType(); protected abstract MidpointAbstractProvider getProvider(); protected String ENDPOINT_ADDRESS = "http://localhost:" + TestMidPointSpringApplication.DEFAULT_PORT - + System.getProperty("mp.test.rest.context.path", "/ws/rest"); + + System.getProperty("mp.test.rest.context.path", "/rest2"); @Override public void initSystem(Task initTask, OperationResult result) throws Exception { @@ -194,17 +190,4 @@ public ProvisioningService getProvisioning() { public DummyAuditService getDummyAuditService() { return dummyAuditService; } - - public MidpointXmlProvider getXmlProvider() { - return xmlProvider; - } - - public MidpointJsonProvider getJsonProvider() { - return jsonProvider; - } - - public MidpointYamlProvider getYamlProvider() { - return yamlProvider; - } - } diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceJson.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceJson.java index ee1e0bc1df4..a15c6cbd9cc 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceJson.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceJson.java @@ -10,10 +10,16 @@ import java.io.File; import javax.ws.rs.core.MediaType; -import com.evolveum.midpoint.common.rest.MidpointAbstractProvider; +import org.springframework.beans.factory.annotation.Autowired; + +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointAbstractProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointJsonProvider; public class TestRestServiceJson extends TestAbstractRestService { + @Autowired + protected MidpointJsonProvider jsonProvider; + @Override protected String getAcceptHeader() { return MediaType.APPLICATION_JSON; @@ -24,7 +30,6 @@ protected String getContentType() { return MediaType.APPLICATION_JSON; } - @Override protected File getRepoFile(String fileBaseName) { return new File(BASE_REPO_DIR + "/json", fileBaseName + ".json"); @@ -39,5 +44,4 @@ protected File getRequestFile(String fileBaseName) { protected MidpointAbstractProvider getProvider() { return jsonProvider; } - } diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java index 53bb7ea2d6d..190023c2d8c 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java @@ -14,10 +14,12 @@ import org.apache.commons.lang3.StringUtils; import org.apache.cxf.jaxrs.client.WebClient; +import org.springframework.beans.factory.annotation.Autowired; import org.testng.AssertJUnit; import org.testng.annotations.Test; -import com.evolveum.midpoint.common.rest.MidpointAbstractProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointAbstractProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointYamlProvider; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; @@ -50,6 +52,9 @@ public class TestRestServiceProxyAuthentication extends RestServiceInitializer { public static final String USER_PROXY_USERNAME = "proxy"; public static final String USER_PROXY_PASSWORD = "ProxyPassw0rd"; + @Autowired + protected MidpointYamlProvider yamlProvider; + @Override public void initSystem(Task initTask, OperationResult result) throws Exception { super.initSystem(initTask, result); diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceXml.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceXml.java index 80b49bd67ad..579c0416d04 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceXml.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceXml.java @@ -10,7 +10,7 @@ import java.io.File; import javax.ws.rs.core.MediaType; -import com.evolveum.midpoint.common.rest.MidpointAbstractProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointAbstractProvider; public class TestRestServiceXml extends TestAbstractRestService { diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceYaml.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceYaml.java index 659146e2b33..39cad87aa60 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceYaml.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceYaml.java @@ -9,10 +9,16 @@ import java.io.File; -import com.evolveum.midpoint.common.rest.MidpointAbstractProvider; +import org.springframework.beans.factory.annotation.Autowired; + +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointAbstractProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointYamlProvider; public class TestRestServiceYaml extends TestAbstractRestService { + @Autowired + protected MidpointYamlProvider yamlProvider; + @Override protected String getAcceptHeader() { return "application/yaml"; @@ -23,7 +29,6 @@ protected String getContentType() { return "application/yaml"; } - @Override protected File getRepoFile(String fileBaseName) { return new File(BASE_REPO_DIR + "/yaml", fileBaseName + ".yml"); @@ -38,5 +43,4 @@ protected File getRequestFile(String fileBaseName) { protected MidpointAbstractProvider getProvider() { return yamlProvider; } - } diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestSecurityQuestionChallengeResponse.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestSecurityQuestionChallengeResponse.java index 80935da3013..2ecd377f8f8 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestSecurityQuestionChallengeResponse.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestSecurityQuestionChallengeResponse.java @@ -20,14 +20,19 @@ import org.apache.cxf.jaxrs.client.ClientConfiguration; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.cxf.transport.local.LocalConduit; +import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.Test; -import com.evolveum.midpoint.common.rest.MidpointAbstractProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointAbstractProvider; +import com.evolveum.midpoint.task.quartzimpl.rest.MidpointYamlProvider; import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; public class TestSecurityQuestionChallengeResponse extends RestServiceInitializer { + @Autowired + protected MidpointYamlProvider yamlProvider; + @Test public void testChallengeResponse() { Response response = getUserAdministrator("SecQ"); @@ -124,5 +129,4 @@ protected String getContentType() { protected MidpointAbstractProvider getProvider() { return jsonProvider; } - } diff --git a/testing/rest/src/test/resources/logback-test.xml b/testing/rest/src/test/resources/logback-test.xml index 05d782b40a9..63ec735773c 100644 --- a/testing/rest/src/test/resources/logback-test.xml +++ b/testing/rest/src/test/resources/logback-test.xml @@ -37,7 +37,7 @@ - +