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 2013/12/16 12:04:57 UTC
svn commit: r1551172 [5/7] - in /syncope/trunk: ./ client/
client/src/main/java/org/apache/syncope/client/
client/src/main/java/org/apache/syncope/client/rest/ common/
common/src/main/java/org/apache/syncope/common/
common/src/main/java/org/apache/sync...
Copied: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/AttributableCond.java (from r1548091, syncope/trunk/common/src/main/java/org/apache/syncope/common/search/AttributableCond.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/AttributableCond.java?p2=syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/AttributableCond.java&p1=syncope/trunk/common/src/main/java/org/apache/syncope/common/search/AttributableCond.java&r1=1548091&r2=1551172&rev=1551172&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/search/AttributableCond.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/AttributableCond.java Mon Dec 16 11:04:52 2013
@@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.common.search;
+package org.apache.syncope.core.persistence.dao.search;
/**
* Search condition to be applied when comparing bean field values.
*/
-public class AttributableCond extends AttributeCond implements SearchCond {
+public class AttributableCond extends AttributeCond {
private static final long serialVersionUID = -1880319220462653955L;
Copied: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/AttributeCond.java (from r1548091, syncope/trunk/common/src/main/java/org/apache/syncope/common/search/AttributeCond.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/AttributeCond.java?p2=syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/AttributeCond.java&p1=syncope/trunk/common/src/main/java/org/apache/syncope/common/search/AttributeCond.java&r1=1548091&r2=1551172&rev=1551172&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/search/AttributeCond.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/AttributeCond.java Mon Dec 16 11:04:52 2013
@@ -16,25 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.common.search;
-
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.syncope.common.AbstractBaseBean;
+package org.apache.syncope.core.persistence.dao.search;
/**
* Search condition to be applied when comparing attribute values.
*/
-@XmlRootElement(name = "attributeCondition")
-@XmlType
-public class AttributeCond extends AbstractBaseBean implements SearchCond {
+public class AttributeCond extends AbstractSearchCond {
private static final long serialVersionUID = 3275277728404021417L;
- @XmlEnum
- @XmlType(name = "attributeConditionType")
public enum Type {
LIKE,
Copied: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/EntitlementCond.java (from r1548091, syncope/trunk/common/src/main/java/org/apache/syncope/common/search/EntitlementCond.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/EntitlementCond.java?p2=syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/EntitlementCond.java&p1=syncope/trunk/common/src/main/java/org/apache/syncope/common/search/EntitlementCond.java&r1=1548091&r2=1551172&rev=1551172&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/search/EntitlementCond.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/EntitlementCond.java Mon Dec 16 11:04:52 2013
@@ -16,16 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.common.search;
+package org.apache.syncope.core.persistence.dao.search;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.syncope.common.AbstractBaseBean;
-
-@XmlRootElement(name = "entitlementCondition")
-@XmlType
-public class EntitlementCond extends AbstractBaseBean implements SearchCond {
+public class EntitlementCond extends AbstractSearchCond {
private static final long serialVersionUID = -4077781080368377428L;
Copied: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/MembershipCond.java (from r1548091, syncope/trunk/common/src/main/java/org/apache/syncope/common/search/MembershipCond.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/MembershipCond.java?p2=syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/MembershipCond.java&p1=syncope/trunk/common/src/main/java/org/apache/syncope/common/search/MembershipCond.java&r1=1548091&r2=1551172&rev=1551172&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/search/MembershipCond.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/MembershipCond.java Mon Dec 16 11:04:52 2013
@@ -16,26 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.common.search;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.syncope.common.AbstractBaseBean;
+package org.apache.syncope.core.persistence.dao.search;
/**
* Search condition to be applied when searching for memberships.
*/
-@XmlRootElement(name = "membershipCondition")
-@XmlType
-public class MembershipCond extends AbstractBaseBean implements SearchCond {
+public class MembershipCond extends AbstractSearchCond {
private static final long serialVersionUID = -728155256293925989L;
private Long roleId;
- private String roleName;
-
public MembershipCond() {
super();
}
@@ -44,20 +35,12 @@ public class MembershipCond extends Abst
return roleId;
}
- public void setRoleId(Long roleId) {
+ public void setRoleId(final Long roleId) {
this.roleId = roleId;
}
- public String getRoleName() {
- return roleName;
- }
-
- public void setRoleName(String roleName) {
- this.roleName = roleName;
- }
-
@Override
public final boolean isValid() {
- return !(roleId == null && roleName == null);
+ return roleId != null;
}
}
Copied: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/ResourceCond.java (from r1548091, syncope/trunk/common/src/main/java/org/apache/syncope/common/search/ResourceCond.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/ResourceCond.java?p2=syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/ResourceCond.java&p1=syncope/trunk/common/src/main/java/org/apache/syncope/common/search/ResourceCond.java&r1=1548091&r2=1551172&rev=1551172&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/search/ResourceCond.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/ResourceCond.java Mon Dec 16 11:04:52 2013
@@ -16,19 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.common.search;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.syncope.common.AbstractBaseBean;
+package org.apache.syncope.core.persistence.dao.search;
/**
* Search condition to be applied when searching for associated resources.
*/
-@XmlRootElement(name = "resourceCondition")
-@XmlType
-public class ResourceCond extends AbstractBaseBean implements SearchCond {
+public class ResourceCond extends AbstractSearchCond {
private static final long serialVersionUID = 466054166309460002L;
@@ -38,7 +31,7 @@ public class ResourceCond extends Abstra
return resourceName;
}
- public void setResourceName(String resourceName) {
+ public void setResourceName(final String resourceName) {
this.resourceName = resourceName;
}
Copied: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/SearchCond.java (from r1548091, syncope/trunk/common/src/main/java/org/apache/syncope/common/search/NodeCond.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/SearchCond.java?p2=syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/SearchCond.java&p1=syncope/trunk/common/src/main/java/org/apache/syncope/common/search/NodeCond.java&r1=1548091&r2=1551172&rev=1551172&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/search/NodeCond.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/SearchCond.java Mon Dec 16 11:04:52 2013
@@ -16,23 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.common.search;
+package org.apache.syncope.core.persistence.dao.search;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.syncope.common.AbstractBaseBean;
-
-@XmlRootElement(name = "nodeCondition")
-@XmlType
-public class NodeCond extends AbstractBaseBean {
+import java.util.List;
+
+public class SearchCond extends AbstractSearchCond {
private static final long serialVersionUID = 661560782247499526L;
- @XmlEnum
- @XmlType(name = "nodeConditionType")
public enum Type {
LEAF,
@@ -54,30 +45,25 @@ public class NodeCond extends AbstractBa
private EntitlementCond entitlementCond;
- private NodeCond leftNodeCond;
-
- private NodeCond rightNodeCond;
+ private SearchCond leftNodeCond;
- public static NodeCond getLeafCond(final AttributableCond syncopeUserCond) {
- NodeCond nodeCond = new NodeCond();
-
- nodeCond.type = Type.LEAF;
- nodeCond.attributableCond = syncopeUserCond;
-
- return nodeCond;
- }
+ private SearchCond rightNodeCond;
- public static NodeCond getLeafCond(final AttributeCond attributeCond) {
- NodeCond nodeCond = new NodeCond();
+ public static SearchCond getLeafCond(final AttributeCond attributeCond) {
+ SearchCond nodeCond = new SearchCond();
nodeCond.type = Type.LEAF;
- nodeCond.attributeCond = attributeCond;
+ if (attributeCond instanceof AttributableCond) {
+ nodeCond.attributableCond = (AttributableCond) attributeCond;
+ } else {
+ nodeCond.attributeCond = attributeCond;
+ }
return nodeCond;
}
- public static NodeCond getLeafCond(final MembershipCond membershipCond) {
- NodeCond nodeCond = new NodeCond();
+ public static SearchCond getLeafCond(final MembershipCond membershipCond) {
+ SearchCond nodeCond = new SearchCond();
nodeCond.type = Type.LEAF;
nodeCond.membershipCond = membershipCond;
@@ -85,8 +71,8 @@ public class NodeCond extends AbstractBa
return nodeCond;
}
- public static NodeCond getLeafCond(final ResourceCond resourceCond) {
- NodeCond nodeCond = new NodeCond();
+ public static SearchCond getLeafCond(final ResourceCond resourceCond) {
+ SearchCond nodeCond = new SearchCond();
nodeCond.type = Type.LEAF;
nodeCond.resourceCond = resourceCond;
@@ -94,8 +80,8 @@ public class NodeCond extends AbstractBa
return nodeCond;
}
- public static NodeCond getLeafCond(final EntitlementCond entitlementCond) {
- NodeCond nodeCond = new NodeCond();
+ public static SearchCond getLeafCond(final EntitlementCond entitlementCond) {
+ SearchCond nodeCond = new SearchCond();
nodeCond.type = Type.LEAF;
nodeCond.entitlementCond = entitlementCond;
@@ -103,38 +89,37 @@ public class NodeCond extends AbstractBa
return nodeCond;
}
- public static NodeCond getNotLeafCond(final AttributableCond syncopeUserCond) {
- NodeCond nodeCond = getLeafCond(syncopeUserCond);
+ public static SearchCond getNotLeafCond(final AttributeCond attributeCond) {
+ SearchCond nodeCond = getLeafCond(attributeCond);
nodeCond.type = Type.NOT_LEAF;
return nodeCond;
}
- public static NodeCond getNotLeafCond(final AttributeCond attributeCond) {
- NodeCond nodeCond = getLeafCond(attributeCond);
+ public static SearchCond getNotLeafCond(final MembershipCond membershipCond) {
+ SearchCond nodeCond = getLeafCond(membershipCond);
nodeCond.type = Type.NOT_LEAF;
return nodeCond;
}
- public static NodeCond getNotLeafCond(final MembershipCond membershipCond) {
- NodeCond nodeCond = getLeafCond(membershipCond);
+ public static SearchCond getNotLeafCond(final ResourceCond resourceCond) {
+ SearchCond nodeCond = getLeafCond(resourceCond);
nodeCond.type = Type.NOT_LEAF;
return nodeCond;
}
- public static NodeCond getNotLeafCond(final ResourceCond resourceCond) {
- NodeCond nodeCond = getLeafCond(resourceCond);
+ public static SearchCond getNotLeafCond(final EntitlementCond entitlementCond) {
+ SearchCond nodeCond = getLeafCond(entitlementCond);
nodeCond.type = Type.NOT_LEAF;
return nodeCond;
}
- public static NodeCond getNotLeafCond(final EntitlementCond entitlementCond) {
- NodeCond nodeCond = getLeafCond(entitlementCond);
+ public static SearchCond getNotLeafCond(final SearchCond nodeCond) {
nodeCond.type = Type.NOT_LEAF;
return nodeCond;
}
- public static NodeCond getAndCond(final NodeCond leftCond, final NodeCond rightCond) {
- NodeCond nodeCond = new NodeCond();
+ public static SearchCond getAndCond(final SearchCond leftCond, final SearchCond rightCond) {
+ SearchCond nodeCond = new SearchCond();
nodeCond.type = Type.AND;
nodeCond.leftNodeCond = leftCond;
@@ -143,8 +128,17 @@ public class NodeCond extends AbstractBa
return nodeCond;
}
- public static NodeCond getOrCond(final NodeCond leftCond, final NodeCond rightCond) {
- NodeCond nodeCond = new NodeCond();
+ public static SearchCond getAndCond(final List<SearchCond> conditions) {
+ if (conditions.size() > 2) {
+ SearchCond removed = conditions.remove(0);
+ return getAndCond(removed, getAndCond(conditions));
+ } else {
+ return getAndCond(conditions.get(0), conditions.get(1));
+ }
+ }
+
+ public static SearchCond getOrCond(final SearchCond leftCond, final SearchCond rightCond) {
+ SearchCond nodeCond = new SearchCond();
nodeCond.type = Type.OR;
nodeCond.leftNodeCond = leftCond;
@@ -153,6 +147,15 @@ public class NodeCond extends AbstractBa
return nodeCond;
}
+ public static SearchCond getOrCond(final List<SearchCond> conditions) {
+ if (conditions.size() > 2) {
+ SearchCond removed = conditions.remove(0);
+ return getOrCond(removed, getOrCond(conditions));
+ } else {
+ return getOrCond(conditions.get(0), conditions.get(1));
+ }
+ }
+
public AttributableCond getAttributableCond() {
return attributableCond;
}
@@ -193,19 +196,19 @@ public class NodeCond extends AbstractBa
this.entitlementCond = entitlementCond;
}
- public NodeCond getLeftNodeCond() {
+ public SearchCond getLeftNodeCond() {
return leftNodeCond;
}
- public void setLeftNodeCond(final NodeCond leftNodeCond) {
+ public void setLeftNodeCond(final SearchCond leftNodeCond) {
this.leftNodeCond = leftNodeCond;
}
- public NodeCond getRightNodeCond() {
+ public SearchCond getRightNodeCond() {
return rightNodeCond;
}
- public void setRightNodeCond(final NodeCond rightNodeCond) {
+ public void setRightNodeCond(final SearchCond rightNodeCond) {
this.rightNodeCond = rightNodeCond;
}
@@ -217,7 +220,6 @@ public class NodeCond extends AbstractBa
this.type = type;
}
- @JsonIgnore
public boolean isValid() {
boolean isValid = false;
Copied: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/package-info.java (from r1548091, syncope/trunk/common/src/main/java/org/apache/syncope/common/search/package-info.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/package-info.java?p2=syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/package-info.java&p1=syncope/trunk/common/src/main/java/org/apache/syncope/common/search/package-info.java&r1=1548091&r2=1551172&rev=1551172&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/search/package-info.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/search/package-info.java Mon Dec 16 11:04:52 2013
@@ -16,8 +16,4 @@
* specific language governing permissions and limitations
* under the License.
*/
-@XmlSchema(namespace = SyncopeConstants.NAMESPACE)
-package org.apache.syncope.common.search;
-
-import javax.xml.bind.annotation.XmlSchema;
-import org.apache.syncope.common.SyncopeConstants;
+package org.apache.syncope.core.persistence.dao.search;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java Mon Dec 16 11:04:52 2013
@@ -38,22 +38,6 @@ public class NotificationValidator exten
getTemplate(EntityViolationType.InvalidNotification, "No events")).
addNode("events").addConstraintViolation();
}
- if (value.getAbout() != null && !value.getAbout().isValid()) {
- isValid = false;
-
- context.buildConstraintViolationWithTemplate(
- getTemplate(EntityViolationType.InvalidNotification, "Invalid about search condition")).
- addNode("about").addConstraintViolation();
- }
- if (value.getRecipients() != null) {
- if (!value.getRecipients().isValid() && !value.isSelfAsRecipient()) {
- isValid = false;
-
- context.buildConstraintViolationWithTemplate(
- getTemplate(EntityViolationType.InvalidNotification, "Invalid recipients search condition")).
- addNode("recipients").addConstraintViolation();
- }
- }
return isValid;
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/PropagationReporter.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/PropagationReporter.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/PropagationReporter.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/PropagationReporter.java Mon Dec 16 11:04:52 2013
@@ -19,7 +19,7 @@
package org.apache.syncope.core.propagation;
import java.util.List;
-import org.apache.syncope.common.to.PropagationStatusTO;
+import org.apache.syncope.common.to.PropagationStatus;
import org.apache.syncope.common.types.PropagationTaskExecStatus;
import org.apache.syncope.core.persistence.beans.PropagationTask;
import org.identityconnectors.framework.common.objects.ConnectorObject;
@@ -54,5 +54,5 @@ public interface PropagationReporter {
*
* @return the list of propagation statuses
*/
- List<PropagationStatusTO> getStatuses();
+ List<PropagationStatus> getStatuses();
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationReporter.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationReporter.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationReporter.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationReporter.java Mon Dec 16 11:04:52 2013
@@ -20,7 +20,7 @@ package org.apache.syncope.core.propagat
import java.util.ArrayList;
import java.util.List;
-import org.apache.syncope.common.to.PropagationStatusTO;
+import org.apache.syncope.common.to.PropagationStatus;
import org.apache.syncope.common.types.PropagationTaskExecStatus;
import org.apache.syncope.core.connid.ConnObjectUtil;
import org.apache.syncope.core.persistence.beans.PropagationTask;
@@ -37,14 +37,14 @@ public class DefaultPropagationReporter
@Autowired
protected ConnObjectUtil connObjectUtil;
- protected final List<PropagationStatusTO> statuses = new ArrayList<PropagationStatusTO>();
+ protected final List<PropagationStatus> statuses = new ArrayList<PropagationStatus>();
@Override
public void onSuccessOrSecondaryResourceFailures(final String resource,
final PropagationTaskExecStatus executionStatus,
final String failureReason, final ConnectorObject beforeObj, final ConnectorObject afterObj) {
- final PropagationStatusTO propagation = new PropagationStatusTO();
+ final PropagationStatus propagation = new PropagationStatus();
propagation.setResource(resource);
propagation.setStatus(executionStatus);
propagation.setFailureReason(failureReason);
@@ -61,7 +61,7 @@ public class DefaultPropagationReporter
}
private boolean containsPropagationStatusTO(final String resourceName) {
- for (PropagationStatusTO status : statuses) {
+ for (PropagationStatus status : statuses) {
if (resourceName.equals(status.getResource())) {
return true;
}
@@ -77,7 +77,7 @@ public class DefaultPropagationReporter
for (PropagationTask propagationTask : tasks) {
if (!containsPropagationStatusTO(propagationTask.getResource().getName())) {
- final PropagationStatusTO propagationStatusTO = new PropagationStatusTO();
+ final PropagationStatus propagationStatusTO = new PropagationStatus();
propagationStatusTO.setResource(propagationTask.getResource().getName());
propagationStatusTO.setStatus(PropagationTaskExecStatus.FAILURE);
propagationStatusTO.setFailureReason(
@@ -88,7 +88,7 @@ public class DefaultPropagationReporter
}
@Override
- public List<PropagationStatusTO> getStatuses() {
+ public List<PropagationStatus> getStatuses() {
return statuses;
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java Mon Dec 16 11:04:52 2013
@@ -34,6 +34,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.dao.EntitlementDAO;
import org.apache.syncope.core.persistence.dao.RoleDAO;
import org.apache.syncope.core.rest.data.RoleDataBinder;
+import org.apache.syncope.core.rest.data.SearchCondConverter;
import org.apache.syncope.core.util.AttributableUtil;
import org.apache.syncope.core.util.EntitlementUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,8 +65,8 @@ public class RoleReportlet extends Abstr
if (conf.getMatchingCond() == null) {
result = roleDAO.findAll();
} else {
- result = searchDAO.search(adminRoleIds, conf.getMatchingCond(), page, PAGE_SIZE,
- AttributableUtil.getInstance(AttributableType.ROLE));
+ result = searchDAO.search(adminRoleIds, SearchCondConverter.convert(conf.getMatchingCond()),
+ page, PAGE_SIZE, AttributableUtil.getInstance(AttributableType.ROLE));
}
return result;
@@ -76,8 +77,8 @@ public class RoleReportlet extends Abstr
return conf.getMatchingCond() == null
? roleDAO.findAll().size()
- : searchDAO.count(adminRoleIds, conf.getMatchingCond(),
- AttributableUtil.getInstance(AttributableType.ROLE));
+ : searchDAO.count(adminRoleIds, SearchCondConverter.convert(conf.getMatchingCond()),
+ AttributableUtil.getInstance(AttributableType.ROLE));
}
private void doExtractResources(final ContentHandler handler, final AbstractAttributableTO attributableTO)
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java Mon Dec 16 11:04:52 2013
@@ -37,6 +37,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.dao.UserDAO;
import org.apache.syncope.core.rest.data.RoleDataBinder;
import org.apache.syncope.core.rest.data.UserDataBinder;
+import org.apache.syncope.core.rest.data.SearchCondConverter;
import org.apache.syncope.core.util.AttributableUtil;
import org.apache.syncope.core.util.DataFormat;
import org.apache.syncope.core.util.EntitlementUtil;
@@ -72,8 +73,8 @@ public class UserReportlet extends Abstr
if (conf.getMatchingCond() == null) {
result = userDAO.findAll(adminRoleIds, page, PAGE_SIZE);
} else {
- result = searchDAO.search(adminRoleIds, conf.getMatchingCond(), page, PAGE_SIZE,
- AttributableUtil.getInstance(AttributableType.USER));
+ result = searchDAO.search(adminRoleIds, SearchCondConverter.convert(conf.getMatchingCond()),
+ page, PAGE_SIZE, AttributableUtil.getInstance(AttributableType.USER));
}
return result;
@@ -84,7 +85,7 @@ public class UserReportlet extends Abstr
return conf.getMatchingCond() == null
? userDAO.count(adminRoleIds)
- : searchDAO.count(adminRoleIds, conf.getMatchingCond(),
+ : searchDAO.count(adminRoleIds, SearchCondConverter.convert(conf.getMatchingCond()),
AttributableUtil.getInstance(AttributableType.USER));
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java Mon Dec 16 11:04:52 2013
@@ -26,14 +26,14 @@ import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.to.BulkAction;
-import org.apache.syncope.common.to.BulkActionRes;
+import org.apache.syncope.common.reqres.BulkAction;
+import org.apache.syncope.common.reqres.BulkActionResult;
import org.apache.syncope.common.to.ConnBundleTO;
import org.apache.syncope.common.to.ConnInstanceTO;
import org.apache.syncope.common.types.ConnConfPropSchema;
import org.apache.syncope.common.types.ConnConfProperty;
import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.ConnInstance;
import org.apache.syncope.core.persistence.beans.ExternalResource;
import org.apache.syncope.core.persistence.dao.ConnInstanceDAO;
@@ -302,16 +302,16 @@ public class ConnectorController extends
}
@PreAuthorize("hasRole('CONNECTOR_DELETE') and #bulkAction.operation == #bulkAction.operation.DELETE")
- public BulkActionRes bulk(final BulkAction bulkAction) {
- BulkActionRes res = new BulkActionRes();
+ public BulkActionResult bulk(final BulkAction bulkAction) {
+ BulkActionResult res = new BulkActionResult();
if (bulkAction.getOperation() == BulkAction.Type.DELETE) {
for (String id : bulkAction.getTargets()) {
try {
- res.add(delete(Long.valueOf(id)).getId(), BulkActionRes.Status.SUCCESS);
+ res.add(delete(Long.valueOf(id)).getId(), BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.error("Error performing delete for connector {}", id, e);
- res.add(id, BulkActionRes.Status.FAILURE);
+ res.add(id, BulkActionResult.Status.FAILURE);
}
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/EntitlementController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/EntitlementController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/EntitlementController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/EntitlementController.java Mon Dec 16 11:04:52 2013
@@ -22,7 +22,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import org.apache.syncope.common.to.EntitlementTO;
+import org.apache.syncope.common.wrap.EntitlementTO;
import org.apache.syncope.core.persistence.beans.Entitlement;
import org.apache.syncope.core.persistence.dao.EntitlementDAO;
import org.apache.syncope.core.util.EntitlementUtil;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/LoggerController.java Mon Dec 16 11:04:52 2013
@@ -40,7 +40,7 @@ import org.apache.syncope.common.types.L
import org.apache.syncope.common.types.LoggerType;
import org.apache.syncope.common.types.ResourceOperation;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.ExternalResource;
import org.apache.syncope.core.persistence.beans.SchedTask;
import org.apache.syncope.core.persistence.beans.SyncTask;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java Mon Dec 16 11:04:52 2013
@@ -44,7 +44,7 @@ import org.apache.syncope.common.to.Repo
import org.apache.syncope.common.types.ReportExecExportFormat;
import org.apache.syncope.common.types.ReportExecStatus;
import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.init.JobInstanceLoader;
import org.apache.syncope.core.persistence.beans.Report;
import org.apache.syncope.core.persistence.beans.ReportExec;
@@ -129,16 +129,6 @@ public class ReportController extends Ab
}
@PreAuthorize("hasRole('REPORT_LIST')")
- public List<ReportTO> list() {
- List<Report> reports = reportDAO.findAll();
- List<ReportTO> result = new ArrayList<ReportTO>(reports.size());
- for (Report report : reports) {
- result.add(binder.getReportTO(report));
- }
- return result;
- }
-
- @PreAuthorize("hasRole('REPORT_LIST')")
public List<ReportTO> list(final int page, final int size) {
List<Report> reports = reportDAO.findAll(page, size);
List<ReportTO> result = new ArrayList<ReportTO>(reports.size());
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java Mon Dec 16 11:04:52 2013
@@ -24,14 +24,14 @@ import java.util.Set;
import javax.persistence.EntityExistsException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.syncope.common.to.BulkAction;
-import org.apache.syncope.common.to.BulkActionRes;
+import org.apache.syncope.common.reqres.BulkAction;
+import org.apache.syncope.common.reqres.BulkActionResult;
import org.apache.syncope.common.to.ConnObjectTO;
import org.apache.syncope.common.to.ResourceTO;
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.MappingPurpose;
import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.connid.ConnObjectUtil;
import org.apache.syncope.core.init.ImplementationClassNamesLoader;
import org.apache.syncope.core.persistence.beans.AbstractAttributable;
@@ -246,16 +246,16 @@ public class ResourceController extends
}
@PreAuthorize("hasRole('RESOURCE_DELETE') and #bulkAction.operation == #bulkAction.operation.DELETE")
- public BulkActionRes bulk(final BulkAction bulkAction) {
- BulkActionRes res = new BulkActionRes();
+ public BulkActionResult bulk(final BulkAction bulkAction) {
+ BulkActionResult res = new BulkActionResult();
if (bulkAction.getOperation() == BulkAction.Type.DELETE) {
for (String name : bulkAction.getTargets()) {
try {
- res.add(delete(name).getName(), BulkActionRes.Status.SUCCESS);
+ res.add(delete(name).getName(), BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.error("Error performing delete for resource {}", name, e);
- res.add(name, BulkActionRes.Status.FAILURE);
+ res.add(name, BulkActionResult.Status.FAILURE);
}
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java Mon Dec 16 11:04:52 2013
@@ -27,12 +27,11 @@ import java.util.Set;
import javax.annotation.Resource;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.syncope.common.mod.RoleMod;
-import org.apache.syncope.common.search.NodeCond;
-import org.apache.syncope.common.services.InvalidSearchConditionException;
+import org.apache.syncope.core.persistence.dao.search.SearchCond;
import org.apache.syncope.common.to.RoleTO;
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.PropagationTask;
import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
@@ -182,7 +181,7 @@ public class RoleController extends Abst
@PreAuthorize("isAuthenticated()")
@Transactional(readOnly = true)
public List<RoleTO> list(final int page, final int size) {
- List<SyncopeRole> roles = roleDAO.findAll();
+ List<SyncopeRole> roles = roleDAO.findAll(page, size);
List<RoleTO> roleTOs = new ArrayList<RoleTO>(roles.size());
for (SyncopeRole role : roles) {
@@ -194,28 +193,14 @@ public class RoleController extends Abst
@PreAuthorize("isAuthenticated()")
@Transactional(readOnly = true, rollbackFor = { Throwable.class })
- public int searchCount(final NodeCond searchCondition)
- throws InvalidSearchConditionException {
-
- if (!searchCondition.isValid()) {
- LOG.error("Invalid search condition: {}", searchCondition);
- throw new InvalidSearchConditionException();
- }
-
+ public int searchCount(final SearchCond searchCondition) {
final Set<Long> adminRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
return searchDAO.count(adminRoleIds, searchCondition, AttributableUtil.getInstance(AttributableType.ROLE));
}
@PreAuthorize("isAuthenticated()")
@Transactional(readOnly = true, rollbackFor = { Throwable.class })
- public List<RoleTO> search(final NodeCond searchCondition, final int page, final int size)
- throws InvalidSearchConditionException {
-
- if (!searchCondition.isValid()) {
- LOG.error("Invalid search condition: {}", searchCondition);
- throw new InvalidSearchConditionException();
- }
-
+ public List<RoleTO> search(final SearchCond searchCondition, final int page, final int size) {
final List<SyncopeRole> matchingRoles = searchDAO.search(
EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames()), searchCondition, page, size,
AttributableUtil.getInstance(AttributableType.ROLE));
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java Mon Dec 16 11:04:52 2013
@@ -31,7 +31,7 @@ import org.apache.syncope.common.to.VirS
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.types.SchemaType;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java Mon Dec 16 11:04:52 2013
@@ -24,8 +24,8 @@ import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.syncope.common.to.BulkAction;
-import org.apache.syncope.common.to.BulkActionRes;
+import org.apache.syncope.common.reqres.BulkAction;
+import org.apache.syncope.common.reqres.BulkActionResult;
import org.apache.syncope.common.to.SchedTaskTO;
import org.apache.syncope.common.to.SyncTaskTO;
import org.apache.syncope.common.to.TaskExecTO;
@@ -34,7 +34,7 @@ import org.apache.syncope.common.types.P
import org.apache.syncope.common.types.PropagationTaskExecStatus;
import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.types.TaskType;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.init.ImplementationClassNamesLoader;
import org.apache.syncope.core.init.JobInstanceLoader;
import org.apache.syncope.core.notification.NotificationJob;
@@ -142,20 +142,6 @@ public class TaskController extends Abst
@PreAuthorize("hasRole('TASK_LIST')")
@SuppressWarnings("unchecked")
- public <T extends AbstractTaskTO> List<T> list(final TaskType taskType) {
- TaskUtil taskUtil = TaskUtil.getInstance(taskType);
-
- List<Task> tasks = taskDAO.findAll(taskUtil.taskClass());
- List<T> taskTOs = new ArrayList<T>(tasks.size());
- for (Task task : tasks) {
- taskTOs.add((T) binder.getTaskTO(task, taskUtil));
- }
-
- return taskTOs;
- }
-
- @PreAuthorize("hasRole('TASK_LIST')")
- @SuppressWarnings("unchecked")
public <T extends AbstractTaskTO> List<T> list(final TaskType taskType, final int page, final int size) {
TaskUtil taskUtil = TaskUtil.getInstance(taskType);
@@ -326,17 +312,17 @@ public class TaskController extends Abst
+ "(hasRole('TASK_EXECUTE') and "
+ "(#bulkAction.operation == #bulkAction.operation.EXECUTE or "
+ "#bulkAction.operation == #bulkAction.operation.DRYRUN))")
- public BulkActionRes bulk(final BulkAction bulkAction) {
- BulkActionRes res = new BulkActionRes();
+ public BulkActionResult bulk(final BulkAction bulkAction) {
+ BulkActionResult res = new BulkActionResult();
switch (bulkAction.getOperation()) {
case DELETE:
for (String taskId : bulkAction.getTargets()) {
try {
- res.add(delete(Long.valueOf(taskId)).getId(), BulkActionRes.Status.SUCCESS);
+ res.add(delete(Long.valueOf(taskId)).getId(), BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.error("Error performing delete for task {}", taskId, e);
- res.add(taskId, BulkActionRes.Status.FAILURE);
+ res.add(taskId, BulkActionResult.Status.FAILURE);
}
}
break;
@@ -345,10 +331,10 @@ public class TaskController extends Abst
for (String taskId : bulkAction.getTargets()) {
try {
execute(Long.valueOf(taskId), true);
- res.add(taskId, BulkActionRes.Status.SUCCESS);
+ res.add(taskId, BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.error("Error performing dryrun for task {}", taskId, e);
- res.add(taskId, BulkActionRes.Status.FAILURE);
+ res.add(taskId, BulkActionResult.Status.FAILURE);
}
}
break;
@@ -357,10 +343,10 @@ public class TaskController extends Abst
for (String taskId : bulkAction.getTargets()) {
try {
execute(Long.valueOf(taskId), false);
- res.add(taskId, BulkActionRes.Status.SUCCESS);
+ res.add(taskId, BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.error("Error performing execute for task {}", taskId, e);
- res.add(taskId, BulkActionRes.Status.FAILURE);
+ res.add(taskId, BulkActionResult.Status.FAILURE);
}
}
break;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java Mon Dec 16 11:04:52 2013
@@ -29,16 +29,15 @@ import java.util.Set;
import org.apache.syncope.common.mod.StatusMod;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.syncope.common.mod.UserMod;
-import org.apache.syncope.common.search.NodeCond;
-import org.apache.syncope.common.services.InvalidSearchConditionException;
-import org.apache.syncope.common.to.BulkAction;
-import org.apache.syncope.common.to.BulkActionRes;
-import org.apache.syncope.common.to.BulkActionRes.Status;
+import org.apache.syncope.core.persistence.dao.search.SearchCond;
+import org.apache.syncope.common.reqres.BulkAction;
+import org.apache.syncope.common.reqres.BulkActionResult;
+import org.apache.syncope.common.reqres.BulkActionResult.Status;
import org.apache.syncope.common.to.MembershipTO;
import org.apache.syncope.common.to.UserTO;
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.PropagationTask;
import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
@@ -120,12 +119,7 @@ public class UserController extends Abst
@PreAuthorize("hasRole('USER_LIST')")
@Transactional(readOnly = true, rollbackFor = { Throwable.class })
- public int searchCount(final NodeCond searchCondition) throws InvalidSearchConditionException {
- if (!searchCondition.isValid()) {
- LOG.error("Invalid search condition: {}", searchCondition);
- throw new InvalidSearchConditionException();
- }
-
+ public int searchCount(final SearchCond searchCondition) {
return searchDAO.count(EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames()),
searchCondition, AttributableUtil.getInstance(AttributableType.USER));
}
@@ -152,21 +146,14 @@ public class UserController extends Abst
}
@PreAuthorize("hasRole('USER_READ')")
- @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ @Transactional(readOnly = true)
public UserTO read(final Long userId) {
return binder.getUserTO(userId);
}
@PreAuthorize("hasRole('USER_LIST')")
- @Transactional(readOnly = true, rollbackFor = { Throwable.class })
- public List<UserTO> search(final NodeCond searchCondition, final int page, final int size)
- throws InvalidSearchConditionException {
-
- if (!searchCondition.isValid()) {
- LOG.error("Invalid search condition: {}", searchCondition);
- throw new InvalidSearchConditionException();
- }
-
+ @Transactional(readOnly = true)
+ public List<UserTO> search(final SearchCond searchCondition, final int page, final int size) {
final List<SyncopeUser> matchingUsers = searchDAO.search(EntitlementUtil.getRoleIds(EntitlementUtil.
getOwnedEntitlementNames()), searchCondition, page, size,
AttributableUtil.getInstance(AttributableType.USER));
@@ -252,18 +239,16 @@ public class UserController extends Abst
*/
WorkflowResult<Map.Entry<UserMod, Boolean>> updated = uwfAdapter.update(actual);
- List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(updated);
-
PropagationReporter propagationReporter = ApplicationContextProvider.getApplicationContext().
getBean(PropagationReporter.class);
+ List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(updated);
if (tasks.isEmpty()) {
// SYNCOPE-459: take care of user virtual attributes ...
binder.forceVirtualAttributes(
updated.getResult().getKey().getId(),
actual.getVirAttrsToRemove(),
actual.getVirAttrsToUpdate());
-
} else {
try {
taskExecutor.execute(tasks, propagationReporter);
@@ -389,8 +374,8 @@ public class UserController extends Abst
+ "(hasRole('USER_UPDATE') and "
+ "(#bulkAction.operation == #bulkAction.operation.REACTIVATE or "
+ "#bulkAction.operation == #bulkAction.operation.SUSPEND))")
- public BulkActionRes bulk(final BulkAction bulkAction) {
- BulkActionRes res = new BulkActionRes();
+ public BulkActionResult bulk(final BulkAction bulkAction) {
+ BulkActionResult res = new BulkActionResult();
switch (bulkAction.getOperation()) {
case DELETE:
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java Mon Dec 16 11:04:52 2013
@@ -35,8 +35,8 @@ import org.apache.syncope.common.types.I
import org.apache.syncope.common.types.MappingPurpose;
import org.apache.syncope.common.types.ResourceOperation;
import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientCompositeException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.beans.AbstractAttrValue;
import org.apache.syncope.core.persistence.beans.AbstractAttributable;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ConnInstanceDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ConnInstanceDataBinder.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ConnInstanceDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ConnInstanceDataBinder.java Mon Dec 16 11:04:52 2013
@@ -27,7 +27,7 @@ import org.apache.syncope.common.types.C
import org.apache.syncope.common.types.ConnConfProperty;
import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.connid.ConnPoolConfUtil;
import org.apache.syncope.core.persistence.beans.ConnInstance;
import org.apache.syncope.core.persistence.dao.ConnInstanceDAO;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/NotificationDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/NotificationDataBinder.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/NotificationDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/NotificationDataBinder.java Mon Dec 16 11:04:52 2013
@@ -26,7 +26,7 @@ import org.springframework.stereotype.Co
@Component
public class NotificationDataBinder {
- private static final String[] IGNORE_PROPERTIES = {"id", "about", "recipients"};
+ private static final String[] IGNORE_PROPERTIES = { "id", "about", "recipients" };
public NotificationTO getNotificationTO(final Notification notification) {
NotificationTO result = new NotificationTO();
@@ -48,6 +48,7 @@ public class NotificationDataBinder {
public void updateNotification(final Notification notification, final NotificationTO notificationTO) {
BeanUtils.copyProperties(notificationTO, notification, IGNORE_PROPERTIES);
+
notification.setAbout(notificationTO.getAbout());
notification.setRecipients(notificationTO.getRecipients());
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java Mon Dec 16 11:04:52 2013
@@ -33,8 +33,8 @@ import org.apache.syncope.common.types.C
import org.apache.syncope.common.types.IntMappingType;
import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientCompositeException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.AbstractMapping;
import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
import org.apache.syncope.core.persistence.beans.AccountPolicy;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java Mon Dec 16 11:04:52 2013
@@ -27,8 +27,8 @@ import org.apache.syncope.common.to.Role
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.ResourceOperation;
import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientCompositeException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.connid.ConnObjectUtil;
import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
import org.apache.syncope.core.persistence.beans.AbstractSchema;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java Mon Dec 16 11:04:52 2013
@@ -25,8 +25,8 @@ import org.apache.syncope.common.to.Sche
import org.apache.syncope.common.to.VirSchemaTO;
import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientCompositeException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondConverter.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondConverter.java?rev=1551172&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondConverter.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondConverter.java Mon Dec 16 11:04:52 2013
@@ -0,0 +1,50 @@
+/*
+ * 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.rest.data;
+
+import org.apache.cxf.jaxrs.ext.search.SearchBean;
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
+import org.apache.syncope.common.search.SyncopeFiqlSearchConditionBuilder;
+import org.apache.syncope.core.persistence.dao.search.SearchCond;
+
+/**
+ * Converts FIQL expressions to Syncope's <tt>SearchCond</tt>.
+ */
+public final class SearchCondConverter {
+
+ /**
+ * Parses a FIQL expression into Syncope's <tt>SearchCond</tt>, using CXF's <tt>FiqlParser</tt>.
+ *
+ * @param fiqlExpression FIQL string
+ * @return <tt>SearchCond</tt> instance for given FIQL expression
+ * @see FiqlParser
+ */
+ public static SearchCond convert(final String fiqlExpression) {
+ FiqlParser<SearchBean> fiqlParser = new FiqlParser<SearchBean>(
+ SearchBean.class, SyncopeFiqlSearchConditionBuilder.CONTEXTUAL_PROPERTIES);
+ SearchCondVisitor searchCondVisitor = new SearchCondVisitor();
+
+ searchCondVisitor.visit(fiqlParser.parse(fiqlExpression));
+ return searchCondVisitor.getQuery();
+ }
+
+ private SearchCondConverter() {
+ // empty constructor for static utility class
+ }
+}
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondConverter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondConverter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondVisitor.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondVisitor.java?rev=1551172&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondVisitor.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondVisitor.java Mon Dec 16 11:04:52 2013
@@ -0,0 +1,202 @@
+/*
+ * 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.rest.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.cxf.jaxrs.ext.search.ConditionType;
+import org.apache.cxf.jaxrs.ext.search.SearchBean;
+import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchUtils;
+import org.apache.cxf.jaxrs.ext.search.visitor.AbstractSearchConditionVisitor;
+import org.apache.syncope.common.search.SearchableFields;
+import org.apache.syncope.common.search.SpecialAttr;
+import org.apache.syncope.common.to.RoleTO;
+import org.apache.syncope.common.to.UserTO;
+import org.apache.syncope.core.persistence.dao.search.AttributableCond;
+import org.apache.syncope.core.persistence.dao.search.AttributeCond;
+import org.apache.syncope.core.persistence.dao.search.EntitlementCond;
+import org.apache.syncope.core.persistence.dao.search.MembershipCond;
+import org.apache.syncope.core.persistence.dao.search.ResourceCond;
+import org.apache.syncope.core.persistence.dao.search.SearchCond;
+
+/**
+ * Converts CXF's <tt>SearchCondition</tt> into internal <tt>SearchCond</tt>.
+ */
+public class SearchCondVisitor extends AbstractSearchConditionVisitor<SearchBean, SearchCond> {
+
+ private static final List<String> ATTRIBUTABLE_FIELDS;
+
+ static {
+ ATTRIBUTABLE_FIELDS = new ArrayList<String>();
+ ATTRIBUTABLE_FIELDS.addAll(SearchableFields.get(UserTO.class));
+ ATTRIBUTABLE_FIELDS.addAll(SearchableFields.get(RoleTO.class));
+ }
+
+ private SearchCond searchCond;
+
+ public SearchCondVisitor() {
+ super(null);
+ }
+
+ public SearchCondVisitor(final Map<String, String> fieldMap) {
+ super(fieldMap);
+ }
+
+ private AttributeCond createAttributeCond(final String schema) {
+ AttributeCond attributeCond = ATTRIBUTABLE_FIELDS.contains(schema)
+ ? new AttributableCond()
+ : new AttributeCond();
+ attributeCond.setSchema(schema);
+ return attributeCond;
+ }
+
+ private SearchCond visitPrimitive(final SearchCondition<SearchBean> sc) {
+ String name = getRealPropertyName(sc.getStatement().getProperty());
+ SpecialAttr specialAttrName = SpecialAttr.fromString(name);
+
+ String value = SearchUtils.toSqlWildcardString(sc.getStatement().getValue().toString(), false);
+ SpecialAttr specialAttrValue = SpecialAttr.fromString(value);
+
+ AttributeCond attributeCond = createAttributeCond(name);
+ attributeCond.setExpression(value);
+
+ SearchCond leaf;
+ switch (sc.getConditionType()) {
+ case EQUALS:
+ case NOT_EQUALS:
+ if (specialAttrName == null) {
+ if (specialAttrValue != null && specialAttrValue == SpecialAttr.NULL) {
+ attributeCond.setType(AttributeCond.Type.ISNULL);
+ attributeCond.setExpression(null);
+ } else if (value.indexOf('%') == -1) {
+ attributeCond.setType(AttributeCond.Type.EQ);
+ } else {
+ attributeCond.setType(AttributeCond.Type.LIKE);
+ }
+
+ leaf = SearchCond.getLeafCond(attributeCond);
+ } else {
+ switch (specialAttrName) {
+ case ROLES:
+ MembershipCond membershipCond = new MembershipCond();
+ membershipCond.setRoleId(Long.valueOf(value));
+ leaf = SearchCond.getLeafCond(membershipCond);
+ break;
+
+ case RESOURCES:
+ ResourceCond resourceCond = new ResourceCond();
+ resourceCond.setResourceName(value);
+ leaf = SearchCond.getLeafCond(resourceCond);
+ break;
+
+ case ENTITLEMENTS:
+ EntitlementCond entitlementCond = new EntitlementCond();
+ entitlementCond.setExpression(value);
+ leaf = SearchCond.getLeafCond(entitlementCond);
+ break;
+
+ default:
+ throw new IllegalArgumentException(
+ String.format("Special attr name %s is not supported", specialAttrName));
+ }
+ }
+ if (sc.getConditionType() == ConditionType.NOT_EQUALS) {
+ if (leaf.getAttributeCond() != null
+ && leaf.getAttributeCond().getType() == AttributeCond.Type.ISNULL) {
+
+ leaf.getAttributeCond().setType(AttributeCond.Type.ISNOTNULL);
+ } else if (leaf.getAttributableCond() != null
+ && leaf.getAttributableCond().getType() == AttributableCond.Type.ISNULL) {
+
+ leaf.getAttributableCond().setType(AttributeCond.Type.ISNOTNULL);
+ } else {
+ leaf = SearchCond.getNotLeafCond(leaf);
+ }
+ }
+ break;
+
+ case GREATER_OR_EQUALS:
+ attributeCond.setType(AttributeCond.Type.GE);
+ leaf = SearchCond.getLeafCond(attributeCond);
+ break;
+
+ case GREATER_THAN:
+ attributeCond.setType(AttributeCond.Type.GT);
+ leaf = SearchCond.getLeafCond(attributeCond);
+ break;
+
+ case LESS_OR_EQUALS:
+ attributeCond.setType(AttributeCond.Type.LE);
+ leaf = SearchCond.getLeafCond(attributeCond);
+ break;
+
+ case LESS_THAN:
+ attributeCond.setType(AttributeCond.Type.LT);
+ leaf = SearchCond.getLeafCond(attributeCond);
+ break;
+
+ default:
+ throw new IllegalArgumentException(
+ String.format("Condition type %s is not supported", sc.getConditionType().name()));
+ }
+
+ return leaf;
+ }
+
+ private SearchCond visitCompount(final SearchCondition<SearchBean> sc) {
+ List<SearchCond> searchConds = new ArrayList<SearchCond>();
+ for (SearchCondition<SearchBean> searchCondition : sc.getSearchConditions()) {
+ searchConds.add(searchCondition.getStatement() == null
+ ? visitCompount(searchCondition)
+ : visitPrimitive(searchCondition));
+ }
+
+ SearchCond compound;
+ switch (sc.getConditionType()) {
+ case AND:
+ compound = SearchCond.getAndCond(searchConds);
+ break;
+
+ case OR:
+ compound = SearchCond.getOrCond(searchConds);
+ break;
+
+ default:
+ throw new IllegalArgumentException(
+ String.format("Condition type %s is not supported", sc.getConditionType().name()));
+ }
+
+ return compound;
+ }
+
+ @Override
+ public void visit(final SearchCondition<SearchBean> sc) {
+ searchCond = sc.getStatement() == null
+ ? visitCompount(sc)
+ : visitPrimitive(sc);
+ }
+
+ @Override
+ public SearchCond getQuery() {
+ return searchCond;
+ }
+
+}
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondVisitor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SearchCondVisitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java Mon Dec 16 11:04:52 2013
@@ -32,7 +32,7 @@ import org.apache.syncope.common.to.User
import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.types.TaskType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.init.JobInstanceLoader;
import org.apache.syncope.core.persistence.beans.ExternalResource;
import org.apache.syncope.core.persistence.beans.NotificationTask;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Mon Dec 16 11:04:52 2013
@@ -35,8 +35,8 @@ import org.apache.syncope.common.types.P
import org.apache.syncope.common.types.ResourceOperation;
import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientCompositeException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.connid.ConnObjectUtil;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java Mon Dec 16 11:04:52 2013
@@ -30,12 +30,11 @@ import javax.ws.rs.core.Response.Respons
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
-import org.apache.syncope.common.services.InvalidSearchConditionException;
import org.apache.syncope.common.types.EntityViolationType;
import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.types.RESTHeaders;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
-import org.apache.syncope.common.validation.SyncopeClientException;
+import org.apache.syncope.common.SyncopeClientCompositeException;
+import org.apache.syncope.common.SyncopeClientException;
import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.persistence.validation.attrvalue.ParsingValidationException;
@@ -202,8 +201,6 @@ public class RestServiceExceptionMapper
}
} else if (ex instanceof WorkflowException) {
return buildResponse(responseBuilder, ClientExceptionType.Workflow, getExMessage(ex));
- } else if (ex instanceof InvalidSearchConditionException) {
- return buildResponse(responseBuilder, ClientExceptionType.InvalidSearchCondition, getExMessage(ex));
} else if (ex instanceof PersistenceException) {
return buildResponse(responseBuilder, ClientExceptionType.GenericPersistence, getExMessage(ex));
} else if (ex instanceof org.apache.ibatis.exceptions.PersistenceException) {
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java Mon Dec 16 11:04:52 2013
@@ -19,27 +19,46 @@
package org.apache.syncope.core.services;
import java.net.URI;
+import java.util.List;
+import java.util.Map;
import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.ext.search.SearchBean;
+import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchContext;
+import org.apache.syncope.common.AbstractBaseBean;
+import org.apache.syncope.common.SyncopeClientException;
+import org.apache.syncope.common.services.JAXRSService;
+import org.apache.syncope.common.reqres.PagedResult;
+import org.apache.syncope.common.types.ClientExceptionType;
import org.apache.syncope.common.types.Preference;
import org.apache.syncope.common.types.RESTHeaders;
+import org.apache.syncope.core.persistence.dao.search.SearchCond;
+import org.apache.syncope.core.rest.data.SearchCondVisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-abstract class AbstractServiceImpl {
+abstract class AbstractServiceImpl implements JAXRSService {
/**
* Logger.
*/
protected static final Logger LOG = LoggerFactory.getLogger(AbstractServiceImpl.class);
+ protected static final String OPTIONS_ALLOW = "GET,POST,OPTIONS,HEAD";
+
@Context
protected UriInfo uriInfo;
@Context
- protected MessageContext context;
+ protected MessageContext messageContext;
+
+ @Context
+ protected SearchContext searchContext;
/**
* Reads <tt>Prefer</tt> header from request and parses into a <tt>Preference</tt> instance.
@@ -48,7 +67,7 @@ abstract class AbstractServiceImpl {
* or <tt>Preference.NONE</tt> if missing.
*/
protected Preference getPreference() {
- return Preference.fromString(context.getHttpHeaders().getHeaderString(RESTHeaders.PREFER));
+ return Preference.fromString(messageContext.getHttpHeaders().getHeaderString(RESTHeaders.PREFER));
}
/**
@@ -108,4 +127,84 @@ abstract class AbstractServiceImpl {
return builder;
}
+
+ /**
+ * Checks whether given page and size values are valid.
+ *
+ * [SYNCOPE-461] Keep this method until BVal 1.0 (implementing JSR 303 1.1 which will work with CXF JAX-RS
+ * validation) is available.
+ *
+ * @param page result page number
+ * @param size number of entries per page
+ * @see https://issues.apache.org/jira/browse/SYNCOPE-461
+ */
+ protected void checkPageSize(final int page, final int size) {
+ if (page <= 0 || size <= 0) {
+ LOG.error("Invalid page / size specified: {},{}", page, size);
+
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPageOrSize);
+ sce.getElements().add(page);
+ sce.getElements().add(size);
+ throw sce;
+ }
+ }
+
+ protected SearchCond getSearchCond(final String fiql) {
+ try {
+ SearchCondVisitor visitor = new SearchCondVisitor();
+ SearchCondition<SearchBean> sc = searchContext.getCondition(fiql, SearchBean.class);
+ sc.accept(visitor);
+
+ return visitor.getQuery();
+ } catch (Exception e) {
+ LOG.error("Invalid FIQL expression: {}", fiql, e);
+
+ SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSearchExpression);
+ sce.getElements().add(fiql);
+ throw sce;
+ }
+ }
+
+ /**
+ * Builds a paged result out of a list of items and additional information.
+ *
+ * @param <T> result type
+ * @param list bare list of items to be returned
+ * @param page current page
+ * @param size requested size
+ * @param totalCount total result size (not considering pagination)
+ * @return
+ */
+ protected <T extends AbstractBaseBean> PagedResult<T> buildPagedResult(
+ final List<T> list, final int page, final int size, final int totalCount) {
+
+ PagedResult<T> result = new PagedResult<T>();
+ result.getResult().addAll(list);
+
+ result.setPage(page);
+ result.setSize(result.getResult().size());
+ result.setTotalCount(totalCount);
+
+ UriBuilder builder = uriInfo.getAbsolutePathBuilder();
+ MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
+ for (Map.Entry<String, List<String>> queryParam : queryParams.entrySet()) {
+ builder = builder.queryParam(queryParam.getKey(), queryParam.getValue().toArray());
+ }
+
+ if (result.getPage() > 1) {
+ result.setPrev(builder.
+ replaceQueryParam(PARAM_PAGE, result.getPage() - 1).
+ replaceQueryParam(PARAM_SIZE, size).
+ build());
+ }
+ if ((result.getPage() - 1) * size + result.getSize() < totalCount) {
+ result.setNext(builder.
+ replaceQueryParam(PARAM_PAGE, result.getPage() + 1).
+ replaceQueryParam(PARAM_SIZE, size).
+ build());
+ }
+
+ return result;
+ }
+
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java Mon Dec 16 11:04:52 2013
@@ -30,8 +30,8 @@ import javax.ws.rs.core.StreamingOutput;
import org.apache.syncope.common.services.ConfigurationService;
import org.apache.syncope.common.to.ConfigurationTO;
-import org.apache.syncope.common.to.MailTemplateTO;
-import org.apache.syncope.common.to.ValidatorTO;
+import org.apache.syncope.common.wrap.MailTemplate;
+import org.apache.syncope.common.wrap.Validator;
import org.apache.syncope.common.types.RESTHeaders;
import org.apache.syncope.common.util.CollectionWrapper;
import org.apache.syncope.core.persistence.dao.impl.ContentLoader;
@@ -76,14 +76,14 @@ public class ConfigurationServiceImpl ex
@Override
@SuppressWarnings("unchecked")
- public List<MailTemplateTO> getMailTemplates() {
- return CollectionWrapper.wrap(controller.getMailTemplates(), MailTemplateTO.class);
+ public List<MailTemplate> getMailTemplates() {
+ return CollectionWrapper.wrap(controller.getMailTemplates(), MailTemplate.class);
}
@Override
@SuppressWarnings("unchecked")
- public List<ValidatorTO> getValidators() {
- return CollectionWrapper.wrap(controller.getValidators(), ValidatorTO.class);
+ public List<Validator> getValidators() {
+ return CollectionWrapper.wrap(controller.getValidators(), Validator.class);
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java Mon Dec 16 11:04:52 2013
@@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.Response;
import org.apache.syncope.common.services.ConnectorService;
-import org.apache.syncope.common.to.BulkAction;
-import org.apache.syncope.common.to.BulkActionRes;
+import org.apache.syncope.common.reqres.BulkAction;
+import org.apache.syncope.common.reqres.BulkActionResult;
import org.apache.syncope.common.to.ConnBundleTO;
import org.apache.syncope.common.to.ConnIdObjectClassTO;
import org.apache.syncope.common.to.ConnInstanceTO;
@@ -122,7 +122,7 @@ public class ConnectorServiceImpl extend
}
@Override
- public BulkActionRes bulk(final BulkAction bulkAction) {
+ public BulkActionResult bulk(final BulkAction bulkAction) {
return controller.bulk(bulkAction);
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java?rev=1551172&r1=1551171&r2=1551172&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java Mon Dec 16 11:04:52 2013
@@ -21,7 +21,7 @@ package org.apache.syncope.core.services
import java.util.List;
import org.apache.syncope.common.services.EntitlementService;
-import org.apache.syncope.common.to.EntitlementTO;
+import org.apache.syncope.common.wrap.EntitlementTO;
import org.apache.syncope.common.util.CollectionWrapper;
import org.apache.syncope.core.rest.controller.EntitlementController;
import org.springframework.beans.factory.annotation.Autowired;