You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/07/06 14:56:19 UTC
[4/4] syncope git commit: [SYNCOPE-1145] Core and Common
implementation completed, Console still TODO
[SYNCOPE-1145] Core and Common implementation completed, Console still TODO
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/7451efb6
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/7451efb6
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/7451efb6
Branch: refs/heads/master
Commit: 7451efb6d274cc446da952d7b607357b0422f30f
Parents: d4cd448
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Jul 6 16:55:56 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Jul 6 16:56:07 2017 +0200
----------------------------------------------------------------------
.../wizards/resources/ConnectorConfPanel.java | 8 +-
.../common/lib/to/AbstractHistoryConf.java | 72 ++++++
.../lib/to/ConnInstanceHistoryConfTO.java | 40 ++++
.../syncope/common/lib/to/ConnInstanceTO.java | 22 +-
.../common/lib/to/ResourceHistoryConfTO.java | 40 ++++
.../common/lib/types/StandardEntitlement.java | 12 +
.../api/service/ConnectorHistoryService.java | 66 ++++++
.../api/service/ResourceHistoryService.java | 66 ++++++
.../core/logic/ConnectorHistoryLogic.java | 115 +++++++++
.../syncope/core/logic/ConnectorLogic.java | 26 +-
.../core/logic/ResourceHistoryLogic.java | 114 +++++++++
.../syncope/core/logic/ResourceLogic.java | 40 +---
.../apache/syncope/core/logic/SchemaLogic.java | 28 +--
.../api/dao/ConnInstanceHistoryConfDAO.java | 36 +++
.../api/dao/ExternalResourceHistoryConfDAO.java | 36 +++
.../api/entity/ConnInstanceHistoryConf.java | 24 ++
.../persistence/api/entity/HistoryConf.java | 41 ++++
.../resource/ExternalResourceHistoryConf.java | 25 ++
.../persistence/jpa/dao/JPAConnInstanceDAO.java | 8 +-
.../jpa/dao/JPAConnInstanceHistoryConfDAO.java | 71 ++++++
.../jpa/dao/JPAExternalResourceDAO.java | 15 ++
.../dao/JPAExternalResourceHistoryConfDAO.java | 71 ++++++
.../jpa/entity/AbstractHistoryConf.java | 76 ++++++
.../jpa/entity/JPAConnInstanceHistoryConf.java | 59 +++++
.../jpa/entity/JPAEntityFactory.java | 7 +
.../JPAExternalResourceHistoryConf.java | 60 +++++
.../main/resources/domains/MasterContent.xml | 17 ++
.../persistence/jpa/inner/PlainSchemaTest.java | 2 +-
.../jpa/outer/ConnInstanceHistoryConfTest.java | 74 ++++++
.../jpa/outer/ResourceHistoryConfTest.java | 74 ++++++
.../test/resources/domains/MasterContent.xml | 19 +-
.../api/data/ConnInstanceDataBinder.java | 2 +-
.../java/data/ConnInstanceDataBinderImpl.java | 53 ++++-
.../java/data/ResourceDataBinderImpl.java | 33 ++-
.../AbstractPropagationTaskExecutor.java | 8 +-
.../service/ConnectorHistoryServiceImpl.java | 49 ++++
.../cxf/service/ResourceHistoryServiceImpl.java | 49 ++++
.../org/apache/syncope/fit/AbstractITCase.java | 22 +-
.../syncope/fit/core/ConnectorITCase.java | 236 +++++++++++--------
.../apache/syncope/fit/core/PullTaskITCase.java | 4 +-
.../apache/syncope/fit/core/ResourceITCase.java | 86 +++++--
41 files changed, 1665 insertions(+), 241 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ConnectorConfPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ConnectorConfPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ConnectorConfPanel.java
index 21d494d..580e2c8 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ConnectorConfPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ConnectorConfPanel.java
@@ -87,11 +87,9 @@ public abstract class ConnectorConfPanel extends AbstractConnConfPanel<ConnInsta
final ConnConfProperty property = new ConnConfProperty();
property.setSchema(key);
- if (instance.getConfMap().containsKey(key.getName())
- && instance.getConfMap().get(key.getName()).getValues() != null) {
-
- property.getValues().addAll(instance.getConfMap().get(key.getName()).getValues());
- property.setOverridable(instance.getConfMap().get(key.getName()).isOverridable());
+ if (instance.getConf(key.getName()) != null && instance.getConf(key.getName()).getValues() != null) {
+ property.getValues().addAll(instance.getConf(key.getName()).getValues());
+ property.setOverridable(instance.getConf(key.getName()).isOverridable());
}
if (property.getValues().isEmpty() && !key.getDefaultValues().isEmpty()) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractHistoryConf.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractHistoryConf.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractHistoryConf.java
new file mode 100644
index 0000000..a410a73
--- /dev/null
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AbstractHistoryConf.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.common.lib.to;
+
+import java.util.Date;
+import javax.ws.rs.PathParam;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+import org.apache.syncope.common.lib.AbstractBaseBean;
+
+@XmlRootElement(name = "abstractHistoryConf")
+@XmlType
+@XmlSeeAlso({ ConnInstanceHistoryConfTO.class, ResourceHistoryConfTO.class })
+public abstract class AbstractHistoryConf extends AbstractBaseBean implements EntityTO {
+
+ private static final long serialVersionUID = -8001640160293506651L;
+
+ private String key;
+
+ private String creator;
+
+ private Date creation;
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @PathParam("key")
+ @Override
+ public void setKey(final String key) {
+ this.key = key;
+ }
+
+ public String getCreator() {
+ return creator;
+ }
+
+ public void setCreator(final String creator) {
+ this.creator = creator;
+ }
+
+ public Date getCreation() {
+ return creation == null
+ ? null
+ : new Date(creation.getTime());
+ }
+
+ public void setCreation(final Date creation) {
+ this.creation = creation == null
+ ? null
+ : new Date(creation.getTime());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceHistoryConfTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceHistoryConfTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceHistoryConfTO.java
new file mode 100644
index 0000000..6583c54
--- /dev/null
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceHistoryConfTO.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.common.lib.to;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "connInstanceHistoryConf")
+@XmlType
+public class ConnInstanceHistoryConfTO extends AbstractHistoryConf {
+
+ private static final long serialVersionUID = 8067539341757100479L;
+
+ private ConnInstanceTO connInstanceTO;
+
+ public ConnInstanceTO getConnInstanceTO() {
+ return connInstanceTO;
+ }
+
+ public void setConnInstanceTO(final ConnInstanceTO connInstanceTO) {
+ this.connInstanceTO = connInstanceTO;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java
index 4f91355..d7c8be7 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ConnInstanceTO.java
@@ -20,17 +20,16 @@ package org.apache.syncope.common.lib.to;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Collections;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import org.apache.commons.collections4.IterableUtils;
+import org.apache.commons.collections4.Predicate;
import org.apache.syncope.common.lib.AbstractBaseBean;
import org.apache.syncope.common.lib.types.ConnConfProperty;
import org.apache.syncope.common.lib.types.ConnectorCapability;
@@ -112,15 +111,14 @@ public class ConnInstanceTO extends AbstractBaseBean implements EntityTO {
}
@JsonIgnore
- public Map<String, ConnConfProperty> getConfMap() {
- Map<String, ConnConfProperty> result = new HashMap<>();
-
- for (ConnConfProperty prop : getConf()) {
- result.put(prop.getSchema().getName(), prop);
- }
- result = Collections.unmodifiableMap(result);
-
- return Collections.unmodifiableMap(result);
+ public ConnConfProperty getConf(final String schemaName) {
+ return IterableUtils.find(conf, new Predicate<ConnConfProperty>() {
+
+ @Override
+ public boolean evaluate(final ConnConfProperty object) {
+ return object.getSchema().getName().equals(schemaName);
+ }
+ });
}
@XmlElementWrapper(name = "capabilities")
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/common/lib/src/main/java/org/apache/syncope/common/lib/to/ResourceHistoryConfTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ResourceHistoryConfTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ResourceHistoryConfTO.java
new file mode 100644
index 0000000..388b63c
--- /dev/null
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ResourceHistoryConfTO.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.common.lib.to;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "resourceHistoryConf")
+@XmlType
+public class ResourceHistoryConfTO extends AbstractHistoryConf {
+
+ private static final long serialVersionUID = -7308499697925335157L;
+
+ private ResourceTO resourceTO;
+
+ public ResourceTO getResourceTO() {
+ return resourceTO;
+ }
+
+ public void setResourceTO(final ResourceTO resourceTO) {
+ this.resourceTO = resourceTO;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/common/lib/src/main/java/org/apache/syncope/common/lib/types/StandardEntitlement.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/types/StandardEntitlement.java b/common/lib/src/main/java/org/apache/syncope/common/lib/types/StandardEntitlement.java
index 81709f6..9bf8de3 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/types/StandardEntitlement.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/types/StandardEntitlement.java
@@ -128,6 +128,12 @@ public final class StandardEntitlement {
public static final String RESOURCE_LIST_CONNOBJECT = "RESOURCE_LIST_CONNOBJECT";
+ public static final String RESOURCE_HISTORY_LIST = "RESOURCE_HISTORY_LIST";
+
+ public static final String RESOURCE_HISTORY_RESTORE = "RESOURCE_HISTORY_RESTORE";
+
+ public static final String RESOURCE_HISTORY_DELETE = "RESOURCE_HISTORY_DELETE";
+
public static final String CONNECTOR_LIST = "CONNECTOR_LIST";
public static final String CONNECTOR_CREATE = "CONNECTOR_CREATE";
@@ -140,6 +146,12 @@ public final class StandardEntitlement {
public static final String CONNECTOR_RELOAD = "CONNECTOR_RELOAD";
+ public static final String CONNECTOR_HISTORY_LIST = "CONNECTOR_HISTORY_LIST";
+
+ public static final String CONNECTOR_HISTORY_RESTORE = "CONNECTOR_HISTORY_RESTORE";
+
+ public static final String CONNECTOR_HISTORY_DELETE = "CONNECTOR_HISTORY_DELETE";
+
public static final String CONFIGURATION_EXPORT = "CONFIGURATION_EXPORT";
public static final String CONFIGURATION_LIST = "CONFIGURATION_LIST";
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConnectorHistoryService.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConnectorHistoryService.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConnectorHistoryService.java
new file mode 100644
index 0000000..28a0b3c
--- /dev/null
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConnectorHistoryService.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.common.rest.api.service;
+
+import java.util.List;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO;
+
+/**
+ * REST operations for connector instance configuration versioning.
+ */
+@Path("connectorsHistory")
+public interface ConnectorHistoryService extends JAXRSService {
+
+ /**
+ * Returns a list of all connector configuration history instances for the given connector instance key.
+ *
+ * @param connectorKey connector instance key
+ * @return list of all connector configuration history instances for the given connector instance key
+ */
+ @GET
+ @Path("{connectorKey}")
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ List<ConnInstanceHistoryConfTO> list(@NotNull @PathParam("connectorKey") String connectorKey);
+
+ /**
+ * Restores the connector configuration history instance matching the provided key.
+ *
+ * @param key connector configuration history instance key to be restored
+ */
+ @POST
+ @Path("{key}")
+ void restore(@NotNull @PathParam("key") String key);
+
+ /**
+ * Deletes the connector configuration history instance matching the provided key.
+ *
+ * @param key connector configuration history instance key to be deleted
+ */
+ @DELETE
+ @Path("{key}")
+ void delete(@NotNull @PathParam("key") String key);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceHistoryService.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceHistoryService.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceHistoryService.java
new file mode 100644
index 0000000..fbf748a
--- /dev/null
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceHistoryService.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.common.rest.api.service;
+
+import java.util.List;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.syncope.common.lib.to.ResourceHistoryConfTO;
+
+/**
+ * REST operations for resource configuration versioning.
+ */
+@Path("resourcesHistory")
+public interface ResourceHistoryService extends JAXRSService {
+
+ /**
+ * Returns a list of all resource configuration history for the given resource key.
+ *
+ * @param resourceKey resource key
+ * @return list of all resource configuration history for the given resource key
+ */
+ @GET
+ @Path("{resourceKey}")
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ List<ResourceHistoryConfTO> list(@NotNull @PathParam("resourceKey") String resourceKey);
+
+ /**
+ * Restores the resource configuration history matching the provided key.
+ *
+ * @param key resource configuration history key to be restored
+ */
+ @POST
+ @Path("{key}")
+ void restore(@NotNull @PathParam("key") String key);
+
+ /**
+ * Deletes the resource configuration history matching the provided key.
+ *
+ * @param key resource configuration history key to be deleted
+ */
+ @DELETE
+ @Path("{key}")
+ void delete(@NotNull @PathParam("key") String key);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorHistoryLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorHistoryLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorHistoryLogic.java
new file mode 100644
index 0000000..2d0afa7
--- /dev/null
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorHistoryLogic.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.logic;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.syncope.core.persistence.api.dao.ConnInstanceDAO;
+import org.apache.syncope.core.persistence.api.dao.ConnInstanceHistoryConfDAO;
+import org.apache.syncope.core.persistence.api.dao.NotFoundException;
+import org.apache.syncope.core.persistence.api.entity.ConnInstance;
+import org.apache.syncope.core.persistence.api.entity.ConnInstanceHistoryConf;
+import org.apache.syncope.core.provisioning.api.data.ConnInstanceDataBinder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ConnectorHistoryLogic extends AbstractTransactionalLogic<ConnInstanceHistoryConfTO> {
+
+ @Autowired
+ private ConnInstanceHistoryConfDAO connInstanceHistoryConfDAO;
+
+ @Autowired
+ private ConnInstanceDAO connInstanceDAO;
+
+ @Autowired
+ private ConnInstanceDataBinder binder;
+
+ private ConnInstanceHistoryConfTO getConnInstanceHistoryConfTO(final ConnInstanceHistoryConf history) {
+ ConnInstanceHistoryConfTO historyTO = new ConnInstanceHistoryConfTO();
+ historyTO.setKey(history.getKey());
+ historyTO.setCreator(history.getCreator());
+ historyTO.setCreation(history.getCreation());
+ historyTO.setConnInstanceTO(history.getConf());
+
+ return historyTO;
+ }
+
+ @PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_HISTORY_LIST + "')")
+ public List<ConnInstanceHistoryConfTO> list(final String key) {
+ ConnInstance connInstance = connInstanceDAO.find(key);
+ if (connInstance == null) {
+ throw new NotFoundException("Connector '" + key + "'");
+ }
+
+ return CollectionUtils.collect(connInstanceHistoryConfDAO.findByEntity(connInstance),
+ new Transformer<ConnInstanceHistoryConf, ConnInstanceHistoryConfTO>() {
+
+ @Override
+ public ConnInstanceHistoryConfTO transform(final ConnInstanceHistoryConf input) {
+ return getConnInstanceHistoryConfTO(input);
+ }
+
+ }, new ArrayList<ConnInstanceHistoryConfTO>());
+ }
+
+ @PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_HISTORY_RESTORE + "')")
+ public void restore(final String key) {
+ ConnInstanceHistoryConf connInstanceHistoryConf = connInstanceHistoryConfDAO.find(key);
+ if (connInstanceHistoryConf == null) {
+ throw new NotFoundException("Connector History Conf '" + key + "'");
+ }
+
+ binder.update(connInstanceHistoryConf.getConf());
+ }
+
+ @PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_HISTORY_DELETE + "')")
+ public void delete(final String key) {
+ ConnInstanceHistoryConf connInstanceHistoryConf = connInstanceHistoryConfDAO.find(key);
+ if (connInstanceHistoryConf == null) {
+ throw new NotFoundException("Connector History Conf '" + key + "'");
+ }
+
+ connInstanceHistoryConfDAO.delete(key);
+ }
+
+ @Override
+ protected ConnInstanceHistoryConfTO resolveReference(final Method method, final Object... args)
+ throws UnresolvedReferenceException {
+
+ if (!"list".equals(method.getName())) {
+ try {
+ String key = (String) args[0];
+ return getConnInstanceHistoryConfTO(connInstanceHistoryConfDAO.find(key));
+ } catch (Throwable ignore) {
+ LOG.debug("Unresolved reference", ignore);
+ throw new UnresolvedReferenceException(ignore);
+ }
+ }
+
+ throw new UnresolvedReferenceException();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorLogic.java
index 65d02d3..e84dfe5 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ConnectorLogic.java
@@ -77,34 +77,12 @@ public class ConnectorLogic extends AbstractTransactionalLogic<ConnInstanceTO> {
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_CREATE + "')")
public ConnInstanceTO create(final ConnInstanceTO connInstanceTO) {
- ConnInstance connInstance = binder.getConnInstance(connInstanceTO);
- try {
- connInstance = connInstanceDAO.save(connInstance);
- } catch (SyncopeClientException e) {
- throw e;
- } catch (Exception e) {
- SyncopeClientException ex = SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
- ex.getElements().add(e.getMessage());
- throw ex;
- }
-
- return binder.getConnInstanceTO(connInstance);
+ return binder.getConnInstanceTO(connInstanceDAO.save(binder.getConnInstance(connInstanceTO)));
}
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_UPDATE + "')")
public ConnInstanceTO update(final ConnInstanceTO connInstanceTO) {
- ConnInstance connInstance = binder.update(connInstanceTO.getKey(), connInstanceTO);
- try {
- connInstance = connInstanceDAO.save(connInstance);
- } catch (SyncopeClientException e) {
- throw e;
- } catch (Exception e) {
- SyncopeClientException ex = SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
- ex.getElements().add(e.getMessage());
- throw ex;
- }
-
- return binder.getConnInstanceTO(connInstance);
+ return binder.getConnInstanceTO(binder.update(connInstanceTO));
}
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_DELETE + "')")
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceHistoryLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceHistoryLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceHistoryLogic.java
new file mode 100644
index 0000000..fc95f81
--- /dev/null
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceHistoryLogic.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.logic;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.syncope.common.lib.to.ResourceHistoryConfTO;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
+import org.apache.syncope.core.persistence.api.dao.ExternalResourceHistoryConfDAO;
+import org.apache.syncope.core.persistence.api.dao.NotFoundException;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResourceHistoryConf;
+import org.apache.syncope.core.provisioning.api.data.ResourceDataBinder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ResourceHistoryLogic extends AbstractTransactionalLogic<ResourceHistoryConfTO> {
+
+ @Autowired
+ private ExternalResourceHistoryConfDAO resourceHistoryConfDAO;
+
+ @Autowired
+ private ExternalResourceDAO resourceDAO;
+
+ @Autowired
+ private ResourceDataBinder binder;
+
+ private ResourceHistoryConfTO getResourceHistoryConfTO(final ExternalResourceHistoryConf history) {
+ ResourceHistoryConfTO historyTO = new ResourceHistoryConfTO();
+ historyTO.setKey(history.getKey());
+ historyTO.setCreator(history.getCreator());
+ historyTO.setCreation(history.getCreation());
+ historyTO.setResourceTO(history.getConf());
+
+ return historyTO;
+ }
+
+ @PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_HISTORY_LIST + "')")
+ public List<ResourceHistoryConfTO> list(final String key) {
+ ExternalResource resource = resourceDAO.find(key);
+ if (resource == null) {
+ throw new NotFoundException("Resource '" + key + "'");
+ }
+
+ return CollectionUtils.collect(resourceHistoryConfDAO.findByEntity(resource),
+ new Transformer<ExternalResourceHistoryConf, ResourceHistoryConfTO>() {
+
+ @Override
+ public ResourceHistoryConfTO transform(final ExternalResourceHistoryConf input) {
+ return getResourceHistoryConfTO(input);
+ }
+ }, new ArrayList<ResourceHistoryConfTO>());
+ }
+
+ @PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_HISTORY_RESTORE + "')")
+ public void restore(final String key) {
+ ExternalResourceHistoryConf resourceHistoryConf = resourceHistoryConfDAO.find(key);
+ if (resourceHistoryConf == null) {
+ throw new NotFoundException("Resource History Conf '" + key + "'");
+ }
+
+ binder.update(resourceHistoryConf.getEntity(), resourceHistoryConf.getConf());
+ }
+
+ @PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_HISTORY_DELETE + "')")
+ public void delete(final String key) {
+ ExternalResourceHistoryConf resourceHistoryConf = resourceHistoryConfDAO.find(key);
+ if (resourceHistoryConf == null) {
+ throw new NotFoundException("Resource History Conf '" + key + "'");
+ }
+
+ resourceHistoryConfDAO.delete(key);
+ }
+
+ @Override
+ protected ResourceHistoryConfTO resolveReference(final Method method, final Object... args)
+ throws UnresolvedReferenceException {
+
+ if (!"list".equals(method.getName())) {
+ try {
+ String key = (String) args[0];
+ return getResourceHistoryConfTO(resourceHistoryConfDAO.find(key));
+ } catch (Throwable ignore) {
+ LOG.debug("Unresolved reference", ignore);
+ throw new UnresolvedReferenceException(ignore);
+ }
+ }
+
+ throw new UnresolvedReferenceException();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
index b07a92b..5269c1e 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
@@ -125,18 +125,7 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
throw new DuplicateException(resourceTO.getKey());
}
- ExternalResource resource = null;
- try {
- resource = resourceDAO.save(binder.create(resourceTO));
- } catch (SyncopeClientException e) {
- throw e;
- } catch (Exception e) {
- SyncopeClientException ex = SyncopeClientException.build(ClientExceptionType.InvalidExternalResource);
- ex.getElements().add(e.getMessage());
- throw ex;
- }
-
- return binder.getResourceTO(resource);
+ return binder.getResourceTO(resourceDAO.save(binder.create(resourceTO)));
}
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_UPDATE + "')")
@@ -146,18 +135,7 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
throw new NotFoundException("Resource '" + resourceTO.getKey() + "'");
}
- resource = binder.update(resource, resourceTO);
- try {
- resource = resourceDAO.save(resource);
- } catch (SyncopeClientException e) {
- throw e;
- } catch (Exception e) {
- SyncopeClientException ex = SyncopeClientException.build(ClientExceptionType.InvalidExternalResource);
- ex.getElements().add(e.getMessage());
- throw ex;
- }
-
- return binder.getResourceTO(resource);
+ return binder.getResourceTO(resourceDAO.save(binder.update(resource, resourceTO)));
}
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_UPDATE + "')")
@@ -208,25 +186,25 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
}
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_DELETE + "')")
- public ResourceTO delete(final String resourceName) {
- ExternalResource resource = resourceDAO.find(resourceName);
+ public ResourceTO delete(final String key) {
+ ExternalResource resource = resourceDAO.find(key);
if (resource == null) {
- throw new NotFoundException("Resource '" + resourceName + "'");
+ throw new NotFoundException("Resource '" + key + "'");
}
ResourceTO resourceToDelete = binder.getResourceTO(resource);
- resourceDAO.delete(resourceName);
+ resourceDAO.delete(key);
return resourceToDelete;
}
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_READ + "')")
@Transactional(readOnly = true)
- public ResourceTO read(final String resourceName) {
- ExternalResource resource = resourceDAO.find(resourceName);
+ public ResourceTO read(final String key) {
+ ExternalResource resource = resourceDAO.find(key);
if (resource == null) {
- throw new NotFoundException("Resource '" + resourceName + "'");
+ throw new NotFoundException("Resource '" + key + "'");
}
return binder.getResourceTO(resource);
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java
index 2eb14c5..97da0f6 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java
@@ -95,7 +95,7 @@ public class SchemaLogic extends AbstractTransactionalLogic<AbstractSchemaTO> {
public <T extends AbstractSchemaTO> T create(final SchemaType schemaType, final T schemaTO) {
if (StringUtils.isBlank(schemaTO.getKey())) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
- sce.getElements().add("Schema name");
+ sce.getElements().add("Schema key");
throw sce;
}
@@ -124,23 +124,23 @@ public class SchemaLogic extends AbstractTransactionalLogic<AbstractSchemaTO> {
}
@PreAuthorize("hasRole('" + StandardEntitlement.SCHEMA_DELETE + "')")
- public void delete(final SchemaType schemaType, final String schemaName) {
- if (!doesSchemaExist(schemaType, schemaName)) {
- throw new NotFoundException(schemaType + "/" + schemaName);
+ public void delete(final SchemaType schemaType, final String schemaKey) {
+ if (!doesSchemaExist(schemaType, schemaKey)) {
+ throw new NotFoundException(schemaType + "/" + schemaKey);
}
switch (schemaType) {
case VIRTUAL:
- virSchemaDAO.delete(schemaName);
+ virSchemaDAO.delete(schemaKey);
break;
case DERIVED:
- derSchemaDAO.delete(schemaName);
+ derSchemaDAO.delete(schemaKey);
break;
case PLAIN:
default:
- plainSchemaDAO.delete(schemaName);
+ plainSchemaDAO.delete(schemaKey);
}
}
@@ -207,22 +207,22 @@ public class SchemaLogic extends AbstractTransactionalLogic<AbstractSchemaTO> {
@PreAuthorize("isAuthenticated()")
@SuppressWarnings("unchecked")
- public <T extends AbstractSchemaTO> T read(final SchemaType schemaType, final String schemaName) {
+ public <T extends AbstractSchemaTO> T read(final SchemaType schemaType, final String schemaKey) {
T read;
switch (schemaType) {
case VIRTUAL:
- VirSchema virSchema = virSchemaDAO.find(schemaName);
+ VirSchema virSchema = virSchemaDAO.find(schemaKey);
if (virSchema == null) {
- throw new NotFoundException("Virtual Schema '" + schemaName + "'");
+ throw new NotFoundException("Virtual Schema '" + schemaKey + "'");
}
read = (T) binder.getVirSchemaTO(virSchema);
break;
case DERIVED:
- DerSchema derSchema = derSchemaDAO.find(schemaName);
+ DerSchema derSchema = derSchemaDAO.find(schemaKey);
if (derSchema == null) {
- throw new NotFoundException("Derived schema '" + schemaName + "'");
+ throw new NotFoundException("Derived schema '" + schemaKey + "'");
}
read = (T) binder.getDerSchemaTO(derSchema);
@@ -230,9 +230,9 @@ public class SchemaLogic extends AbstractTransactionalLogic<AbstractSchemaTO> {
case PLAIN:
default:
- PlainSchema schema = plainSchemaDAO.find(schemaName);
+ PlainSchema schema = plainSchemaDAO.find(schemaKey);
if (schema == null) {
- throw new NotFoundException("Schema '" + schemaName + "'");
+ throw new NotFoundException("Schema '" + schemaKey + "'");
}
read = (T) binder.getPlainSchemaTO(schema);
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ConnInstanceHistoryConfDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ConnInstanceHistoryConfDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ConnInstanceHistoryConfDAO.java
new file mode 100644
index 0000000..1caad69
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ConnInstanceHistoryConfDAO.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.core.persistence.api.entity.ConnInstance;
+import org.apache.syncope.core.persistence.api.entity.ConnInstanceHistoryConf;
+
+public interface ConnInstanceHistoryConfDAO extends DAO<ConnInstanceHistoryConf> {
+
+ ConnInstanceHistoryConf find(String key);
+
+ List<ConnInstanceHistoryConf> findByEntity(ConnInstance entity);
+
+ ConnInstanceHistoryConf save(ConnInstanceHistoryConf conf);
+
+ void delete(String key);
+
+ void deleteByEntity(ConnInstance entity);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ExternalResourceHistoryConfDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ExternalResourceHistoryConfDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ExternalResourceHistoryConfDAO.java
new file mode 100644
index 0000000..1c4db5a
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/ExternalResourceHistoryConfDAO.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResourceHistoryConf;
+
+public interface ExternalResourceHistoryConfDAO extends DAO<ExternalResourceHistoryConf> {
+
+ ExternalResourceHistoryConf find(String key);
+
+ List<ExternalResourceHistoryConf> findByEntity(ExternalResource entity);
+
+ ExternalResourceHistoryConf save(ExternalResourceHistoryConf conf);
+
+ void delete(String key);
+
+ void deleteByEntity(ExternalResource entity);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstanceHistoryConf.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstanceHistoryConf.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstanceHistoryConf.java
new file mode 100644
index 0000000..88a4481
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstanceHistoryConf.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.entity;
+
+import org.apache.syncope.common.lib.to.ConnInstanceTO;
+
+public interface ConnInstanceHistoryConf extends HistoryConf<ConnInstance, ConnInstanceTO> {
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/HistoryConf.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/HistoryConf.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/HistoryConf.java
new file mode 100644
index 0000000..5da50c1
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/HistoryConf.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.entity;
+
+import java.util.Date;
+import org.apache.syncope.common.lib.to.EntityTO;
+
+public interface HistoryConf<E extends Entity, T extends EntityTO> extends Entity {
+
+ String getCreator();
+
+ void setCreator(String creator);
+
+ Date getCreation();
+
+ void setCreation(Date creation);
+
+ E getEntity();
+
+ void setEntity(E entity);
+
+ T getConf();
+
+ void setConf(T conf);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/resource/ExternalResourceHistoryConf.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/resource/ExternalResourceHistoryConf.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/resource/ExternalResourceHistoryConf.java
new file mode 100644
index 0000000..0fd8a25
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/resource/ExternalResourceHistoryConf.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.entity.resource;
+
+import org.apache.syncope.common.lib.to.ResourceTO;
+import org.apache.syncope.core.persistence.api.entity.HistoryConf;
+
+public interface ExternalResourceHistoryConf extends HistoryConf<ExternalResource, ResourceTO> {
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceDAO.java
index 91cf1dd..8972b8b 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceDAO.java
@@ -24,6 +24,7 @@ import javax.persistence.TypedQuery;
import org.apache.commons.collections4.Closure;
import org.apache.commons.collections4.IterableUtils;
import org.apache.syncope.core.persistence.api.dao.ConnInstanceDAO;
+import org.apache.syncope.core.persistence.api.dao.ConnInstanceHistoryConfDAO;
import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
import org.apache.syncope.core.persistence.api.dao.NotFoundException;
import org.apache.syncope.core.persistence.api.entity.ConnInstance;
@@ -37,6 +38,9 @@ import org.springframework.stereotype.Repository;
public class JPAConnInstanceDAO extends AbstractDAO<ConnInstance> implements ConnInstanceDAO {
@Autowired
+ private ConnInstanceHistoryConfDAO connInstanceHistoryConfDAO;
+
+ @Autowired
private ExternalResourceDAO resourceDAO;
@Autowired
@@ -85,8 +89,10 @@ public class JPAConnInstanceDAO extends AbstractDAO<ConnInstance> implements Con
});
+ connInstanceHistoryConfDAO.deleteByEntity(connInstance);
+
entityManager().remove(connInstance);
- connRegistry.unregisterConnector(key.toString());
+ connRegistry.unregisterConnector(key);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceHistoryConfDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceHistoryConfDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceHistoryConfDAO.java
new file mode 100644
index 0000000..001d7fb
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConnInstanceHistoryConfDAO.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.dao;
+
+import java.util.List;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import org.apache.syncope.core.persistence.api.dao.ConnInstanceHistoryConfDAO;
+import org.apache.syncope.core.persistence.api.entity.ConnInstance;
+import org.apache.syncope.core.persistence.api.entity.ConnInstanceHistoryConf;
+import org.apache.syncope.core.persistence.jpa.entity.JPAConnInstanceHistoryConf;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class JPAConnInstanceHistoryConfDAO
+ extends AbstractDAO<ConnInstanceHistoryConf> implements ConnInstanceHistoryConfDAO {
+
+ @Override
+ public ConnInstanceHistoryConf find(final String key) {
+ return entityManager().find(JPAConnInstanceHistoryConf.class, key);
+ }
+
+ @Override
+ public List<ConnInstanceHistoryConf> findByEntity(final ConnInstance entity) {
+ TypedQuery<ConnInstanceHistoryConf> query = entityManager().createQuery(
+ "SELECT e FROM " + JPAConnInstanceHistoryConf.class.getSimpleName()
+ + " e WHERE e.entity=:entity ORDER BY e.creation DESC", ConnInstanceHistoryConf.class);
+ query.setParameter("entity", entity);
+ return query.getResultList();
+ }
+
+ @Override
+ public ConnInstanceHistoryConf save(final ConnInstanceHistoryConf conf) {
+ return entityManager().merge(conf);
+ }
+
+ @Override
+ public void delete(final String key) {
+ ConnInstanceHistoryConf conf = find(key);
+ if (conf == null) {
+ return;
+ }
+
+ entityManager().remove(conf);
+ }
+
+ @Override
+ public void deleteByEntity(final ConnInstance entity) {
+ Query query = entityManager().createQuery(
+ "DELETE FROM " + JPAConnInstanceHistoryConf.class.getSimpleName() + " e WHERE e.entity=:entity");
+ query.setParameter("entity", entity);
+ query.executeUpdate();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
index 03a0fe5..c49bd5a 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
@@ -26,6 +26,7 @@ import javax.persistence.TypedQuery;
import org.apache.syncope.common.lib.types.TaskType;
import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
+import org.apache.syncope.core.persistence.api.dao.ExternalResourceHistoryConfDAO;
import org.apache.syncope.core.persistence.api.dao.NotFoundException;
import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
import org.apache.syncope.core.persistence.api.dao.GroupDAO;
@@ -76,6 +77,8 @@ public class JPAExternalResourceDAO extends AbstractDAO<ExternalResource> implem
private RealmDAO realmDAO;
+ private ExternalResourceHistoryConfDAO externalResourceHistoryConfDAO;
+
private TaskDAO taskDAO() {
synchronized (this) {
if (taskDAO == null) {
@@ -139,6 +142,16 @@ public class JPAExternalResourceDAO extends AbstractDAO<ExternalResource> implem
return realmDAO;
}
+ private ExternalResourceHistoryConfDAO externalResourceHistoryConfDAO() {
+ synchronized (this) {
+ if (externalResourceHistoryConfDAO == null) {
+ externalResourceHistoryConfDAO = ApplicationContextProvider.getApplicationContext().
+ getBean(ExternalResourceHistoryConfDAO.class);
+ }
+ }
+ return externalResourceHistoryConfDAO;
+ }
+
@Override
public int count() {
Query query = entityManager().createQuery(
@@ -286,6 +299,8 @@ public class JPAExternalResourceDAO extends AbstractDAO<ExternalResource> implem
}
}
+ externalResourceHistoryConfDAO().deleteByEntity(resource);
+
if (resource.getConnector() != null && resource.getConnector().getResources() != null
&& !resource.getConnector().getResources().isEmpty()) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceHistoryConfDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceHistoryConfDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceHistoryConfDAO.java
new file mode 100644
index 0000000..ba43355
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceHistoryConfDAO.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.dao;
+
+import java.util.List;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import org.apache.syncope.core.persistence.api.dao.ExternalResourceHistoryConfDAO;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResourceHistoryConf;
+import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResourceHistoryConf;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class JPAExternalResourceHistoryConfDAO
+ extends AbstractDAO<ExternalResourceHistoryConf> implements ExternalResourceHistoryConfDAO {
+
+ @Override
+ public ExternalResourceHistoryConf find(final String key) {
+ return entityManager().find(JPAExternalResourceHistoryConf.class, key);
+ }
+
+ @Override
+ public List<ExternalResourceHistoryConf> findByEntity(final ExternalResource entity) {
+ TypedQuery<ExternalResourceHistoryConf> query = entityManager().createQuery(
+ "SELECT e FROM " + JPAExternalResourceHistoryConf.class.getSimpleName()
+ + " e WHERE e.entity=:entity ORDER BY e.creation DESC", ExternalResourceHistoryConf.class);
+ query.setParameter("entity", entity);
+ return query.getResultList();
+ }
+
+ @Override
+ public ExternalResourceHistoryConf save(final ExternalResourceHistoryConf conf) {
+ return entityManager().merge(conf);
+ }
+
+ @Override
+ public void delete(final String key) {
+ ExternalResourceHistoryConf conf = find(key);
+ if (conf == null) {
+ return;
+ }
+
+ entityManager().remove(conf);
+ }
+
+ @Override
+ public void deleteByEntity(final ExternalResource entity) {
+ Query query = entityManager().createQuery(
+ "DELETE FROM " + JPAExternalResourceHistoryConf.class.getSimpleName() + " e WHERE e.entity=:entity");
+ query.setParameter("entity", entity);
+ query.executeUpdate();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractHistoryConf.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractHistoryConf.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractHistoryConf.java
new file mode 100644
index 0000000..9ee2c65
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractHistoryConf.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.entity;
+
+import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Lob;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.apache.syncope.common.lib.to.EntityTO;
+import org.apache.syncope.core.persistence.api.entity.Entity;
+import org.apache.syncope.core.persistence.api.entity.HistoryConf;
+import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
+
+@MappedSuperclass
+public abstract class AbstractHistoryConf<E extends Entity, T extends EntityTO>
+ extends AbstractGeneratedKeyEntity implements HistoryConf<E, T> {
+
+ private static final long serialVersionUID = -7210303753586235180L;
+
+ @Column(nullable = false)
+ private String creator;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date creation;
+
+ @Lob
+ protected String conf;
+
+ @Override
+ public String getCreator() {
+ return creator;
+ }
+
+ @Override
+ public void setCreator(final String creator) {
+ this.creator = creator;
+ }
+
+ @Override
+ public Date getCreation() {
+ return creation == null
+ ? null
+ : new Date(creation.getTime());
+ }
+
+ @Override
+ public void setCreation(final Date creation) {
+ this.creation = creation == null
+ ? null
+ : new Date(creation.getTime());
+ }
+
+ @Override
+ public void setConf(final T conf) {
+ this.conf = POJOHelper.serialize(conf);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstanceHistoryConf.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstanceHistoryConf.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstanceHistoryConf.java
new file mode 100644
index 0000000..9001676
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstanceHistoryConf.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.to.ConnInstanceTO;
+import org.apache.syncope.core.persistence.api.entity.ConnInstance;
+import org.apache.syncope.core.persistence.api.entity.ConnInstanceHistoryConf;
+import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
+
+@Entity
+@Table(name = JPAConnInstanceHistoryConf.TABLE)
+public class JPAConnInstanceHistoryConf
+ extends AbstractHistoryConf<ConnInstance, ConnInstanceTO> implements ConnInstanceHistoryConf {
+
+ private static final long serialVersionUID = -4152915369607435186L;
+
+ public static final String TABLE = "ConnInstanceHistoryConf";
+
+ @OneToOne
+ private JPAConnInstance entity;
+
+ @Override
+ public ConnInstance getEntity() {
+ return entity;
+ }
+
+ @Override
+ public void setEntity(final ConnInstance entity) {
+ checkType(entity, JPAConnInstance.class);
+ this.entity = (JPAConnInstance) entity;
+ }
+
+ @Override
+ public ConnInstanceTO getConf() {
+ return StringUtils.isBlank(conf)
+ ? null
+ : POJOHelper.deserialize(conf, ConnInstanceTO.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
index daea67a..88f4e5a 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
@@ -31,6 +31,7 @@ import org.apache.syncope.core.persistence.api.entity.AnyTemplateRealm;
import org.apache.syncope.core.persistence.api.entity.AnyType;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
import org.apache.syncope.core.persistence.api.entity.ConnInstance;
+import org.apache.syncope.core.persistence.api.entity.ConnInstanceHistoryConf;
import org.apache.syncope.core.persistence.api.entity.ConnPoolConf;
import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.Domain;
@@ -125,6 +126,8 @@ import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
import org.apache.syncope.core.persistence.api.entity.resource.OrgUnit;
import org.apache.syncope.core.persistence.jpa.entity.resource.JPAOrgUnit;
import org.apache.syncope.core.persistence.api.entity.DynRealm;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResourceHistoryConf;
+import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResourceHistoryConf;
@Component
public class JPAEntityFactory implements EntityFactory {
@@ -184,12 +187,16 @@ public class JPAEntityFactory implements EntityFactory {
result = (E) new JPANotification();
} else if (reference.equals(ExternalResource.class)) {
result = (E) new JPAExternalResource();
+ } else if (reference.equals(ExternalResourceHistoryConf.class)) {
+ result = (E) new JPAExternalResourceHistoryConf();
} else if (reference.equals(Provision.class)) {
result = (E) new JPAProvision();
} else if (reference.equals(OrgUnit.class)) {
result = (E) new JPAOrgUnit();
} else if (reference.equals(ConnInstance.class)) {
result = (E) new JPAConnInstance();
+ } else if (reference.equals(ConnInstanceHistoryConf.class)) {
+ result = (E) new JPAConnInstanceHistoryConf();
} else if (reference.equals(PlainSchema.class)) {
result = (E) new JPAPlainSchema();
} else if (reference.equals(APlainAttr.class)) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResourceHistoryConf.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResourceHistoryConf.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResourceHistoryConf.java
new file mode 100644
index 0000000..31fa726
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResourceHistoryConf.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.entity.resource;
+
+import javax.persistence.Entity;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.to.ResourceTO;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResourceHistoryConf;
+import org.apache.syncope.core.persistence.jpa.entity.AbstractHistoryConf;
+import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
+
+@Entity
+@Table(name = JPAExternalResourceHistoryConf.TABLE)
+public class JPAExternalResourceHistoryConf
+ extends AbstractHistoryConf<ExternalResource, ResourceTO> implements ExternalResourceHistoryConf {
+
+ public static final String TABLE = "ExternalResourceHistoryConf";
+
+ private static final long serialVersionUID = 4994551965604592529L;
+
+ @OneToOne
+ private JPAExternalResource entity;
+
+ @Override
+ public ExternalResource getEntity() {
+ return entity;
+ }
+
+ @Override
+ public void setEntity(final ExternalResource entity) {
+ checkType(entity, JPAExternalResource.class);
+ this.entity = (JPAExternalResource) entity;
+ }
+
+ @Override
+ public ResourceTO getConf() {
+ return StringUtils.isBlank(conf)
+ ? null
+ : POJOHelper.deserialize(conf, ResourceTO.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/main/resources/domains/MasterContent.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/domains/MasterContent.xml b/core/persistence-jpa/src/main/resources/domains/MasterContent.xml
index 33d8a70..9d42535 100644
--- a/core/persistence-jpa/src/main/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/main/resources/domains/MasterContent.xml
@@ -152,6 +152,23 @@ under the License.
<CPlainAttrValue id="447e2456-3ff5-41bc-8ff1-cbb0567546cb"
attribute_id="cfec3140-562d-459c-ac6a-e3e10758661d" longValue="120"/>
+ <!-- Connector and Resource configuration history -->
+ <SyncopeSchema id="connector.conf.history.size"/>
+ <PlainSchema id="connector.conf.history.size" type="Long"
+ mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+ <CPlainAttr id="ae36c6ab-0f39-40d7-b6e6-3b8394547c9c"
+ owner_id="cd64d66f-6fff-4008-b966-a06b1cc1436d" schema_id="connector.conf.history.size"/>
+ <CPlainAttrValue id="4989ce5d-7b42-4a5c-b725-54286888df10"
+ attribute_id="ae36c6ab-0f39-40d7-b6e6-3b8394547c9c" longValue="10"/>
+
+ <SyncopeSchema id="resource.conf.history.size"/>
+ <PlainSchema id="resource.conf.history.size" type="Long"
+ mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+ <CPlainAttr id="ae7ae53a-74cf-48b0-9a57-6d2c94928e60"
+ owner_id="cd64d66f-6fff-4008-b966-a06b1cc1436d" schema_id="resource.conf.history.size"/>
+ <CPlainAttrValue id="059ac3e1-687f-4dd9-a28b-a23f8b436f31"
+ attribute_id="ae7ae53a-74cf-48b0-9a57-6d2c94928e60" longValue="10"/>
+
<AnyType id="USER" kind="USER"/>
<AnyTypeClass id="BaseUser"/>
<AnyType_AnyTypeClass anyType_id="USER" anyTypeClass_id="BaseUser"/>
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java
index f1d0f95..ffe1edc 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java
@@ -47,7 +47,7 @@ public class PlainSchemaTest extends AbstractTest {
@Test
public void findAll() {
List<PlainSchema> schemas = plainSchemaDAO.findAll();
- assertEquals(41, schemas.size());
+ assertEquals(43, schemas.size());
}
@Test
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ConnInstanceHistoryConfTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ConnInstanceHistoryConfTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ConnInstanceHistoryConfTest.java
new file mode 100644
index 0000000..43c0b65
--- /dev/null
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ConnInstanceHistoryConfTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.outer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+import java.util.List;
+import org.apache.syncope.common.lib.to.ConnInstanceTO;
+import org.apache.syncope.core.persistence.api.dao.ConnInstanceDAO;
+import org.apache.syncope.core.persistence.api.dao.ConnInstanceHistoryConfDAO;
+import org.apache.syncope.core.persistence.api.entity.ConnInstance;
+import org.apache.syncope.core.persistence.api.entity.ConnInstanceHistoryConf;
+import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional("Master")
+public class ConnInstanceHistoryConfTest extends AbstractTest {
+
+ @Autowired
+ private ConnInstanceDAO connInstanceDAO;
+
+ @Autowired
+ private ConnInstanceHistoryConfDAO connInstanceHistoryConfDAO;
+
+ @Test
+ public void createDelete() {
+ ConnInstance ldapConnector = connInstanceDAO.find("74141a3b-0762-4720-a4aa-fc3e374ef3ef");
+ assertNotNull(ldapConnector);
+
+ ConnInstanceHistoryConf ldapHistory = entityFactory.newEntity(ConnInstanceHistoryConf.class);
+ ldapHistory.setCreation(new Date());
+ ldapHistory.setCreator("me");
+ ldapHistory.setEntity(ldapConnector);
+ ldapHistory.setConf(new ConnInstanceTO());
+
+ ldapHistory = connInstanceHistoryConfDAO.save(ldapHistory);
+ assertNotNull(ldapHistory.getKey());
+
+ connInstanceHistoryConfDAO.flush();
+
+ List<ConnInstanceHistoryConf> history = connInstanceHistoryConfDAO.findByEntity(ldapConnector);
+ assertEquals(1, history.size());
+ assertEquals(ldapHistory, history.get(0));
+
+ connInstanceHistoryConfDAO.delete(ldapHistory.getKey());
+
+ connInstanceHistoryConfDAO.flush();
+
+ assertNull(connInstanceHistoryConfDAO.find(ldapHistory.getKey()));
+ assertTrue(connInstanceHistoryConfDAO.findByEntity(ldapConnector).isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceHistoryConfTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceHistoryConfTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceHistoryConfTest.java
new file mode 100644
index 0000000..2bc36a6
--- /dev/null
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceHistoryConfTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.outer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+import java.util.List;
+import org.apache.syncope.common.lib.to.ResourceTO;
+import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
+import org.apache.syncope.core.persistence.api.dao.ExternalResourceHistoryConfDAO;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResourceHistoryConf;
+import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional("Master")
+public class ResourceHistoryConfTest extends AbstractTest {
+
+ @Autowired
+ private ExternalResourceDAO resourceDAO;
+
+ @Autowired
+ private ExternalResourceHistoryConfDAO resourceHistoryConfDAO;
+
+ @Test
+ public void createDelete() {
+ ExternalResource ldapResource = resourceDAO.find("resource-ldap");
+ assertNotNull(ldapResource);
+
+ ExternalResourceHistoryConf ldapHistory = entityFactory.newEntity(ExternalResourceHistoryConf.class);
+ ldapHistory.setCreation(new Date());
+ ldapHistory.setCreator("me");
+ ldapHistory.setEntity(ldapResource);
+ ldapHistory.setConf(new ResourceTO());
+
+ ldapHistory = resourceHistoryConfDAO.save(ldapHistory);
+ assertNotNull(ldapHistory.getKey());
+
+ resourceHistoryConfDAO.flush();
+
+ List<ExternalResourceHistoryConf> history = resourceHistoryConfDAO.findByEntity(ldapResource);
+ assertEquals(1, history.size());
+ assertEquals(ldapHistory, history.get(0));
+
+ resourceHistoryConfDAO.delete(ldapHistory.getKey());
+
+ resourceHistoryConfDAO.flush();
+
+ assertNull(resourceHistoryConfDAO.find(ldapHistory.getKey()));
+ assertTrue(resourceHistoryConfDAO.findByEntity(ldapResource).isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
index 5e9c46e..83bacf0 100644
--- a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
@@ -151,7 +151,24 @@ under the License.
owner_id="cd64d66f-6fff-4008-b966-a06b1cc1436d" schema_id="jwt.lifetime.minutes"/>
<CPlainAttrValue id="447e2456-3ff5-41bc-8ff1-cbb0567546cb"
attribute_id="cfec3140-562d-459c-ac6a-e3e10758661d" longValue="120"/>
-
+
+ <!-- Connector and Resource configuration history -->
+ <SyncopeSchema id="connector.conf.history.size"/>
+ <PlainSchema id="connector.conf.history.size" type="Long"
+ mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+ <CPlainAttr id="ae36c6ab-0f39-40d7-b6e6-3b8394547c9c"
+ owner_id="cd64d66f-6fff-4008-b966-a06b1cc1436d" schema_id="connector.conf.history.size"/>
+ <CPlainAttrValue id="4989ce5d-7b42-4a5c-b725-54286888df10"
+ attribute_id="ae36c6ab-0f39-40d7-b6e6-3b8394547c9c" longValue="10"/>
+
+ <SyncopeSchema id="resource.conf.history.size"/>
+ <PlainSchema id="resource.conf.history.size" type="Long"
+ mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+ <CPlainAttr id="ae7ae53a-74cf-48b0-9a57-6d2c94928e60"
+ owner_id="cd64d66f-6fff-4008-b966-a06b1cc1436d" schema_id="resource.conf.history.size"/>
+ <CPlainAttrValue id="059ac3e1-687f-4dd9-a28b-a23f8b436f31"
+ attribute_id="ae7ae53a-74cf-48b0-9a57-6d2c94928e60" longValue="10"/>
+
<!-- sample policies -->
<PullPolicy id="66691e96-285f-4464-bc19-e68384ea4c85" description="a pull policy"
specification='{"conflictResolutionAction":"IGNORE"}'/>
http://git-wip-us.apache.org/repos/asf/syncope/blob/7451efb6/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/ConnInstanceDataBinder.java
----------------------------------------------------------------------
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/ConnInstanceDataBinder.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/ConnInstanceDataBinder.java
index 698fd25..ae7074f 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/ConnInstanceDataBinder.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/ConnInstanceDataBinder.java
@@ -31,6 +31,6 @@ public interface ConnInstanceDataBinder {
ConnInstanceTO getConnInstanceTO(ConnInstance connInstance);
- ConnInstance update(String key, ConnInstanceTO connInstanceTO);
+ ConnInstance update(ConnInstanceTO connInstanceTO);
}