You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by jb...@apache.org on 2012/11/12 09:25:22 UTC
svn commit: r1408183 [1/2] - in /incubator/syncope/branches/cxf: ./
archetype/ build-tools/ client/ common/ common/.externalToolBuilders/
common/src/main/java/org/apache/syncope/
common/src/main/java/org/apache/syncope/controller/ common/src/main/java/...
Author: jbernhardt
Date: Mon Nov 12 08:25:17 2012
New Revision: 1408183
URL: http://svn.apache.org/viewvc?rev=1408183&view=rev
Log:
Added User and Role Controller Interfaces
Added:
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/NotFoundException.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/InvalidSearchConditionException.java
- copied, changed from r1405783, incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/InvalidSearchConditionException.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/RoleController.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UnauthorizedRoleException.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UserController.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/propagation/
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/propagation/PropagationException.java
- copied, changed from r1405783, incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/workflow/
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/workflow/WorkflowException.java
- copied, changed from r1405783, incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/WorkflowException.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/RoleControllerImpl.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/UserControllerImpl.java
Removed:
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/InvalidSearchConditionException.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/WorkflowException.java
Modified:
incubator/syncope/branches/cxf/archetype/ (props changed)
incubator/syncope/branches/cxf/build-tools/ (props changed)
incubator/syncope/branches/cxf/client/ (props changed)
incubator/syncope/branches/cxf/client/pom.xml
incubator/syncope/branches/cxf/common/ (props changed)
incubator/syncope/branches/cxf/common/.externalToolBuilders/Maven_Ant_Builder.launch
incubator/syncope/branches/cxf/common/maven-eclipse.xml
incubator/syncope/branches/cxf/common/pom.xml
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/mod/AbstractAttributableMod.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/NodeCond.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/ResourceCond.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/DerivedSchemaTO.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/SchemaMappingTO.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/VirtualSchemaTO.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/AuditLoggerName.java
incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/PropagationTaskExecStatus.java
incubator/syncope/branches/cxf/console/ (props changed)
incubator/syncope/branches/cxf/core/ (props changed)
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/UserDAO.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/AbstractPropagationTaskExecutor.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PriorityPropagationTaskExecutor.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/sync/SyncopeSyncResultHanlder.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java
incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java
incubator/syncope/branches/cxf/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java
incubator/syncope/branches/cxf/core/src/test/java/org/apache/syncope/core/persistence/dao/UserTest.java
incubator/syncope/branches/cxf/pom.xml
Propchange: incubator/syncope/branches/cxf/archetype/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Nov 12 08:25:17 2012
@@ -1 +1,2 @@
target
+.project
Propchange: incubator/syncope/branches/cxf/build-tools/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Nov 12 08:25:17 2012
@@ -1,3 +1,5 @@
target
nb-configuration.xml
.pom.xml.swp
+.classpath
+.project
Propchange: incubator/syncope/branches/cxf/client/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Nov 12 08:25:17 2012
@@ -1,2 +1,4 @@
target
nb-configuration.xml
+.classpath
+.project
Modified: incubator/syncope/branches/cxf/client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/client/pom.xml?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/client/pom.xml (original)
+++ incubator/syncope/branches/cxf/client/pom.xml Mon Nov 12 08:25:17 2012
@@ -107,13 +107,8 @@ under the License.
org.apache.syncope*;version=${project.version};-split-package:=merge-first
</Export-Package>
<Import-Package>
- com.thoughtworks.xstream;version="[1.4,2)",
- org.apache.commons.lang*;version="[2.6,3)",
org.apache.http*;version="[4,5)",
- org.codehaus.jackson.annotate;version="[1.9,2)",
- org.springframework*;version="[3,4)",
- ch.qos.logback.classic;resolution:=optional,
- org.slf4j;resolution:=optional
+ *
</Import-Package>
</instructions>
</configuration>
Propchange: incubator/syncope/branches/cxf/common/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Nov 12 08:25:17 2012
@@ -0,0 +1,3 @@
+.classpath
+.project
+target
Modified: incubator/syncope/branches/cxf/common/.externalToolBuilders/Maven_Ant_Builder.launch
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/.externalToolBuilders/Maven_Ant_Builder.launch?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/.externalToolBuilders/Maven_Ant_Builder.launch (original)
+++ incubator/syncope/branches/cxf/common/.externalToolBuilders/Maven_Ant_Builder.launch Mon Nov 12 08:25:17 2012
@@ -1,25 +1,24 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
-<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
-<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
-<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/syncope-common"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="4"/>
-</listAttribute>
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
-<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
-<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
-<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
-<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="syncope-common"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version='1.0'?><launchConfigurationWorkingSet editPageId='org.eclipse.ui.resourceWorkingSetPage' factoryID='org.eclipse.ui.internal.WorkingSetFactory' label='workingSet' name='workingSet'><item factoryID='org.eclipse.ui.internal.model.ResourceFactory' path='syncope-common' type='4'/></launchConfigurationWorkingSet>}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${build_project}/maven-eclipse.xml"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/>
-<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project}"/>
-<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
-</launchConfiguration>
+ <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/>
+ <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+ <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+ <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="syncope-common"/>
+ <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${build_project}/maven-eclipse.xml"/>
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project}"/>
+ <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
+ <booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version='1.0'?><launchConfigurationWorkingSet editPageId='org.eclipse.ui.resourceWorkingSetPage' factoryID='org.eclipse.ui.internal.WorkingSetFactory' label='workingSet' name='workingSet'><item factoryID='org.eclipse.ui.internal.model.ResourceFactory' path='syncope-common' type='4'/></launchConfigurationWorkingSet>}"/>
+ <stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
+ <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
+ <booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
+ <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
+ <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+ <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+ <listEntry value="1"/>
+ </listAttribute>
+ <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+ <listEntry value="/syncope-common/maven-eclipse.xml"/>
+ </listAttribute>
+</launchConfiguration>
\ No newline at end of file
Modified: incubator/syncope/branches/cxf/common/maven-eclipse.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/maven-eclipse.xml?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/maven-eclipse.xml (original)
+++ incubator/syncope/branches/cxf/common/maven-eclipse.xml Mon Nov 12 08:25:17 2012
@@ -2,7 +2,7 @@
<target name="init"/>
<target name="copy-resources" depends="init">
<copy todir="target/classes/META-INF" filtering="false">
- <fileset dir="C:/Users/jbernhard/workspace/syncope/cxf-port" includes="LICENSE|NOTICE|DISCLAIMER" excludes="**/*.java"/>
+ <fileset dir="C:/Users/jbernhard/workspace/syncope/module-refactoring" includes="LICENSE|NOTICE|DISCLAIMER" excludes="**/*.java"/>
</copy>
</target>
</project>
\ No newline at end of file
Modified: incubator/syncope/branches/cxf/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/pom.xml?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/pom.xml (original)
+++ incubator/syncope/branches/cxf/common/pom.xml Mon Nov 12 08:25:17 2012
@@ -43,7 +43,29 @@ under the License.
</distributionManagement>
<dependencies>
+<dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
@@ -55,13 +77,8 @@ under the License.
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
</dependency>
<dependency>
@@ -98,12 +115,12 @@ under the License.
<Import-Package>
com.thoughtworks.xstream;version="[1.4,2)",
org.apache.commons.lang*;version="[2.6,3)",
- org.apache.http*;version="[4,5)",
org.codehaus.jackson.annotate;version="[1.9,2)",
org.springframework*;version="[3,4)",
ch.qos.logback.classic;resolution:=optional,
- org.slf4j;resolution:=optional
- </Import-Package>
+ org.slf4j;resolution:=optional,
+ *
+ </Import-Package>
</instructions>
</configuration>
</plugin>
Added: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/NotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/NotFoundException.java?rev=1408183&view=auto
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/NotFoundException.java (added)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/NotFoundException.java Mon Nov 12 08:25:17 2012
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+/**
+ * Thrown when something is not found.
+ */
+public class NotFoundException extends Exception {
+
+ private static final long serialVersionUID = 4810651769126663580L;
+
+ public NotFoundException(String msg) {
+ super(msg);
+ }
+
+ public NotFoundException(String msg, Exception e) {
+ super(msg, e);
+ }
+}
Copied: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/InvalidSearchConditionException.java (from r1405783, incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/InvalidSearchConditionException.java)
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/InvalidSearchConditionException.java?p2=incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/InvalidSearchConditionException.java&p1=incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/InvalidSearchConditionException.java&r1=1405783&r2=1408183&rev=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/InvalidSearchConditionException.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/InvalidSearchConditionException.java Mon Nov 12 08:25:17 2012
@@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.core.rest.controller;
+package org.apache.syncope.controller;
public class InvalidSearchConditionException extends Exception {
+ private static final long serialVersionUID = 4142899085950398109L;
+
public InvalidSearchConditionException() {
super();
}
Added: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/RoleController.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/RoleController.java?rev=1408183&view=auto
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/RoleController.java (added)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/RoleController.java Mon Nov 12 08:25:17 2012
@@ -0,0 +1,67 @@
+package org.apache.syncope.controller;
+
+import java.util.List;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+import org.apache.syncope.NotFoundException;
+import org.apache.syncope.mod.RoleMod;
+import org.apache.syncope.to.RoleTO;
+import org.apache.syncope.validation.SyncopeClientCompositeErrorException;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
+
+@Path("/role")
+public interface RoleController {
+
+ @GET
+ @Path("/{roleId}")
+ @PreAuthorize("isAuthenticated()")
+ @Transactional(readOnly = true)
+ public abstract RoleTO read(@PathParam("roleId") final Long roleId)
+ throws NotFoundException, UnauthorizedRoleException;
+
+ @GET
+ @Path("/{roleId}/parent")
+ @PreAuthorize("hasRole('ROLE_READ')")
+ @Transactional(readOnly = true)
+ public abstract RoleTO parent(@PathParam("roleId") final Long roleId)
+ throws NotFoundException, UnauthorizedRoleException;
+
+ @GET
+ @Path("/{roleId}/children")
+ @PreAuthorize("hasRole('ROLE_READ')")
+ @Transactional(readOnly = true)
+ public abstract List<RoleTO> children(@PathParam("roleId") final Long roleId)
+ throws NotFoundException;
+
+ @GET
+ @Transactional(readOnly = true)
+ public abstract List<RoleTO> list();
+
+ @POST
+ @Path("/")
+ @PreAuthorize("hasRole('ROLE_CREATE')")
+ public abstract Response create(final RoleTO roleTO) throws SyncopeClientCompositeErrorException,
+ UnauthorizedRoleException;
+
+ @PUT
+ @Path("/{roleId}")
+ @PreAuthorize("hasRole('ROLE_UPDATE')")
+ public abstract RoleTO update(@PathParam("roleId") final Long roleId,
+ final RoleMod roleMod) throws NotFoundException,
+ UnauthorizedRoleException;
+
+ @DELETE
+ @Path("/{roleId}")
+ @PreAuthorize("hasRole('ROLE_DELETE')")
+ public abstract RoleTO delete(@PathParam("roleId") final Long roleId)
+ throws NotFoundException, UnauthorizedRoleException;
+
+}
\ No newline at end of file
Added: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UnauthorizedRoleException.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UnauthorizedRoleException.java?rev=1408183&view=auto
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UnauthorizedRoleException.java (added)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UnauthorizedRoleException.java Mon Nov 12 08:25:17 2012
@@ -0,0 +1,42 @@
+/*
+ * 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.controller;
+
+import java.util.Collections;
+import java.util.Set;
+
+public class UnauthorizedRoleException extends Exception {
+
+ private static final long serialVersionUID = -7794737282296676827L;
+
+ private final Set<Long> roleIds;
+
+ public UnauthorizedRoleException(final Set<Long> roleIds) {
+ super("Missing entitlement for role(s) " + roleIds);
+ this.roleIds = roleIds;
+ }
+
+ public UnauthorizedRoleException(final Long roleId) {
+ this(Collections.singleton(roleId));
+ }
+
+ public Set<Long> getRoleIds() {
+ return roleIds;
+ }
+}
Added: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UserController.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UserController.java?rev=1408183&view=auto
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UserController.java (added)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/controller/UserController.java Mon Nov 12 08:25:17 2012
@@ -0,0 +1,176 @@
+package org.apache.syncope.controller;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+import org.apache.syncope.mod.UserMod;
+import org.apache.syncope.search.NodeCond;
+import org.apache.syncope.to.UserTO;
+import org.apache.syncope.to.WorkflowFormTO;
+import org.apache.syncope.propagation.PropagationException;
+import org.apache.syncope.controller.InvalidSearchConditionException;
+import org.apache.syncope.controller.UnauthorizedRoleException;
+import org.apache.syncope.NotFoundException;
+import org.apache.syncope.workflow.WorkflowException;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
+
+@Path("/user")
+public interface UserController {
+
+ @GET
+ @PreAuthorize("hasRole('USER_READ')")
+ @Transactional(readOnly = true)
+ public abstract Response verifyPassword(
+ @QueryParam("uname") String username,
+ @QueryParam("pw") final String password)
+ throws NotFoundException, UnauthorizedRoleException;
+
+ @GET
+ @Path("/count")
+ @PreAuthorize("hasRole('USER_LIST')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract Response count();
+
+ @POST
+ @Path("/count")
+ @PreAuthorize("hasRole('USER_READ')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract Response searchCount(
+ final NodeCond searchCondition)
+ throws InvalidSearchConditionException;
+
+ @GET
+ @PreAuthorize("hasRole('USER_LIST')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract List<UserTO> list();
+
+ @GET
+ @PreAuthorize("hasRole('USER_LIST')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract List<UserTO> list(@QueryParam("page") final int page,
+ @QueryParam("size") @DefaultValue("25") final int size);
+
+ @GET
+ @Path("/{userId}")
+ @PreAuthorize("hasRole('USER_READ')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract UserTO read(@PathParam("userId") final Long userId)
+ throws NotFoundException, UnauthorizedRoleException;
+
+ @GET
+ @PreAuthorize("hasRole('USER_READ')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract UserTO read(@QueryParam("uname") final String username)
+ throws NotFoundException, UnauthorizedRoleException;
+
+ @POST
+ @PreAuthorize("hasRole('USER_READ')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract List<UserTO> search(
+ final NodeCond searchCondition)
+ throws InvalidSearchConditionException;
+
+ @POST
+ @PreAuthorize("hasRole('USER_READ')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract List<UserTO> search(final NodeCond searchCondition,
+ @QueryParam("page") final int page,
+ @QueryParam("size") @DefaultValue("25") final int size)
+ throws InvalidSearchConditionException;
+
+ @POST
+ @Path("/")
+ @PreAuthorize("hasRole('USER_CREATE')")
+ public abstract Response create(final UserTO userTO) throws PropagationException,
+ UnauthorizedRoleException, WorkflowException, NotFoundException;
+
+ @PUT
+ @Path("/{userId}")
+ @PreAuthorize("hasRole('USER_UPDATE')")
+ public abstract UserTO update(final UserMod userMod)
+ throws NotFoundException, PropagationException,
+ UnauthorizedRoleException, WorkflowException;
+
+ @PUT
+ @Path("/user/{userId}/status/active")
+ @PreAuthorize("hasRole('USER_UPDATE')")
+ @Transactional(rollbackFor = { Throwable.class })
+ public abstract UserTO activate(
+ @PathParam("userId") final Long userId,
+ @FormParam("token") final String token,
+ @FormParam("resourceNames") final Set<String> resourceNames,
+ @FormParam("performLocally") @DefaultValue("true") final Boolean performLocally,
+ @FormParam("performRemotely") @DefaultValue("true") final Boolean performRemotely)
+ throws WorkflowException, NotFoundException,
+ UnauthorizedRoleException, PropagationException;
+
+ @DELETE
+ @Path("/user/{userId}/status/active")
+ @PreAuthorize("hasRole('USER_UPDATE')")
+ @Transactional(rollbackFor = { Throwable.class })
+ public abstract UserTO suspend(
+ @PathParam("userId") final Long userId,
+ @FormParam("resourceNames") final Set<String> resourceNames,
+ @FormParam("performLocally") @DefaultValue("true") final Boolean performLocally,
+ @FormParam("performRemotely") @DefaultValue("true") final Boolean performRemotely)
+ throws NotFoundException, WorkflowException,
+ UnauthorizedRoleException, PropagationException;
+
+ @DELETE
+ @Path("/{userId}")
+ @PreAuthorize("hasRole('USER_DELETE')")
+ public abstract UserTO delete(@PathParam("userId") final Long userId)
+ throws NotFoundException, WorkflowException, PropagationException,
+ UnauthorizedRoleException;
+
+ @POST
+ @Path("/workflow/task/{taskId}/execute")
+ @PreAuthorize("hasRole('USER_UPDATE')")
+ public abstract UserTO executeWorkflow(
+ @PathParam("taskId") final String taskId, final UserTO userTO)
+ throws WorkflowException, NotFoundException,
+ UnauthorizedRoleException, PropagationException;
+
+ @GET
+ @Path("/workflow/form")
+ @PreAuthorize("hasRole('WORKFLOW_FORM_LIST')")
+ @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+ public abstract List<WorkflowFormTO> getForms();
+
+ @GET
+ @Path("/{userId}/workflow/form")
+ @PreAuthorize("hasRole('WORKFLOW_FORM_READ') and hasRole('USER_READ')")
+ @Transactional(rollbackFor = { Throwable.class })
+ public abstract WorkflowFormTO getFormForUser(
+ @PathParam("userId") final Long userId)
+ throws UnauthorizedRoleException, NotFoundException,
+ WorkflowException;
+
+ @POST
+ @Path("/workflow/task/{taskId}/claim")
+ @PreAuthorize("hasRole('WORKFLOW_FORM_CLAIM')")
+ @Transactional(rollbackFor = { Throwable.class })
+ public abstract WorkflowFormTO claimForm(
+ @PathParam("taskId") final String taskId)
+ throws NotFoundException, WorkflowException;
+
+ @POST
+ @Path("/workflow/form")
+ @PreAuthorize("hasRole('WORKFLOW_FORM_SUBMIT')")
+ @Transactional(rollbackFor = { Throwable.class })
+ public abstract UserTO submitForm(final WorkflowFormTO form)
+ throws NotFoundException, WorkflowException, PropagationException,
+ UnauthorizedRoleException;
+}
\ No newline at end of file
Modified: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/mod/AbstractAttributableMod.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/mod/AbstractAttributableMod.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/mod/AbstractAttributableMod.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/mod/AbstractAttributableMod.java Mon Nov 12 08:25:17 2012
@@ -25,7 +25,7 @@ import org.apache.syncope.AbstractBaseBe
/**
* Abstract base class for objects that can have attributes removed, added or updated.
- *
+ *
* Attributes can be regular attributes, derived attributes, virtual attributes and resources.
*/
public abstract class AbstractAttributableMod extends AbstractBaseBean {
@@ -67,9 +67,9 @@ public abstract class AbstractAttributab
/**
* Convenience method for removing entire attribute instead removing each value in an AttributeMod object
- *
- * @param name (schema) of attribute to be removed.
- * @return true on success.
+ *
+ * @param attribute (schema) of attribute to be removed.
+ * @return true on success.
*/
public boolean addAttributeToBeRemoved(String attribute) {
return attributesToBeRemoved.add(attribute);
@@ -77,9 +77,9 @@ public abstract class AbstractAttributab
/**
* Convenience method for removing entire attribute instead removing each value in an AttributeMod object
- *
- * @param name (schema) of attribute to be removed.
- * @return true on success.
+ *
+ * @param attribute (schema) of attribute to be removed.
+ * @return true on success.
*/
public boolean removeAttributeToBeRemoved(String attribute) {
return attributesToBeRemoved.remove(attribute);
@@ -94,8 +94,8 @@ public abstract class AbstractAttributab
}
/**
- * Add an attribute modification object. AttributeMod itself indicates how the attribute should be modified.
- *
+ * Add an attribute modification object. AttributeMod itself indicates how the attribute should be modified.
+ *
* @param attribute modification object
* @see AttributeMod
* @return true on success
@@ -105,8 +105,8 @@ public abstract class AbstractAttributab
}
/**
- * Remove an attribute modification object. AttributeMod itself indicates how the attribute should be modified.
- *
+ * Remove an attribute modification object. AttributeMod itself indicates how the attribute should be modified.
+ *
* @param attribute modification object
* @see AttributeMod
* @return true on success
@@ -124,9 +124,9 @@ public abstract class AbstractAttributab
}
/**
- * Add an attribute modification object. AttributeMod itself indicates how the attribute should be modified.
- *
- * @param attribute modification object
+ * Add an attribute modification object. AttributeMod itself indicates how the attribute should be modified.
+ *
+ * @param derivedAttribute modification object
* @see AttributeMod
* @return true on success
*/
@@ -135,8 +135,8 @@ public abstract class AbstractAttributab
}
/**
- * Add a derivedattribute. Value is calculated by its definition.
- *
+ * Add a derivedattribute. Value is calculated by its definition.
+ *
* @param derivedAttribute
* @return true on success
*/
Copied: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/propagation/PropagationException.java (from r1405783, incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java)
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/propagation/PropagationException.java?p2=incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/propagation/PropagationException.java&p1=incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java&r1=1405783&r2=1408183&rev=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/propagation/PropagationException.java Mon Nov 12 08:25:17 2012
@@ -16,13 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.core.propagation;
+package org.apache.syncope.propagation;
/**
* Bear stacktrace received during propagation towards a certain resource.
*/
public class PropagationException extends Exception {
+ private static final long serialVersionUID = 1125884657361004958L;
+
/**
* The resource involved in this exception.
*/
Modified: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/NodeCond.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/NodeCond.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/NodeCond.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/NodeCond.java Mon Nov 12 08:25:17 2012
@@ -22,6 +22,8 @@ import org.apache.syncope.AbstractBaseBe
public class NodeCond extends AbstractBaseBean {
+ private static final long serialVersionUID = -8508611056176961293L;
+
public enum Type {
LEAF,
Modified: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/ResourceCond.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/ResourceCond.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/ResourceCond.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/search/ResourceCond.java Mon Nov 12 08:25:17 2012
@@ -25,6 +25,8 @@ import org.apache.syncope.AbstractBaseBe
*/
public class ResourceCond extends AbstractBaseBean {
+ private static final long serialVersionUID = -4577460657640881223L;
+
private String resourceName;
public String getResourceName() {
Modified: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/DerivedSchemaTO.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/DerivedSchemaTO.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/DerivedSchemaTO.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/DerivedSchemaTO.java Mon Nov 12 08:25:17 2012
@@ -22,6 +22,8 @@ import org.apache.syncope.AbstractBaseBe
public class DerivedSchemaTO extends AbstractBaseBean {
+ private static final long serialVersionUID = -5758594647387239936L;
+
private String name;
private String expression;
Modified: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/SchemaMappingTO.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/SchemaMappingTO.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/SchemaMappingTO.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/SchemaMappingTO.java Mon Nov 12 08:25:17 2012
@@ -23,6 +23,8 @@ import org.apache.syncope.types.IntMappi
public class SchemaMappingTO extends AbstractBaseBean {
+ private static final long serialVersionUID = -5948464320236155366L;
+
private Long id;
/**
Modified: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/VirtualSchemaTO.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/VirtualSchemaTO.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/VirtualSchemaTO.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/to/VirtualSchemaTO.java Mon Nov 12 08:25:17 2012
@@ -22,6 +22,8 @@ import org.apache.syncope.AbstractBaseBe
public class VirtualSchemaTO extends AbstractBaseBean {
+ private static final long serialVersionUID = -632352302417688896L;
+
private String name;
public String getName() {
Modified: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/AuditLoggerName.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/AuditLoggerName.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/AuditLoggerName.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/AuditLoggerName.java Mon Nov 12 08:25:17 2012
@@ -30,12 +30,14 @@ import org.springframework.util.StringUt
public class AuditLoggerName extends AbstractBaseBean {
- private Category category;
+ private static final long serialVersionUID = -647989486671786839L;
+
+ private final Category category;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
- private Enum<?> subcategory;
+ private final Enum<?> subcategory;
- private Result result;
+ private final Result result;
@JsonCreator
public AuditLoggerName(@JsonProperty("category") final Category category,
Modified: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/PropagationTaskExecStatus.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/PropagationTaskExecStatus.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/PropagationTaskExecStatus.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/types/PropagationTaskExecStatus.java Mon Nov 12 08:25:17 2012
@@ -26,7 +26,6 @@ package org.apache.syncope.types;
* SUBMITTED -> SUCCESS or FAILURE (depending on the external resource to
* report success or failure).
*
- * @see TaskExecution
*/
public enum PropagationTaskExecStatus {
Copied: incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/workflow/WorkflowException.java (from r1405783, incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/WorkflowException.java)
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/workflow/WorkflowException.java?p2=incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/workflow/WorkflowException.java&p1=incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/WorkflowException.java&r1=1405783&r2=1408183&rev=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/workflow/WorkflowException.java (original)
+++ incubator/syncope/branches/cxf/common/src/main/java/org/apache/syncope/workflow/WorkflowException.java Mon Nov 12 08:25:17 2012
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.core.workflow;
+package org.apache.syncope.workflow;
/**
* Wrapper for all workflow related exceptions. Original exceptions will depend
Propchange: incubator/syncope/branches/cxf/console/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Nov 12 08:25:17 2012
@@ -2,3 +2,5 @@ target
nbactions.xml
nb-configuration.xml
.pom.xml.swp
+.classpath
+.project
Propchange: incubator/syncope/branches/cxf/core/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Nov 12 08:25:17 2012
@@ -2,3 +2,5 @@ target
nb-configuration.xml
nbactions.xml
.pom.xml.swp
+.classpath
+.project
Modified: incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/UserDAO.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/UserDAO.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/UserDAO.java (original)
+++ incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/UserDAO.java Mon Nov 12 08:25:17 2012
@@ -24,7 +24,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.core.persistence.beans.user.UAttrValue;
import org.apache.syncope.core.persistence.validation.entity.InvalidEntityException;
-import org.apache.syncope.core.rest.controller.InvalidSearchConditionException;
+import org.apache.syncope.controller.InvalidSearchConditionException;
public interface UserDAO extends DAO {
Modified: incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java (original)
+++ incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java Mon Nov 12 08:25:17 2012
@@ -51,7 +51,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.dao.SchemaDAO;
import org.apache.syncope.core.persistence.dao.TaskDAO;
import org.apache.syncope.core.persistence.dao.UserDAO;
-import org.apache.syncope.core.rest.controller.InvalidSearchConditionException;
+import org.apache.syncope.controller.InvalidSearchConditionException;
@Repository
public class UserDAOImpl extends AbstractDAOImpl implements UserDAO {
Modified: incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/AbstractPropagationTaskExecutor.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/AbstractPropagationTaskExecutor.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/AbstractPropagationTaskExecutor.java (original)
+++ incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/AbstractPropagationTaskExecutor.java Mon Nov 12 08:25:17 2012
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.propagation;
+import org.apache.syncope.propagation.PropagationException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Collection;
Modified: incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PriorityPropagationTaskExecutor.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PriorityPropagationTaskExecutor.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PriorityPropagationTaskExecutor.java (original)
+++ incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PriorityPropagationTaskExecutor.java Mon Nov 12 08:25:17 2012
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.propagation;
+import org.apache.syncope.propagation.PropagationException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Modified: incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java?rev=1408183&r1=1408182&r2=1408183&view=diff
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java (original)
+++ incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java Mon Nov 12 08:25:17 2012
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.propagation;
+import org.apache.syncope.propagation.PropagationException;
import java.util.Collection;
import org.apache.syncope.core.persistence.beans.PropagationTask;
import org.apache.syncope.core.persistence.beans.TaskExec;
Added: incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/RoleControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/RoleControllerImpl.java?rev=1408183&view=auto
==============================================================================
--- incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/RoleControllerImpl.java (added)
+++ incubator/syncope/branches/cxf/core/src/main/java/org/apache/syncope/core/rest/controller/RoleControllerImpl.java Mon Nov 12 08:25:17 2012
@@ -0,0 +1,233 @@
+/*
+ * 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.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.syncope.core.audit.AuditManager;
+import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
+import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
+import org.apache.syncope.core.persistence.dao.RoleDAO;
+import org.apache.syncope.core.persistence.dao.UserDAO;
+import org.apache.syncope.core.rest.data.RoleDataBinder;
+import org.apache.syncope.core.util.EntitlementUtil;
+import org.apache.syncope.core.util.NotFoundException;
+import org.apache.syncope.mod.RoleMod;
+import org.apache.syncope.to.RoleTO;
+import org.apache.syncope.types.AuditElements.Category;
+import org.apache.syncope.types.AuditElements.Result;
+import org.apache.syncope.types.AuditElements.RoleSubCategory;
+import org.apache.syncope.validation.SyncopeClientCompositeErrorException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Controller
+@RequestMapping("/role")
+public class RoleControllerImpl extends AbstractController {
+
+ @Autowired
+ private AuditManager auditManager;
+
+ @Autowired
+ private RoleDAO roleDAO;
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private RoleDataBinder dataBinder;
+
+ @PreAuthorize("hasRole('ROLE_READ')")
+ @RequestMapping(method = RequestMethod.GET, value = "/read/{roleId}")
+ @Transactional(readOnly = true)
+ public RoleTO read(@PathVariable("roleId") final Long roleId)
+ throws NotFoundException, UnauthorizedRoleException {
+
+ SyncopeRole role = dataBinder.getSyncopeRole(roleId);
+
+ Set<Long> allowedRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
+ if (!allowedRoleIds.contains(role.getId())) {
+ throw new UnauthorizedRoleException(role.getId());
+ }
+
+ auditManager.audit(Category.role, RoleSubCategory.read, Result.success,
+ "Successfully read role: " + role.getId());
+
+ return dataBinder.getRoleTO(role);
+ }
+
+ @PreAuthorize("isAuthenticated()")
+ @RequestMapping(method = RequestMethod.GET, value = "/selfRead/{roleId}")
+ @Transactional(readOnly = true)
+ public RoleTO selfRead(@PathVariable("roleId") final Long roleId)
+ throws NotFoundException, UnauthorizedRoleException {
+
+ SyncopeRole role = dataBinder.getSyncopeRole(roleId);
+
+ SyncopeUser authUser = userDAO.find(SecurityContextHolder.getContext().getAuthentication().getName());
+ if (authUser == null) {
+ throw new NotFoundException("Authenticated user "
+ + SecurityContextHolder.getContext().getAuthentication().getName());
+ }
+
+ Set<Long> allowedRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
+ allowedRoleIds.addAll(authUser.getRoleIds());
+ if (!allowedRoleIds.contains(role.getId())) {
+ throw new UnauthorizedRoleException(role.getId());
+ }
+
+ auditManager.audit(Category.role, RoleSubCategory.selfRead, Result.success,
+ "Successfully read own role: " + role.getId());
+
+ return dataBinder.getRoleTO(role);
+ }
+
+ @PreAuthorize("hasRole('ROLE_READ')")
+ @RequestMapping(method = RequestMethod.GET, value = "/parent/{roleId}")
+ @Transactional(readOnly = true)
+ public RoleTO parent(@PathVariable("roleId") final Long roleId)
+ throws NotFoundException, UnauthorizedRoleException {
+
+ SyncopeRole role = dataBinder.getSyncopeRole(roleId);
+
+ Set<Long> allowedRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
+ if (role.getParent() != null && !allowedRoleIds.contains(role.getParent().getId())) {
+ throw new UnauthorizedRoleException(role.getParent().getId());
+ }
+
+ RoleTO result = role.getParent() == null
+ ? null
+ : dataBinder.getRoleTO(role.getParent());
+
+ auditManager.audit(Category.role, RoleSubCategory.parent, Result.success,
+ result == null
+ ? "Role " + role.getId() + " is a root role"
+ : "Found parent for role " + role.getId() + ": " + result.getId());
+
+ return result;
+ }
+
+ @PreAuthorize("hasRole('ROLE_READ')")
+ @RequestMapping(method = RequestMethod.GET, value = "/children/{roleId}")
+ @Transactional(readOnly = true)
+ public List<RoleTO> children(@PathVariable("roleId") final Long roleId) throws NotFoundException {
+ SyncopeRole role = dataBinder.getSyncopeRole(roleId);
+
+ Set<Long> allowedRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
+
+ List<SyncopeRole> children = roleDAO.findChildren(role);
+ List<RoleTO> childrenTOs = new ArrayList<RoleTO>(children.size());
+ for (SyncopeRole child : children) {
+ if (allowedRoleIds.contains(child.getId())) {
+ childrenTOs.add(dataBinder.getRoleTO(child));
+ }
+ }
+
+ auditManager.audit(Category.role, RoleSubCategory.children, Result.success,
+ "Found " + childrenTOs.size() + " children of role " + roleId);
+
+ return childrenTOs;
+ }
+
+ @RequestMapping(method = RequestMethod.GET, value = "/list")
+ @Transactional(readOnly = true)
+ public List<RoleTO> list() {
+ List<SyncopeRole> roles = roleDAO.findAll();
+ List<RoleTO> roleTOs = new ArrayList<RoleTO>(roles.size());
+ for (SyncopeRole role : roles) {
+ roleTOs.add(dataBinder.getRoleTO(role));
+ }
+
+ auditManager.audit(Category.role, RoleSubCategory.list, Result.success,
+ "Successfully listed all roles: " + roleTOs.size());
+
+ return roleTOs;
+ }
+
+ @PreAuthorize("hasRole('ROLE_CREATE')")
+ @RequestMapping(method = RequestMethod.POST, value = "/create")
+ public RoleTO create(final HttpServletResponse response, @RequestBody final RoleTO roleTO)
+ throws SyncopeClientCompositeErrorException, UnauthorizedRoleException {
+
+ LOG.debug("Role create called with parameters {}", roleTO);
+
+ Set<Long> allowedRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
+ if (roleTO.getParent() != 0 && !allowedRoleIds.contains(roleTO.getParent())) {
+ throw new UnauthorizedRoleException(roleTO.getParent());
+ }
+
+ SyncopeRole role = roleDAO.save(dataBinder.create(roleTO));
+
+ auditManager.audit(Category.role, RoleSubCategory.create, Result.success,
+ "Successfully created role: " + role.getId());
+
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ return dataBinder.getRoleTO(role);
+ }
+
+ @PreAuthorize("hasRole('ROLE_UPDATE')")
+ @RequestMapping(method = RequestMethod.POST, value = "/update")
+ public RoleTO update(@RequestBody final RoleMod roleMod) throws NotFoundException, UnauthorizedRoleException {
+ LOG.debug("Role update called with parameter {}", roleMod);
+
+ SyncopeRole role = dataBinder.getSyncopeRole(roleMod.getId());
+
+ Set<Long> allowedRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
+ if (!allowedRoleIds.contains(role.getId())) {
+ throw new UnauthorizedRoleException(role.getId());
+ }
+
+ dataBinder.update(role, roleMod);
+ role = roleDAO.save(role);
+
+ auditManager.audit(Category.role, RoleSubCategory.update, Result.success,
+ "Successfully updated role: " + role.getId());
+
+ return dataBinder.getRoleTO(role);
+ }
+
+ @PreAuthorize("hasRole('ROLE_DELETE')")
+ @RequestMapping(method = RequestMethod.GET, value = "/delete/{roleId}")
+ public RoleTO delete(@PathVariable("roleId") final Long roleId) throws NotFoundException, UnauthorizedRoleException {
+ SyncopeRole role = dataBinder.getSyncopeRole(roleId);
+
+ RoleTO roleToDelete = dataBinder.getRoleTO(role);
+
+ Set<Long> allowedRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
+ if (!allowedRoleIds.contains(role.getId())) {
+ throw new UnauthorizedRoleException(role.getId());
+ }
+
+ auditManager.audit(Category.role, RoleSubCategory.delete, Result.success,
+ "Successfully deleted role: " + role.getId());
+
+ roleDAO.delete(roleId);
+
+ return roleToDelete;
+ }
+}