You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by cs...@apache.org on 2013/01/28 17:18:34 UTC
svn commit: r1439474 -
/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/
Author: cschneider
Date: Mon Jan 28 16:18:34 2013
New Revision: 1439474
URL: http://svn.apache.org/viewvc?rev=1439474&view=rev
Log:
SYNCOPE-231 Removing explicit Exception handling where ExceptionMapper should work
Modified:
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -24,7 +24,6 @@ import java.net.URI;
import java.util.List;
import java.util.Set;
-import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.UriInfo;
@@ -35,7 +34,6 @@ import org.apache.syncope.common.to.Conf
import org.apache.syncope.common.to.MailTemplateTO;
import org.apache.syncope.common.to.ValidatorTO;
import org.apache.syncope.common.util.CollectionWrapper;
-import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
import org.apache.syncope.core.rest.controller.ConfigurationController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -66,11 +64,7 @@ public class ConfigurationServiceImpl im
@Override
public void delete(final String key) {
- try {
- configurationController.delete(key);
- } catch (MissingConfKeyException e) {
- throw new NotFoundException(e);
- }
+ configurationController.delete(key);
}
@Override
@@ -90,20 +84,13 @@ public class ConfigurationServiceImpl im
@Override
public ConfigurationTO read(final String key) {
- try {
- return configurationController.read(null, key);
- } catch (MissingConfKeyException e) {
- throw new NotFoundException(e);
- }
+ return configurationController.read(null, key);
+
}
@Override
public void update(final String key, final ConfigurationTO configurationTO) {
- try {
- configurationController.update(null, configurationTO);
- } catch (MissingConfKeyException e) {
- throw new NotFoundException(e);
- }
+ configurationController.update(null, configurationTO);
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -22,7 +22,6 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.List;
-import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -32,9 +31,6 @@ import org.apache.syncope.common.to.Conn
import org.apache.syncope.common.to.ConnInstanceTO;
import org.apache.syncope.common.to.SchemaTO;
import org.apache.syncope.common.types.ConnConfProperty;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
-import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
-import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.rest.controller.ConnInstanceController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -49,62 +45,38 @@ public class ConnectorServiceImpl implem
@Override
public Response create(final ConnInstanceTO connectorTO) {
- try {
- ConnInstanceTO connector = connectorController.create(new DummyHTTPServletResponse(), connectorTO);
- URI location = uriInfo.getAbsolutePathBuilder().path(connector.getId() + "").build();
- return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, connector.getId()).build();
- } catch (SyncopeClientCompositeErrorException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ ConnInstanceTO connector = connectorController.create(new DummyHTTPServletResponse(), connectorTO);
+ URI location = uriInfo.getAbsolutePathBuilder().path(connector.getId() + "").build();
+ return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, connector.getId()).build();
}
@Override
public void delete(final Long connectorId) {
- try {
- connectorController.delete(connectorId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ connectorController.delete(connectorId);
}
@Override
public List<ConnBundleTO> getBundles(final String lang) {
- try {
- return connectorController.getBundles(lang);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- } catch (MissingConfKeyException e) {
- throw new BadRequestException(e);
- }
+ return connectorController.getBundles(lang);
}
@Override
public List<ConnConfProperty> getConfigurationProperties(final Long connectorId) {
- try {
- return connectorController.getConfigurationProperties(connectorId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return connectorController.getConfigurationProperties(connectorId);
}
@Override
public List<SchemaTO> getSchemaNames(final Long connectorId, final ConnInstanceTO connectorTO,
final boolean showall) {
- try {
- List<String> schemaNames = connectorController.getSchemaNames(new DummyHTTPServletResponse(), connectorTO,
- showall);
- List<SchemaTO> schemas = new ArrayList<SchemaTO>();
- for (String name : schemaNames) {
- SchemaTO schemaTO = new SchemaTO();
- schemaTO.setName(name);
- schemas.add(schemaTO);
- }
- return schemas;
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
+ List<String> schemaNames = connectorController.getSchemaNames(new DummyHTTPServletResponse(), connectorTO,
+ showall);
+ List<SchemaTO> schemas = new ArrayList<SchemaTO>();
+ for (String name : schemaNames) {
+ SchemaTO schemaTO = new SchemaTO();
+ schemaTO.setName(name);
+ schemas.add(schemaTO);
}
+ return schemas;
}
@Override
@@ -114,43 +86,23 @@ public class ConnectorServiceImpl implem
@Override
public ConnInstanceTO read(final Long connectorId) {
- try {
- return connectorController.read(connectorId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return connectorController.read(connectorId);
}
@Override
public ConnInstanceTO readConnectorBean(final String resourceName) {
- try {
- return connectorController.readConnectorBean(resourceName);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return connectorController.readConnectorBean(resourceName);
}
@Override
public void update(final Long connectorId, final ConnInstanceTO connectorTO) {
- try {
- connectorController.update(connectorTO);
- } catch (SyncopeClientCompositeErrorException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ connectorController.update(connectorTO);
}
@Override
public boolean validate(final ConnInstanceTO connectorTO) {
- try {
- return (Boolean) connectorController.check(new DummyHTTPServletResponse(), connectorTO).getModel().values()
- .iterator().next();
- } catch (SyncopeClientCompositeErrorException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return (Boolean) connectorController.check(new DummyHTTPServletResponse(), connectorTO).getModel().values()
+ .iterator().next();
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java Mon Jan 28 16:18:34 2013
@@ -21,6 +21,9 @@ package org.apache.syncope.core.services
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
+/**
+ * While @Context can also be set on fields this variant is needed to make it compatible with spring proxies
+ */
public interface ContextAware {
@Context
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -88,11 +88,7 @@ public class LoggerServiceImpl implement
public void delete(final LoggerType type, final String name) {
switch (type) {
case NORMAL:
- try {
- loggerController.deleteLog(name);
- } catch (org.apache.syncope.core.persistence.dao.NotFoundException e) {
- throw new NotFoundException(e);
- }
+ loggerController.deleteLog(name);
break;
case AUDIT:
try {
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -26,7 +26,6 @@ import javax.ws.rs.core.UriInfo;
import org.apache.syncope.common.services.NotificationService;
import org.apache.syncope.common.to.NotificationTO;
-import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.rest.controller.NotificationController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -41,22 +40,14 @@ public class NotificationServiceImpl imp
@Override
public Response create(final NotificationTO notificationTO) {
- try {
- NotificationTO createdNotificationTO = notificationController.createInternal(notificationTO);
- URI location = uriInfo.getAbsolutePathBuilder().path("" + createdNotificationTO.getId()).build();
- return Response.created(location).build();
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ NotificationTO createdNotificationTO = notificationController.createInternal(notificationTO);
+ URI location = uriInfo.getAbsolutePathBuilder().path("" + createdNotificationTO.getId()).build();
+ return Response.created(location).build();
}
@Override
public NotificationTO read(final Long notificationId) {
- try {
- return notificationController.read(notificationId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return notificationController.read(notificationId);
}
@Override
@@ -65,22 +56,13 @@ public class NotificationServiceImpl imp
}
@Override
- public NotificationTO update(final Long notificationId,
- final NotificationTO notificationTO) {
- try {
- return notificationController.update(notificationTO);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ public NotificationTO update(final Long notificationId, final NotificationTO notificationTO) {
+ return notificationController.update(notificationTO);
}
@Override
public NotificationTO delete(final Long notificationId) {
- try {
- return notificationController.delete(notificationId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return notificationController.delete(notificationId);
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -32,7 +32,6 @@ import org.apache.syncope.common.to.Pass
import org.apache.syncope.common.to.PolicyTO;
import org.apache.syncope.common.to.SyncPolicyTO;
import org.apache.syncope.common.types.PolicyType;
-import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.rest.controller.PolicyController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -70,11 +69,7 @@ public class PolicyServiceImpl implement
@Override
public void delete(final PolicyType type, final Long policyId) {
- try {
- policyController.delete(policyId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ policyController.delete(policyId);
}
@SuppressWarnings("unchecked")
@@ -86,62 +81,50 @@ public class PolicyServiceImpl implement
@SuppressWarnings("unchecked")
@Override
public <T extends PolicyTO> T read(final PolicyType type, final Long policyId) {
- try {
- return (T) policyController.read(policyId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return (T) policyController.read(policyId);
}
@SuppressWarnings("unchecked")
@Override
public <T extends PolicyTO> T readGlobal(final PolicyType type) {
- try {
- switch (type) {
- case ACCOUNT:
- case GLOBAL_ACCOUNT:
- return (T) policyController.getGlobalAccountPolicy();
-
- case PASSWORD:
- case GLOBAL_PASSWORD:
- return (T) policyController.getGlobalPasswordPolicy();
-
- case SYNC:
- case GLOBAL_SYNC:
- return (T) policyController.getGlobalSyncPolicy();
-
- default:
- throw new BadRequestException();
- }
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
+ switch (type) {
+ case ACCOUNT:
+ case GLOBAL_ACCOUNT:
+ return (T) policyController.getGlobalAccountPolicy();
+
+ case PASSWORD:
+ case GLOBAL_PASSWORD:
+ return (T) policyController.getGlobalPasswordPolicy();
+
+ case SYNC:
+ case GLOBAL_SYNC:
+ return (T) policyController.getGlobalSyncPolicy();
+
+ default:
+ throw new BadRequestException();
}
}
@Override
public <T extends PolicyTO> void update(final PolicyType type, final Long policyId, final T policyTO) {
- try {
- switch (type) {
- case ACCOUNT:
- case GLOBAL_ACCOUNT:
- policyController.update((AccountPolicyTO) policyTO);
- break;
-
- case PASSWORD:
- case GLOBAL_PASSWORD:
- policyController.update((PasswordPolicyTO) policyTO);
- break;
-
- case SYNC:
- case GLOBAL_SYNC:
- policyController.update((SyncPolicyTO) policyTO);
- break;
-
- default:
- break;
- }
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
+ switch (type) {
+ case ACCOUNT:
+ case GLOBAL_ACCOUNT:
+ policyController.update((AccountPolicyTO) policyTO);
+ break;
+
+ case PASSWORD:
+ case GLOBAL_PASSWORD:
+ policyController.update((PasswordPolicyTO) policyTO);
+ break;
+
+ case SYNC:
+ case GLOBAL_SYNC:
+ policyController.update((SyncPolicyTO) policyTO);
+ break;
+
+ default:
+ break;
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -28,13 +28,11 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.UriInfo;
-import org.apache.syncope.common.SyncopeConstants;
import org.apache.syncope.common.services.ReportService;
import org.apache.syncope.common.to.ReportExecTO;
import org.apache.syncope.common.to.ReportTO;
import org.apache.syncope.common.types.ReportExecExportFormat;
import org.apache.syncope.core.persistence.beans.ReportExec;
-import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.persistence.dao.ReportDAO;
import org.apache.syncope.core.rest.controller.ReportController;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,29 +40,24 @@ import org.springframework.stereotype.Se
@Service
public class ReportServiceImpl implements ReportService, ContextAware {
-
@Autowired
- private ReportController reportController;
-
+ ReportController reportController;
+
@Autowired
private ReportDAO reportDAO;
-
+
private UriInfo uriInfo;
@Override
public Response create(final ReportTO reportTO) {
ReportTO createdReportTO = reportController.createInternal(reportTO);
URI location = uriInfo.getAbsolutePathBuilder().path("" + createdReportTO.getId()).build();
- return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, createdReportTO.getId()).build();
+ return Response.created(location).build();
}
@Override
public void update(final Long reportId, final ReportTO reportTO) {
- try {
- reportController.update(reportTO);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ reportController.update(reportTO);
}
@Override
@@ -94,65 +87,38 @@ public class ReportServiceImpl implement
@Override
public ReportTO read(final Long reportId) {
- try {
- return reportController.read(reportId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return reportController.read(reportId);
}
@Override
public ReportExecTO readExecution(final Long executionId) {
- try {
- return reportController.readExecution(executionId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return reportController.readExecution(executionId);
}
@Override
public Response exportExecutionResult(final Long executionId, final ReportExecExportFormat fmt) {
- final ReportExecExportFormat format = (fmt == null)
- ? ReportExecExportFormat.XML
- : fmt;
- try {
- final ReportExec reportExec = reportController.getAndCheckReportExecInternal(executionId);
- return Response.ok(new StreamingOutput() {
- @Override
- public void write(final OutputStream os) throws IOException {
- reportController.exportExecutionResultInternal(os, reportExec, format);
- }
- }).build();
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ final ReportExecExportFormat format = (fmt == null) ? ReportExecExportFormat.XML : fmt;
+ final ReportExec reportExec = reportController.getAndCheckReportExecInternal(executionId);
+ return Response.ok(new StreamingOutput() {
+ public void write(final OutputStream os) throws IOException {
+ reportController.exportExecutionResultInternal(os, reportExec, format);
+ }
+ }).build();
}
@Override
public ReportExecTO execute(final Long reportId) {
- try {
- return reportController.execute(reportId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return reportController.execute(reportId);
}
@Override
public void delete(final Long reportId) {
- try {
- reportController.delete(reportId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ reportController.delete(reportId);
}
@Override
public void deleteExecution(final Long executionId) {
- try {
- reportController.deleteExecution(executionId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ reportController.deleteExecution(executionId);
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -22,7 +22,6 @@ import java.net.URI;
import java.util.List;
import java.util.Set;
-import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -33,8 +32,6 @@ import org.apache.syncope.common.to.Prop
import org.apache.syncope.common.to.ResourceTO;
import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.common.util.CollectionWrapper;
-import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
-import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.rest.controller.ResourceController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -49,46 +46,24 @@ public class ResourceServiceImpl impleme
@Override
public Response create(final ResourceTO resourceTO) {
- try {
- ResourceTO resource = resourceController.create(new DummyHTTPServletResponse(), resourceTO);
- URI location = uriInfo.getAbsolutePathBuilder().path(resource.getName()).build();
- return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, resource.getName()).build();
- } catch (SyncopeClientCompositeErrorException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ ResourceTO resource = resourceController.create(new DummyHTTPServletResponse(), resourceTO);
+ URI location = uriInfo.getAbsolutePathBuilder().path(resource.getName()).build();
+ return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, resource.getName()).build();
}
@Override
public void update(final String resourceName, final ResourceTO resourceTO) {
- try {
- resourceController.update(resourceTO);
- } catch (SyncopeClientCompositeErrorException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ resourceController.update(resourceTO);
}
@Override
public void delete(final String resourceName) {
- try {
- resourceController.delete(resourceName);
- } catch (SyncopeClientCompositeErrorException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ resourceController.delete(resourceName);
}
@Override
public ResourceTO read(final String resourceName) {
- try {
- return resourceController.read(resourceName);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return resourceController.read(resourceName);
}
@Override
@@ -101,45 +76,27 @@ public class ResourceServiceImpl impleme
@Override
public List<ResourceTO> list() {
- try {
- return resourceController.list(null);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return resourceController.list(null);
}
@Override
public List<ResourceTO> list(final Long connInstanceId) {
- try {
- return resourceController.list(connInstanceId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return resourceController.list(connInstanceId);
}
@Override
public ConnObjectTO getConnector(final String resourceName, final AttributableType type, final String objectId) {
- try {
- return resourceController.getObject(resourceName, type, objectId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return resourceController.getObject(resourceName, type, objectId);
}
@Override
public boolean check(final ResourceTO resourceTO) {
- try {
- return (Boolean) resourceController.check(new DummyHTTPServletResponse(), resourceTO).getModel().values()
+ return (Boolean) resourceController.check(new DummyHTTPServletResponse(), resourceTO).getModel().values()
.iterator().next();
- } catch (SyncopeClientCompositeErrorException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
}
@Override
- public void setUriInfo(UriInfo ui) {
+ public void setUriInfo(final UriInfo ui) {
this.uriInfo = ui;
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -21,7 +21,6 @@ package org.apache.syncope.core.services
import java.net.URI;
import java.util.List;
-import javax.ws.rs.BadRequestException;
import javax.ws.rs.ServiceUnavailableException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -31,12 +30,7 @@ import org.apache.syncope.common.mod.Rol
import org.apache.syncope.common.search.NodeCond;
import org.apache.syncope.common.services.RoleService;
import org.apache.syncope.common.to.RoleTO;
-import org.apache.syncope.core.persistence.dao.InvalidSearchConditionException;
-import org.apache.syncope.core.persistence.dao.NotFoundException;
-import org.apache.syncope.core.propagation.PropagationException;
import org.apache.syncope.core.rest.controller.RoleController;
-import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
-import org.apache.syncope.core.workflow.WorkflowException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -50,13 +44,7 @@ public class RoleServiceImpl implements
@Override
public List<RoleTO> children(final Long roleId) {
- try {
- return roleController.children(roleId);
- } catch (UnauthorizedRoleException e) {
- throw new javax.ws.rs.NotAuthorizedException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return roleController.children(roleId);
}
@Override
@@ -66,31 +54,15 @@ public class RoleServiceImpl implements
@Override
public Response create(final RoleTO roleTO) {
- try {
- RoleTO created = roleController.create(new DummyHTTPServletResponse(), roleTO);
- URI location = uriInfo.getAbsolutePathBuilder().path(created.getId() + "").build();
- return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, created.getId()).entity(created)
- .build();
- } catch (UnauthorizedRoleException e) {
- throw new javax.ws.rs.NotAuthorizedException(e);
- } catch (WorkflowException e) {
- throw new BadRequestException(e);
- } catch (PropagationException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ RoleTO created = roleController.create(new DummyHTTPServletResponse(), roleTO);
+ URI location = uriInfo.getAbsolutePathBuilder().path(created.getId() + "").build();
+ return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, created.getId()).entity(created)
+ .build();
}
@Override
public RoleTO delete(final Long roleId) {
- try {
- return roleController.delete(roleId);
- } catch (UnauthorizedRoleException e) {
- throw new javax.ws.rs.NotAuthorizedException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return roleController.delete(roleId);
}
@Override
@@ -105,62 +77,32 @@ public class RoleServiceImpl implements
@Override
public RoleTO parent(final Long roleId) {
- try {
- return roleController.parent(roleId);
- } catch (UnauthorizedRoleException e) {
- throw new javax.ws.rs.NotAuthorizedException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return roleController.parent(roleId);
}
@Override
public RoleTO read(final Long roleId) {
- try {
- return roleController.read(roleId);
- } catch (UnauthorizedRoleException e) {
- throw new javax.ws.rs.NotAuthorizedException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return roleController.read(roleId);
}
@Override
public List<RoleTO> search(final NodeCond searchCondition) {
- try {
- return roleController.search(searchCondition);
- } catch (InvalidSearchConditionException e) {
- throw new BadRequestException(e);
- }
+ return roleController.search(searchCondition);
}
@Override
public List<RoleTO> search(final NodeCond searchCondition, final int page, final int size) {
- try {
- return roleController.search(searchCondition, page, size);
- } catch (InvalidSearchConditionException e) {
- throw new BadRequestException(e);
- }
+ return roleController.search(searchCondition, page, size);
}
@Override
public int searchCount(final NodeCond searchCondition) {
- try {
- return (Integer) roleController.searchCount(searchCondition).getModel().values().iterator().next();
- } catch (InvalidSearchConditionException e) {
- throw new BadRequestException(e);
- }
+ return (Integer) roleController.searchCount(searchCondition).getModel().values().iterator().next();
}
@Override
public RoleTO selfRead(final Long roleId) {
- try {
- return roleController.selfRead(roleId);
- } catch (UnauthorizedRoleException e) {
- throw new javax.ws.rs.NotAuthorizedException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return roleController.selfRead(roleId);
}
@Override
@@ -170,17 +112,7 @@ public class RoleServiceImpl implements
@Override
public RoleTO update(final Long roleId, final RoleMod roleMod) {
- try {
- return roleController.update(roleMod);
- } catch (UnauthorizedRoleException e) {
- throw new javax.ws.rs.NotAuthorizedException(e);
- } catch (WorkflowException e) {
- throw new BadRequestException(e);
- } catch (PropagationException e) {
- throw new BadRequestException(e);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ return roleController.update(roleMod);
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -20,6 +20,7 @@ package org.apache.syncope.core.services
import java.net.URI;
import java.util.List;
+
import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -31,7 +32,6 @@ import org.apache.syncope.common.to.Deri
import org.apache.syncope.common.to.SchemaTO;
import org.apache.syncope.common.to.VirtualSchemaTO;
import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.rest.controller.DerivedSchemaController;
import org.apache.syncope.core.rest.controller.SchemaController;
import org.apache.syncope.core.rest.controller.VirtualSchemaController;
@@ -81,29 +81,24 @@ public class SchemaServiceImpl implement
@Override
public void delete(final AttributableType kind, final SchemaType type, final String schemaName) {
- try {
- switch (type) {
- case NORMAL:
- normalSchemaController.delete(kind.toString(), schemaName);
- break;
-
- case DERIVED:
- derivedSchemaController.delete(kind.toString(), schemaName);
- break;
-
- case VIRTUAL:
- virtualSchemaController.delete(kind.toString(), schemaName);
- break;
-
- default:
- throw new BadRequestException();
- }
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
+ switch (type) {
+ case NORMAL:
+ normalSchemaController.delete(kind.toString(), schemaName);
+ break;
+
+ case DERIVED:
+ derivedSchemaController.delete(kind.toString(), schemaName);
+ break;
+
+ case VIRTUAL:
+ virtualSchemaController.delete(kind.toString(), schemaName);
+ break;
+
+ default:
+ throw new BadRequestException();
}
}
- @SuppressWarnings("unchecked")
@Override
public List<? extends AbstractSchemaTO> list(final AttributableType kind, final SchemaType type) {
switch (type) {
@@ -125,47 +120,39 @@ public class SchemaServiceImpl implement
@Override
public <T extends AbstractSchemaTO> T read(final AttributableType kind, final SchemaType type,
final String schemaName) {
- try {
- switch (type) {
- case NORMAL:
- return (T) normalSchemaController.read(kind.toString(), schemaName);
-
- case DERIVED:
- return (T) derivedSchemaController.read(kind.toString(), schemaName);
-
- case VIRTUAL:
- return (T) virtualSchemaController.read(kind.toString(), schemaName);
-
- default:
- throw new BadRequestException();
- }
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
+ switch (type) {
+ case NORMAL:
+ return (T) normalSchemaController.read(kind.toString(), schemaName);
+
+ case DERIVED:
+ return (T) derivedSchemaController.read(kind.toString(), schemaName);
+
+ case VIRTUAL:
+ return (T) virtualSchemaController.read(kind.toString(), schemaName);
+
+ default:
+ throw new BadRequestException();
}
}
@Override
public <T extends AbstractSchemaTO> void update(final AttributableType kind, final SchemaType type,
final String schemaName, final T schemaTO) {
- try {
- switch (type) {
- case NORMAL:
- normalSchemaController.update((SchemaTO) schemaTO, kind.toString());
- break;
-
- case DERIVED:
- derivedSchemaController.update((DerivedSchemaTO) schemaTO, kind.toString());
- break;
-
- case VIRTUAL:
- virtualSchemaController.update((VirtualSchemaTO) schemaTO, kind.toString());
- break;
-
- default:
- throw new BadRequestException();
- }
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
+ switch (type) {
+ case NORMAL:
+ normalSchemaController.update((SchemaTO) schemaTO, kind.toString());
+ break;
+
+ case DERIVED:
+ derivedSchemaController.update((DerivedSchemaTO) schemaTO, kind.toString());
+ break;
+
+ case VIRTUAL:
+ virtualSchemaController.update((VirtualSchemaTO) schemaTO, kind.toString());
+ break;
+
+ default:
+ throw new BadRequestException();
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java?rev=1439474&r1=1439473&r2=1439474&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java Mon Jan 28 16:18:34 2013
@@ -21,14 +21,12 @@ package org.apache.syncope.core.services
import java.net.URI;
import java.util.List;
-import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.syncope.common.services.UserRequestService;
import org.apache.syncope.common.to.UserRequestTO;
import org.apache.syncope.common.types.UserRequestType;
-import org.apache.syncope.core.persistence.dao.NotFoundException;
import org.apache.syncope.core.rest.controller.UserRequestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -53,21 +51,17 @@ public class UserRequestServiceImpl impl
}
@Override
- public Response create(UserRequestTO userRequestTO) {
- try {
- UserRequestTO outUserRequestTO = null;
- if (userRequestTO.getType() == UserRequestType.CREATE) {
- outUserRequestTO = userRequestController.create(userRequestTO.getUserTO());
- } else if (userRequestTO.getType() == UserRequestType.UPDATE) {
- outUserRequestTO = userRequestController.update(userRequestTO.getUserMod());
- } else if (userRequestTO.getType() == UserRequestType.DELETE) {
- userRequestController.delete(userRequestTO.getUserId());
- }
- URI location = uriInfo.getAbsolutePathBuilder().path("" + outUserRequestTO.getId()).build();
- return Response.created(location).entity(outUserRequestTO).build();
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
+ public Response create(final UserRequestTO userRequestTO) {
+ UserRequestTO outUserRequestTO = null;
+ if (userRequestTO.getType() == UserRequestType.CREATE) {
+ outUserRequestTO = userRequestController.create(userRequestTO.getUserTO());
+ } else if (userRequestTO.getType() == UserRequestType.UPDATE) {
+ outUserRequestTO = userRequestController.update(userRequestTO.getUserMod());
+ } else if (userRequestTO.getType() == UserRequestType.DELETE) {
+ userRequestController.delete(userRequestTO.getUserId());
}
+ URI location = uriInfo.getAbsolutePathBuilder().path("" + outUserRequestTO.getId()).build();
+ return Response.created(location).entity(outUserRequestTO).build();
}
@Override
@@ -76,25 +70,17 @@ public class UserRequestServiceImpl impl
}
@Override
- public UserRequestTO read(@PathParam("requestId") Long requestId) {
- try {
- return userRequestController.read(requestId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ public UserRequestTO read(final Long requestId) {
+ return userRequestController.read(requestId);
}
@Override
- public void delete(@PathParam("requestId") Long requestId) {
- try {
- userRequestController.deleteRequest(requestId);
- } catch (NotFoundException e) {
- throw new javax.ws.rs.NotFoundException(e);
- }
+ public void delete(final Long requestId) {
+ userRequestController.deleteRequest(requestId);
}
@Override
- public void setUriInfo(UriInfo uriInfo) {
+ public void setUriInfo(final UriInfo uriInfo) {
this.uriInfo = uriInfo;
}