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/09/19 14:24:07 UTC
svn commit: r1524710 [2/3] - 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/to/
common/src/main/java/org/apache/s...
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java Thu Sep 19 12:24:05 2013
@@ -30,7 +30,7 @@ import org.apache.syncope.common.to.Bulk
import org.apache.syncope.common.to.ConnObjectTO;
import org.apache.syncope.common.to.UserTO;
import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.console.commons.StatusBean;
import org.apache.syncope.console.commons.StatusUtils;
import org.springframework.stereotype.Component;
@@ -78,7 +78,7 @@ public class UserRestClient extends Abst
UserTO userTO = null;
try {
userTO = getService(UserService.class).read(id);
- } catch (SyncopeClientCompositeErrorException e) {
+ } catch (SyncopeClientCompositeException e) {
LOG.error("While reading a user", e);
}
return userTO;
@@ -88,7 +88,7 @@ public class UserRestClient extends Abst
UserTO userTO = null;
try {
userTO = getService(UserService.class).read(username);
- } catch (SyncopeClientCompositeErrorException e) {
+ } catch (SyncopeClientCompositeException e) {
LOG.error("While reading a user", e);
}
return userTO;
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java Thu Sep 19 12:24:05 2013
@@ -21,7 +21,7 @@ package org.apache.syncope.console.rest;
import org.apache.syncope.common.services.WorkflowService;
import org.apache.syncope.common.to.WorkflowDefinitionTO;
import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.springframework.stereotype.Component;
@Component
@@ -29,11 +29,11 @@ public class WorkflowRestClient extends
private static final long serialVersionUID = 5049285686167071017L;
- public WorkflowDefinitionTO getDefinition() throws SyncopeClientCompositeErrorException {
+ public WorkflowDefinitionTO getDefinition() throws SyncopeClientCompositeException {
return getService(WorkflowService.class).getDefinition(AttributableType.USER);
}
- public void updateDefinition(final WorkflowDefinitionTO workflowDef) throws SyncopeClientCompositeErrorException {
+ public void updateDefinition(final WorkflowDefinitionTO workflowDef) throws SyncopeClientCompositeException {
getService(WorkflowService.class).updateDefinition(AttributableType.USER, workflowDef);
}
}
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel.java?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/wicket/markup/html/tree/TreeActionLinkPanel.java Thu Sep 19 12:24:05 2013
@@ -19,7 +19,7 @@
package org.apache.syncope.console.wicket.markup.html.tree;
import org.apache.syncope.common.to.RoleTO;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.console.commons.Constants;
import org.apache.syncope.console.commons.XMLRolesReader;
import org.apache.syncope.console.pages.ResultStatusModalPage;
@@ -144,7 +144,7 @@ public class TreeActionLinkPanel extends
});
window.show(target);
- } catch (SyncopeClientCompositeErrorException scce) {
+ } catch (SyncopeClientCompositeException scce) {
error(getString(Constants.OPERATION_ERROR) + ": " + scce.getMessage());
target.add(((Roles) pageRef.getPage()).getFeedbackPanel());
}
Modified: syncope/trunk/console/src/main/resources/applicationContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/applicationContext.xml?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/applicationContext.xml (original)
+++ syncope/trunk/console/src/main/resources/applicationContext.xml Thu Sep 19 12:24:05 2013
@@ -66,52 +66,8 @@ under the License.
<bean id="roleTreeBuilder" class="org.apache.syncope.console.commons.RoleTreeBuilder"/>
- <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
- <property name="depthProperties">
- <bean id="depthProperties" class="org.apache.cxf.staxutils.DocumentDepthProperties">
- <property name="innerElementCountThreshold" value="500"/>
- </bean>
- </property>
- <property name="marshallerProperties">
- <map>
- <entry key="jaxb.formatted.output">
- <value type="java.lang.Boolean">true</value>
- </entry>
- </map>
- </property>
- <property name="collectionWrapperMap">
- <map>
- <entry>
- <key>
- <value>org.apache.syncope.common.to.PolicyTO</value>
- </key>
- <value>policies</value>
- </entry>
- </map>
- </property>
- </bean>
-
- <bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>
-
- <bean id="exceptionMapper" class="org.apache.syncope.client.rest.RestClientExceptionMapper"/>
-
- <bean id="restClientFactory" class="org.apache.syncope.client.rest.RestClientFactoryBean" scope="prototype">
+ <bean id="syncopeClientFactory" class="org.apache.syncope.client.SyncopeClientFactoryBean">
<property name="address" value="${scheme}://${host}:${port}/${rootPath}"/>
- <property name="threadSafe" value="true"/>
- <property name="inheritHeaders" value="true"/>
- <property name="contentType" value="application/json"/>
- <property name="features">
- <list>
- <cxf:logging/>
- </list>
- </property>
- <property name="providers">
- <list>
- <ref bean="jaxbProvider"/>
- <ref bean="jsonProvider"/>
- <ref bean="exceptionMapper"/>
- </list>
- </property>
</bean>
</beans>
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.to.BulkAction;
import org.apache.syncope.common.to.BulkActionRes;
@@ -34,7 +35,7 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.ConnConfPropSchema;
import org.apache.syncope.common.types.ConnConfProperty;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.audit.AuditManager;
import org.apache.syncope.core.persistence.beans.ConnInstance;
@@ -53,7 +54,6 @@ import org.identityconnectors.framework.
import org.identityconnectors.framework.common.objects.ObjectClass;
import org.identityconnectors.framework.impl.api.ConfigurationPropertyImpl;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -89,8 +89,8 @@ public class ConnectorController extends
auditManager.audit(Category.connector, ConnectorSubCategory.create, Result.failure,
"Could not create connector instance: " + connInstanceTO.getDisplayName(), e);
- SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException invalidConnInstance = new SyncopeClientException(
SyncopeClientExceptionType.InvalidConnInstance);
@@ -116,8 +116,8 @@ public class ConnectorController extends
auditManager.audit(Category.connector, ConnectorSubCategory.create, Result.failure,
"Could not update connector instance: " + connInstanceTO.getDisplayName(), e);
- SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException invalidConnInstance = new SyncopeClientException(
SyncopeClientExceptionType.InvalidConnInstance);
@@ -138,8 +138,8 @@ public class ConnectorController extends
}
if (!connInstance.getResources().isEmpty()) {
- SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException associatedResources =
new SyncopeClientException(SyncopeClientExceptionType.AssociatedResources);
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -20,6 +20,7 @@ package org.apache.syncope.core.rest.con
import java.util.ArrayList;
import java.util.List;
+import javax.ws.rs.core.Response;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Logger;
@@ -34,14 +35,13 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.SyncopeClientExceptionType;
import org.apache.syncope.common.types.LoggerLevel;
import org.apache.syncope.common.types.LoggerType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.audit.AuditManager;
import org.apache.syncope.core.persistence.beans.SyncopeLogger;
import org.apache.syncope.core.persistence.dao.LoggerDAO;
import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.apache.syncope.common.util.BeanUtils;
@@ -93,7 +93,8 @@ public class LoggerController extends Ab
}
private void throwInvalidLogger(final LoggerType type) {
- SyncopeClientCompositeErrorException sccee = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException sccee =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.InvalidLogger);
sce.addElement("Expected " + type.name());
@@ -146,8 +147,8 @@ public class LoggerController extends Ab
try {
setLevel(auditLoggerName.toLoggerName(), Level.DEBUG, LoggerType.AUDIT);
} catch (IllegalArgumentException e) {
- SyncopeClientCompositeErrorException sccee =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException sccee =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.InvalidLogger);
sce.addElement(e.getMessage());
@@ -196,8 +197,8 @@ public class LoggerController extends Ab
} catch (NotFoundException e) {
LOG.debug("Ignoring disable of non existing logger {}", auditLoggerName.toLoggerName());
} catch (IllegalArgumentException e) {
- SyncopeClientCompositeErrorException sccee =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException sccee =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.InvalidLogger);
sce.addElement(e.getMessage());
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipInputStream;
+import javax.ws.rs.core.Response;
import org.apache.cocoon.optional.pipeline.components.sax.fop.FopSerializer;
import org.apache.cocoon.pipeline.NonCachingPipeline;
import org.apache.cocoon.pipeline.Pipeline;
@@ -45,7 +46,7 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.ReportExecExportFormat;
import org.apache.syncope.common.types.ReportExecStatus;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.audit.AuditManager;
import org.apache.syncope.core.init.JobInstanceLoader;
@@ -60,7 +61,6 @@ import org.apache.xmlgraphics.util.MimeC
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
@@ -100,8 +100,8 @@ public class ReportController extends Ab
} catch (Exception e) {
LOG.error("While registering quartz job for report " + report.getId(), e);
- SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
sce.addElement(e.getMessage());
scce.addException(sce);
@@ -131,8 +131,8 @@ public class ReportController extends Ab
} catch (Exception e) {
LOG.error("While registering quartz job for report " + report.getId(), e);
- SyncopeClientCompositeErrorException sccee =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException sccee =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
sce.addElement(e.getMessage());
sccee.addException(sce);
@@ -294,8 +294,8 @@ public class ReportController extends Ab
throw new NotFoundException("Report execution " + executionId);
}
if (!ReportExecStatus.SUCCESS.name().equals(reportExec.getStatus()) || reportExec.getExecResult() == null) {
- SyncopeClientCompositeErrorException sccee =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException sccee =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.InvalidReportExec);
sce.addElement(reportExec.getExecResult() == null
? "No report data produced"
@@ -331,8 +331,8 @@ public class ReportController extends Ab
auditManager.audit(Category.report, ReportSubCategory.execute, Result.failure,
"Could not start execution for report: " + report.getId(), e);
- SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
sce.addElement(e.getMessage());
scce.addException(sce);
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -21,6 +21,7 @@ package org.apache.syncope.core.rest.con
import java.util.List;
import java.util.Set;
import javax.persistence.EntityExistsException;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.to.BulkAction;
import org.apache.syncope.common.to.BulkActionRes;
@@ -33,7 +34,7 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.AuditElements.Result;
import org.apache.syncope.common.types.MappingPurpose;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.audit.AuditManager;
import org.apache.syncope.core.connid.ConnObjectUtil;
@@ -59,7 +60,6 @@ import org.identityconnectors.framework.
import org.identityconnectors.framework.common.objects.ObjectClass;
import org.identityconnectors.framework.common.objects.Uid;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -102,8 +102,8 @@ public class ResourceController extends
LOG.debug("Resource creation: {}", resourceTO);
if (StringUtils.isBlank(resourceTO.getName())) {
- SyncopeClientCompositeErrorException sccee =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException sccee =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.RequiredValuesMissing);
sce.addElement("Resource name");
sccee.addException(sce);
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -21,6 +21,7 @@ package org.apache.syncope.core.rest.con
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityExistsException;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.to.AbstractSchemaTO;
import org.apache.syncope.common.to.DerSchemaTO;
@@ -30,7 +31,7 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.AuditElements;
import org.apache.syncope.common.types.SchemaType;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.audit.AuditManager;
import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
@@ -43,7 +44,6 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.rest.data.SchemaDataBinder;
import org.apache.syncope.core.util.AttributableUtil;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
@@ -94,8 +94,8 @@ public class SchemaController extends Ab
final T schemaTO) {
if (StringUtils.isBlank(schemaTO.getName())) {
- SyncopeClientCompositeErrorException sccee =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException sccee =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.RequiredValuesMissing);
sce.addElement("Schema name");
sccee.addException(sce);
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
+import javax.ws.rs.core.Response;
import org.apache.syncope.common.to.BulkAction;
import org.apache.syncope.common.to.BulkActionRes;
import org.apache.syncope.common.to.SchedTaskTO;
@@ -35,7 +36,7 @@ import org.apache.syncope.common.types.P
import org.apache.syncope.common.types.PropagationTaskExecStatus;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
import org.apache.syncope.common.types.TaskType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.audit.AuditManager;
import org.apache.syncope.core.init.ImplementationClassNamesLoader;
@@ -57,7 +58,6 @@ import org.quartz.JobDataMap;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
@@ -106,8 +106,8 @@ public class TaskController extends Abst
} catch (Exception e) {
LOG.error("While registering quartz job for task " + task.getId(), e);
- SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
sce.addElement(e.getMessage());
scce.addException(sce);
@@ -136,7 +136,8 @@ public class TaskController extends Abst
TaskUtil taskUtil = TaskUtil.getInstance(task);
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
binder.updateSchedTask(task, taskTO, taskUtil);
task = taskDAO.save(task);
@@ -284,8 +285,8 @@ public class TaskController extends Abst
auditManager.audit(Category.task, TaskSubCategory.execute, Result.failure,
"Could not start execution for task: " + task.getId() + "/" + taskUtil, e);
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(
- HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
sce.addElement(e.getMessage());
scce.addException(sce);
@@ -344,8 +345,8 @@ public class TaskController extends Abst
}
if (!sce.isEmpty()) {
- SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
scce.addException(sce);
auditManager.audit(Category.task, TaskSubCategory.report, Result.failure,
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java Thu Sep 19 12:24:05 2013
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.RollbackException;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.mod.UserMod;
import org.apache.syncope.common.to.UserRequestTO;
@@ -30,7 +31,7 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.AuditElements.Result;
import org.apache.syncope.common.types.AuditElements.UserRequestSubCategory;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.audit.AuditManager;
import org.apache.syncope.core.persistence.beans.SyncopeConf;
@@ -43,7 +44,6 @@ import org.apache.syncope.core.util.Enti
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -251,14 +251,15 @@ public class UserRequestController {
+ "(hasRole('USER_DELETE') and #request.type == #request.type.DELETE))")
public UserTO execute(final UserRequestTO request, final UserTO reviewed, final UserMod changes) {
UserRequest userRequest = userRequestDAO.find(request.getId());
- if (request == null || request.isExecuted()) {
+ if (request.isExecuted()) {
throw new NotFoundException("Executable user request " + request.getId());
}
if (StringUtils.isBlank(request.getOwner())
|| !request.getOwner().equalsIgnoreCase(EntitlementUtil.getAuthenticatedUsername())) {
- final SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.UNAUTHORIZED);
+
+ final SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.UNAUTHORIZED.getStatusCode());
scce.addException(new SyncopeClientException(SyncopeClientExceptionType.Unauthorized));
throw scce;
}
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -38,7 +38,7 @@ 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.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.beans.AbstractAttrValue;
@@ -370,7 +370,7 @@ public abstract class AbstractAttributab
protected PropagationByResource fill(final AbstractAttributable attributable,
final AbstractAttributableMod attributableMod, final AttributableUtil attrUtil,
- final SyncopeClientCompositeErrorException scce) {
+ final SyncopeClientCompositeException scce) {
PropagationByResource propByRes = new PropagationByResource();
@@ -615,7 +615,7 @@ public abstract class AbstractAttributab
}
protected void fill(final AbstractAttributable attributable, final AbstractAttributableTO attributableTO,
- final AttributableUtil attributableUtil, final SyncopeClientCompositeErrorException scce) {
+ final AttributableUtil attributableUtil, final SyncopeClientCompositeException scce) {
// 1. attributes
SyncopeClientException invalidValues = new SyncopeClientException(SyncopeClientExceptionType.InvalidValues);
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -21,12 +21,13 @@ package org.apache.syncope.core.rest.dat
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import javax.ws.rs.core.Response;
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.SyncopeClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.ConnInstance;
import org.apache.syncope.core.persistence.dao.ConnInstanceDAO;
@@ -34,7 +35,6 @@ import org.apache.syncope.core.util.Conn
import org.identityconnectors.framework.api.ConfigurationProperties;
import org.identityconnectors.framework.impl.api.ConfigurationPropertyImpl;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
@Component
@@ -80,7 +80,8 @@ public class ConnInstanceDataBinder {
}
public ConnInstance getConnInstance(final ConnInstanceTO connInstanceTO) {
- SyncopeClientCompositeErrorException scee = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scee =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException requiredValuesMissing = new SyncopeClientException(
SyncopeClientExceptionType.RequiredValuesMissing);
@@ -127,7 +128,8 @@ public class ConnInstanceDataBinder {
}
public ConnInstance updateConnInstance(final long connInstanceId, final ConnInstanceTO connInstanceTO) {
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException requiredValuesMissing = new SyncopeClientException(
SyncopeClientExceptionType.RequiredValuesMissing);
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.SerializationUtils;
import org.apache.syncope.common.to.MappingItemTO;
import org.apache.syncope.common.to.MappingTO;
@@ -33,7 +34,7 @@ import org.apache.syncope.common.types.C
import org.apache.syncope.common.types.IntMappingType;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.AbstractMapping;
import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
@@ -53,7 +54,6 @@ import org.apache.syncope.core.util.Jexl
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
@Component
@@ -184,7 +184,8 @@ public class ResourceDataBinder {
return null;
}
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException requiredValuesMissing = new SyncopeClientException(
SyncopeClientExceptionType.RequiredValuesMissing);
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -22,12 +22,13 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
+import javax.ws.rs.core.Response;
import org.apache.syncope.common.mod.RoleMod;
import org.apache.syncope.common.to.RoleTO;
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.ResourceOperation;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.connid.ConnObjectUtil;
import org.apache.syncope.core.persistence.beans.AccountPolicy;
@@ -48,7 +49,6 @@ import org.apache.syncope.core.util.Attr
import org.apache.syncope.core.util.EntitlementUtil;
import org.apache.syncope.core.workflow.WorkflowResult;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -114,7 +114,8 @@ public class RoleDataBinder extends Abst
role.setInheritPasswordPolicy(roleTO.isInheritPasswordPolicy());
role.setInheritAccountPolicy(roleTO.isInheritAccountPolicy());
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
// name and parent
SyncopeClientException invalidRoles = new SyncopeClientException(SyncopeClientExceptionType.InvalidRoles);
@@ -192,7 +193,8 @@ public class RoleDataBinder extends Abst
public PropagationByResource update(final SyncopeRole role, final RoleMod roleMod) {
PropagationByResource propByRes = new PropagationByResource();
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
Set<String> currentResources = role.getResourceNames();
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -19,12 +19,13 @@
package org.apache.syncope.core.rest.data;
import java.util.List;
+import javax.ws.rs.core.Response;
import org.apache.syncope.common.to.DerSchemaTO;
import org.apache.syncope.common.to.SchemaTO;
import org.apache.syncope.common.to.VirSchemaTO;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
@@ -34,7 +35,6 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.util.AttributableUtil;
import org.apache.syncope.core.util.JexlUtil;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
@Component
@@ -49,8 +49,8 @@ public class SchemaDataBinder {
// --------------- NORMAL -----------------
private <T extends AbstractSchema> void fill(final T schema, final SchemaTO schemaTO) {
if (!jexlUtil.isExpressionValid(schemaTO.getMandatoryCondition())) {
- SyncopeClientCompositeErrorException scce =
- new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
SyncopeClientException invalidMandatoryCondition = new SyncopeClientException(
SyncopeClientExceptionType.InvalidValues);
@@ -70,7 +70,8 @@ public class SchemaDataBinder {
public <T extends AbstractSchema> void update(final SchemaTO schemaTO, final T schema,
final AttributableUtil attributableUtil) {
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
List<AbstractAttr> attrs = schemaDAO.getAttributes(schema, attributableUtil.attrClass());
if (!attrs.isEmpty()) {
@@ -106,7 +107,8 @@ public class SchemaDataBinder {
// --------------- DERIVED -----------------
private <T extends AbstractDerSchema> T populate(final T derSchema, final DerSchemaTO derSchemaTO) {
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
if (derSchemaTO.getExpression() == null) {
SyncopeClientException requiredValuesMissing = new SyncopeClientException(
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.rest.data;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.to.AbstractAttributableTO;
import org.apache.syncope.common.to.AttributeTO;
@@ -31,7 +32,7 @@ import org.apache.syncope.common.to.User
import org.apache.syncope.common.types.SyncopeClientExceptionType;
import org.apache.syncope.common.types.TaskType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.init.JobInstanceLoader;
import org.apache.syncope.core.persistence.beans.ExternalResource;
@@ -53,7 +54,6 @@ import org.quartz.TriggerKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;
@@ -124,8 +124,8 @@ public class TaskDataBinder {
checkJexl(template, sce);
}
if (!sce.isEmpty()) {
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(
- HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
scce.addException(sce);
throw scce;
}
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -22,6 +22,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Resource;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.mod.MembershipMod;
import org.apache.syncope.common.mod.UserMod;
@@ -34,7 +35,7 @@ import org.apache.syncope.common.types.P
import org.apache.syncope.common.types.ResourceOperation;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
import org.apache.syncope.common.util.BeanUtils;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.connid.ConnObjectUtil;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
@@ -56,7 +57,6 @@ import org.apache.syncope.core.util.Attr
import org.apache.syncope.core.util.EntitlementUtil;
import org.apache.syncope.core.util.PasswordEncoder;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -162,7 +162,7 @@ public class UserDataBinder extends Abst
}
private void setPassword(final SyncopeUser user, final String password,
- final SyncopeClientCompositeErrorException scce) {
+ final SyncopeClientCompositeException scce) {
int passwordHistorySize = 0;
PasswordPolicy policy = policyDAO.getGlobalPasswordPolicy();
@@ -183,7 +183,8 @@ public class UserDataBinder extends Abst
}
public void create(final SyncopeUser user, final UserTO userTO) {
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
// memberships
SyncopeRole role;
@@ -238,7 +239,8 @@ public class UserDataBinder extends Abst
public PropagationByResource update(final SyncopeUser user, final UserMod userMod) {
PropagationByResource propByRes = new PropagationByResource();
- SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+ SyncopeClientCompositeException scce =
+ new SyncopeClientCompositeException(Response.Status.BAD_REQUEST.getStatusCode());
Set<String> currentResources = user.getResourceNames();
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=1524710&r1=1524709&r2=1524710&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 Thu Sep 19 12:24:05 2013
@@ -33,7 +33,7 @@ import org.apache.cxf.jaxrs.client.Respo
import org.apache.syncope.common.services.InvalidSearchConditionException;
import org.apache.syncope.common.types.EntityViolationType;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
import org.apache.syncope.core.persistence.dao.NotFoundException;
@@ -59,8 +59,8 @@ public class RestServiceExceptionMapper
public Response toResponse(final Exception ex) {
LOG.error("Exception thrown by REST method: " + ex.getMessage(), ex);
- if (ex instanceof SyncopeClientCompositeErrorException) {
- return getCompositeExceptionResponse((SyncopeClientCompositeErrorException) ex);
+ if (ex instanceof SyncopeClientCompositeException) {
+ return getCompositeExceptionResponse((SyncopeClientCompositeException) ex);
}
if (ex instanceof AccessDeniedException) {
@@ -114,11 +114,11 @@ public class RestServiceExceptionMapper
"Call of fromResponse() method is not expected in RestServiceExceptionMapper");
}
- private Response getCompositeExceptionResponse(final SyncopeClientCompositeErrorException ex) {
- ResponseBuilder responseBuilder = Response.status(ex.getStatusCode().value());
+ private Response getCompositeExceptionResponse(final SyncopeClientCompositeException ex) {
+ ResponseBuilder responseBuilder = Response.status(ex.getStatusCode());
for (SyncopeClientException sce : ex.getExceptions()) {
responseBuilder.header(
- SyncopeClientCompositeErrorException.EXCEPTION_TYPE_HEADER, sce.getType().getHeaderValue());
+ SyncopeClientCompositeException.EXCEPTION_TYPE_HEADER, sce.getType().getHeaderValue());
for (String attributeName : sce.getElements()) {
responseBuilder.header(sce.getType().getElementHeaderName(), attributeName);
@@ -161,7 +161,7 @@ public class RestServiceExceptionMapper
SyncopeClientExceptionType exType =
SyncopeClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
- builder.header(SyncopeClientCompositeErrorException.EXCEPTION_TYPE_HEADER, exType.getHeaderValue());
+ builder.header(SyncopeClientCompositeException.EXCEPTION_TYPE_HEADER, exType.getHeaderValue());
for (Map.Entry<Class<?>, Set<EntityViolationType>> violation : iee.getViolations().entrySet()) {
for (EntityViolationType violationType : violation.getValue()) {
@@ -207,7 +207,7 @@ public class RestServiceExceptionMapper
final String msg) {
return responseBuilder.header(
- SyncopeClientCompositeErrorException.EXCEPTION_TYPE_HEADER, hType.getHeaderValue()).
+ SyncopeClientCompositeException.EXCEPTION_TYPE_HEADER, hType.getHeaderValue()).
header(hType.getElementHeaderName(), msg).
build();
}
Modified: syncope/trunk/core/src/main/resources/restContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/restContext.xml?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/restContext.xml (original)
+++ syncope/trunk/core/src/main/resources/restContext.xml Thu Sep 19 12:24:05 2013
@@ -53,7 +53,7 @@ under the License.
<map>
<entry>
<key>
- <value>org.apache.syncope.common.to.PolicyTO</value>
+ <value>org.apache.syncope.common.to.AbstractPolicyTO</value>
</key>
<value>policies</value>
</entry>
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Thu Sep 19 12:24:05 2013
@@ -18,7 +18,6 @@
*/
package org.apache.syncope.core.rest;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.UUID;
@@ -28,10 +27,9 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
-import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.http.HttpStatus;
-import org.apache.syncope.client.rest.RestClientExceptionMapper;
-import org.apache.syncope.client.rest.RestClientFactoryBean;
+import org.apache.syncope.client.SyncopeClient;
+import org.apache.syncope.client.SyncopeClientFactoryBean;
import org.apache.syncope.common.mod.AttributeMod;
import org.apache.syncope.common.services.ConfigurationService;
import org.apache.syncope.common.services.ConnectorService;
@@ -56,7 +54,7 @@ import org.apache.syncope.common.to.Role
import org.apache.syncope.common.to.UserTO;
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.types.SchemaType;
-import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,7 +63,7 @@ import org.springframework.test.context.
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:restClientContext.xml", "classpath:testJDBCContext.xml"})
+@ContextConfiguration(locations = {"classpath:testJDBCContext.xml"})
public abstract class AbstractTest {
/**
@@ -77,89 +75,72 @@ public abstract class AbstractTest {
protected static final String ADMIN_PWD = "password";
+ private static final String ADDRESS = "http://localhost:9080/syncope/rest";
+
private static final String ENV_KEY_CONTENT_TYPE = "jaxrsContentType";
- @Autowired
- protected RestClientFactoryBean restClientFactory;
+ protected static SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean().setAddress(ADDRESS);
+
+ protected static SyncopeClient adminClient;
@Autowired
protected DataSource testDataSource;
- protected UserService userService;
+ protected static UserService userService;
- protected UserWorkflowService userWorkflowService;
+ protected static UserWorkflowService userWorkflowService;
- protected RoleService roleService;
+ protected static RoleService roleService;
- protected ResourceService resourceService;
+ protected static ResourceService resourceService;
- protected EntitlementService entitlementService;
+ protected static EntitlementService entitlementService;
- protected ConfigurationService configurationService;
+ protected static ConfigurationService configurationService;
- protected ConnectorService connectorService;
+ protected static ConnectorService connectorService;
- protected LoggerService loggerService;
+ protected static LoggerService loggerService;
- protected ReportService reportService;
+ protected static ReportService reportService;
- protected TaskService taskService;
+ protected static TaskService taskService;
- protected WorkflowService workflowService;
+ protected static WorkflowService workflowService;
- protected NotificationService notificationService;
+ protected static NotificationService notificationService;
- protected SchemaService schemaService;
+ protected static SchemaService schemaService;
- protected UserRequestService userRequestService;
+ protected static UserRequestService userRequestService;
- protected PolicyService policyService;
+ protected static PolicyService policyService;
- @Autowired
- protected RestClientExceptionMapper clientExceptionMapper;
-
- @Before
- public void setup() throws Exception {
+ @BeforeClass
+ public static void setup() {
final String envContentType = System.getProperty(ENV_KEY_CONTENT_TYPE);
if (StringUtils.isNotBlank(envContentType)) {
- restClientFactory.setContentType(envContentType);
+ clientFactory.getRestClientFactoryBean().setContentType(envContentType);
}
- LOG.info("Performing IT with content type {}", restClientFactory.getContentType());
-
- userService = createServiceInstance(UserService.class);
- userWorkflowService = createServiceInstance(UserWorkflowService.class);
- roleService = createServiceInstance(RoleService.class);
- resourceService = createServiceInstance(ResourceService.class);
- entitlementService = createServiceInstance(EntitlementService.class);
- configurationService = createServiceInstance(ConfigurationService.class);
- connectorService = createServiceInstance(ConnectorService.class);
- loggerService = createServiceInstance(LoggerService.class);
- reportService = createServiceInstance(ReportService.class);
- taskService = createServiceInstance(TaskService.class);
- policyService = createServiceInstance(PolicyService.class);
- workflowService = createServiceInstance(WorkflowService.class);
- notificationService = createServiceInstance(NotificationService.class);
- schemaService = createServiceInstance(SchemaService.class);
- userRequestService = createServiceInstance(UserRequestService.class);
- }
-
- protected <T> T createServiceInstance(final Class<T> serviceClass) {
- return restClientFactory.createServiceInstance(serviceClass, ADMIN_UNAME, ADMIN_PWD);
- }
-
- protected <T> T createServiceInstance(final Class<T> serviceClass, final String username, final String password) {
- return restClientFactory.createServiceInstance(serviceClass, username, password);
- }
-
- protected <T> T getObject(final Response response, final Class<T> type, final Object serviceProxy) {
- assertNotNull(response);
- assertNotNull(response.getLocation());
+ LOG.info("Performing IT with content type {}", clientFactory.getContentType().getMediaType());
- String location = response.getLocation().toString();
- WebClient webClient = WebClient.fromClient(WebClient.client(serviceProxy));
- webClient.to(location, false);
+ adminClient = clientFactory.create(ADMIN_UNAME, ADMIN_PWD);
- return webClient.get(type);
+ userService = adminClient.getService(UserService.class);
+ userWorkflowService = adminClient.getService(UserWorkflowService.class);
+ roleService = adminClient.getService(RoleService.class);
+ resourceService = adminClient.getService(ResourceService.class);
+ entitlementService = adminClient.getService(EntitlementService.class);
+ configurationService = adminClient.getService(ConfigurationService.class);
+ connectorService = adminClient.getService(ConnectorService.class);
+ loggerService = adminClient.getService(LoggerService.class);
+ reportService = adminClient.getService(ReportService.class);
+ taskService = adminClient.getService(TaskService.class);
+ policyService = adminClient.getService(PolicyService.class);
+ workflowService = adminClient.getService(WorkflowService.class);
+ notificationService = adminClient.getService(NotificationService.class);
+ schemaService = adminClient.getService(SchemaService.class);
+ userRequestService = adminClient.getService(UserRequestService.class);
}
protected static String getUUIDString() {
@@ -197,7 +178,7 @@ public abstract class AbstractTest {
protected UserTO createUser(final UserTO userTO) {
Response response = userService.create(userTO);
if (response.getStatus() != HttpStatus.SC_CREATED) {
- Exception ex = clientExceptionMapper.fromResponse(response);
+ Exception ex = clientFactory.getExceptionMapper().fromResponse(response);
if (ex != null) {
throw (RuntimeException) ex;
}
@@ -211,46 +192,46 @@ public abstract class AbstractTest {
Response response = schemaService.create(kind, type, schemaTO);
if (response.getStatus() != HttpStatus.SC_CREATED) {
- Exception ex = clientExceptionMapper.fromResponse(response);
+ Exception ex = clientFactory.getExceptionMapper().fromResponse(response);
if (ex != null) {
throw (RuntimeException) ex;
}
}
- return (T) getObject(response, schemaTO.getClass(), schemaService);
+ return (T) adminClient.getObject(response.getLocation(), SchemaService.class, schemaTO.getClass());
}
protected RoleTO createRole(final RoleService roleService, final RoleTO newRoleTO) {
Response response = roleService.create(newRoleTO);
if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
- Exception ex = clientExceptionMapper.fromResponse(response);
+ Exception ex = clientFactory.getExceptionMapper().fromResponse(response);
if (ex != null) {
throw (RuntimeException) ex;
}
}
- return getObject(response, RoleTO.class, roleService);
+ return adminClient.getObject(response.getLocation(), RoleService.class, RoleTO.class);
}
@SuppressWarnings("unchecked")
protected <T extends AbstractPolicyTO> T createPolicy(final T policy) {
Response response = policyService.create(policy);
if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
- Exception ex = clientExceptionMapper.fromResponse(response);
+ Exception ex = clientFactory.getExceptionMapper().fromResponse(response);
if (ex != null) {
throw (RuntimeException) ex;
}
}
- return (T) getObject(response, policy.getClass(), policyService);
+ return (T) adminClient.getObject(response.getLocation(), PolicyService.class, policy.getClass());
}
protected ResourceTO createResource(final ResourceTO resourceTO) {
Response response = resourceService.create(resourceTO);
if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
- Exception ex = clientExceptionMapper.fromResponse(response);
+ Exception ex = clientFactory.getExceptionMapper().fromResponse(response);
if (ex != null) {
throw (RuntimeException) ex;
}
}
- return getObject(response, ResourceTO.class, resourceService);
+ return adminClient.getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java Thu Sep 19 12:24:05 2013
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
import org.apache.syncope.common.search.AttributeCond;
import org.apache.syncope.common.search.NodeCond;
@@ -46,13 +47,11 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.AttributeSchemaType;
import org.apache.syncope.common.types.SchemaType;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.apache.syncope.common.validation.SyncopeClientException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.client.HttpClientErrorException;
@FixMethodOrder(MethodSorters.JVM)
public class AuthenticationTestITCase extends AbstractTest {
@@ -111,8 +110,8 @@ public class AuthenticationTestITCase ex
assertNotNull(schemaTO);
// 4. read the schema created above (as user) - success
- SchemaService schemaService2 = createServiceInstance(SchemaService.class,
- userTO.getUsername(), "password123");
+ SchemaService schemaService2 =
+ clientFactory.create(userTO.getUsername(), "password123").getService(SchemaService.class);
schemaTO = schemaService2.read(AttributableType.USER, SchemaType.NORMAL, schemaName);
assertNotNull(schemaTO);
@@ -121,9 +120,9 @@ public class AuthenticationTestITCase ex
try {
schemaService2.update(AttributableType.ROLE, SchemaType.NORMAL, schemaName, schemaTO);
fail("Schemaupdate as user schould not work");
- } catch (HttpClientErrorException e) {
+ } catch (SyncopeClientCompositeException e) {
assertNotNull(e);
- assertEquals(HttpStatus.FORBIDDEN, e.getStatusCode());
+ assertEquals(HttpStatus.SC_FORBIDDEN, e.getStatusCode());
} catch (AccessControlException e) {
// CXF Service will throw this exception
assertNotNull(e);
@@ -147,18 +146,20 @@ public class AuthenticationTestITCase ex
userTO = createUser(userTO);
assertNotNull(userTO);
- UserService userService2 = createServiceInstance(UserService.class, userTO.getUsername(), "password123");
+ UserService userService2 =
+ clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
UserTO readUserTO = userService2.read(1L);
assertNotNull(readUserTO);
- UserService userService3 = createServiceInstance(UserService.class, "verdi", ADMIN_PWD);
+ UserService userService3 =
+ clientFactory.create("verdi", ADMIN_PWD).getService(UserService.class);
SyncopeClientException exception = null;
try {
userService3.read(1L);
fail();
- } catch (SyncopeClientCompositeErrorException e) {
+ } catch (SyncopeClientCompositeException e) {
exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
}
assertNotNull(exception);
@@ -179,7 +180,8 @@ public class AuthenticationTestITCase ex
userTO = createUser(userTO);
assertNotNull(userTO);
- UserService userService2 = createServiceInstance(UserService.class, userTO.getUsername(), "password123");
+ UserService userService2 =
+ clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
isNullCond.setSchema("loginDate");
@@ -194,7 +196,8 @@ public class AuthenticationTestITCase ex
}
assertTrue(userIds.contains(1L));
- UserService userService3 = createServiceInstance(UserService.class, "verdi", "password");
+ UserService userService3 =
+ clientFactory.create("verdi", "password").getService(UserService.class);
matchedUsers = userService3.search(searchCondition);
@@ -224,17 +227,20 @@ public class AuthenticationTestITCase ex
assertNotNull(userTO);
long userId = userTO.getId();
- UserService userService2 = createServiceInstance(UserService.class, userTO.getUsername(), "password123");
+ UserService userService2 =
+ clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
assertEquals(0, getFailedLogins(userService2, userId));
// authentications failed ...
- UserService userService3 = createServiceInstance(UserService.class, userTO.getUsername(), "wrongpwd1");
+ UserService userService3 =
+ clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
assertReadFails(userService3, userId);
assertReadFails(userService3, userId);
assertEquals(2, getFailedLogins(userService, userId));
- UserService userService4 = createServiceInstance(UserService.class, userTO.getUsername(), "password123");
+ UserService userService4 =
+ clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
assertEquals(0, getFailedLogins(userService4, userId));
}
@@ -254,11 +260,13 @@ public class AuthenticationTestITCase ex
long userId = userTO.getId();
assertNotNull(userTO);
- UserService userService2 = createServiceInstance(UserService.class, userTO.getUsername(), "password123");
+ UserService userService2 =
+ clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
assertEquals(0, getFailedLogins(userService2, userId));
// authentications failed ...
- UserService userService3 = createServiceInstance(UserService.class, userTO.getUsername(), "wrongpwd1");
+ UserService userService3 =
+ clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
assertReadFails(userService3, userId);
assertReadFails(userService3, userId);
assertReadFails(userService3, userId);
@@ -266,7 +274,8 @@ public class AuthenticationTestITCase ex
assertEquals(3, getFailedLogins(userService, userId));
// last authentication before suspension
- userService3 = createServiceInstance(UserService.class, userTO.getUsername(), "wrongpwd1");
+ userService3 =
+ clientFactory.create(userTO.getUsername(), "wrongpwd1").getService(UserService.class);
assertReadFails(userService3, userId);
userTO = userService.read(userTO.getId());
@@ -277,14 +286,16 @@ public class AuthenticationTestITCase ex
assertEquals("suspended", userTO.getStatus());
// Access with correct credentials should fail as user is suspended
- userService2 = createServiceInstance(UserService.class, userTO.getUsername(), "password123");
+ userService2 =
+ clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
assertReadFails(userService2, userId);
userTO = userService.reactivate(userTO.getId());
assertNotNull(userTO);
assertEquals("active", userTO.getStatus());
- userService2 = createServiceInstance(UserService.class, userTO.getUsername(), "password123");
+ userService2 =
+ clientFactory.create(userTO.getUsername(), "password123").getService(UserService.class);
assertEquals(0, getFailedLogins(userService2, userId));
}
@@ -318,7 +329,8 @@ public class AuthenticationTestITCase ex
role1Admin = createUser(role1Admin);
assertNotNull(role1Admin);
- UserService userService2 = createServiceInstance(UserService.class, role1Admin.getUsername(), "password");
+ UserService userService2 =
+ clientFactory.create(role1Admin.getUsername(), "password").getService(UserService.class);
// User with role 1, created by user with child role created above
UserTO role1User = UserTestITCase.getUniqueSampleTO("syncope48user@apache.org");
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java?rev=1524710&r1=1524709&r2=1524710&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java Thu Sep 19 12:24:05 2013
@@ -32,13 +32,14 @@ import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpStatus;
import org.apache.syncope.common.SyncopeConstants;
+import org.apache.syncope.common.services.ConfigurationService;
import org.apache.syncope.common.to.ConfigurationTO;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.client.HttpStatusCodeException;
@FixMethodOrder(MethodSorters.JVM)
public class ConfigurationTestITCase extends AbstractTest {
@@ -51,8 +52,9 @@ public class ConfigurationTestITCase ext
Response response = configurationService.create(configurationTO);
assertNotNull(response);
- assertEquals(org.apache.http.HttpStatus.SC_CREATED, response.getStatus());
- ConfigurationTO newConfigurationTO = getObject(response, ConfigurationTO.class, configurationService);
+ assertEquals(HttpStatus.SC_CREATED, response.getStatus());
+ ConfigurationTO newConfigurationTO =
+ adminClient.getObject(response.getLocation(), ConfigurationService.class, ConfigurationTO.class);
assertEquals(configurationTO, newConfigurationTO);
}
@@ -60,8 +62,8 @@ public class ConfigurationTestITCase ext
public void delete() throws UnsupportedEncodingException {
try {
configurationService.delete("nonExistent");
- } catch (HttpStatusCodeException e) {
- assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
+ } catch (SyncopeClientCompositeException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
}
ConfigurationTO tokenLengthTO = configurationService.read("token.length");
@@ -69,14 +71,15 @@ public class ConfigurationTestITCase ext
configurationService.delete("token.length");
try {
configurationService.read("token.length");
- } catch (HttpStatusCodeException e) {
- assertEquals(e.getStatusCode(), HttpStatus.NOT_FOUND);
+ } catch (SyncopeClientCompositeException e) {
+ assertEquals(HttpStatus.SC_NOT_FOUND, e.getStatusCode());
}
Response response = configurationService.create(tokenLengthTO);
assertNotNull(response);
- assertEquals(org.apache.http.HttpStatus.SC_CREATED, response.getStatus());
- ConfigurationTO newConfigurationTO = getObject(response, ConfigurationTO.class, configurationService);
+ assertEquals(HttpStatus.SC_CREATED, response.getStatus());
+ ConfigurationTO newConfigurationTO =
+ adminClient.getObject(response.getLocation(), ConfigurationService.class, ConfigurationTO.class);
assertEquals(tokenLengthTO, newConfigurationTO);
}
@@ -115,7 +118,7 @@ public class ConfigurationTestITCase ext
public void dbExport() throws IOException {
Response response = configurationService.export();
assertNotNull(response);
- assertEquals(HttpStatus.OK.value(), response.getStatus());
+ assertEquals(HttpStatus.SC_OK, response.getStatus());
String contentType = response.getHeaderString(HttpHeaders.CONTENT_TYPE);
assertTrue(contentType.contains("xml"));
String contentDisposition = response.getHeaderString(SyncopeConstants.CONTENT_DISPOSITION_HEADER);