You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by jb...@apache.org on 2013/01/25 15:18:47 UTC
svn commit: r1438530 - in /syncope/trunk:
client/src/main/java/org/apache/syncope/client/services/proxy/
console/src/main/java/org/apache/syncope/console/rest/
core/src/main/java/org/apache/syncope/core/services/
Author: jbernhardt
Date: Fri Jan 25 14:18:47 2013
New Revision: 1438530
URL: http://svn.apache.org/viewvc?rev=1438530&view=rev
Log:
[SYNCOPE-231]
* RoleService
Added:
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/RoleServiceProxy.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/RoleServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/RoleServiceProxy.java?rev=1438530&r1=1438529&r2=1438530&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/RoleServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/RoleServiceProxy.java Fri Jan 25 14:18:47 2013
@@ -56,7 +56,7 @@ public class RoleServiceProxy extends Sp
RoleTO role = getRestTemplate().postForObject(baseUrl + "role/create", roleTO, RoleTO.class);
URI location = URI.create(baseUrl + "role/read/" + role.getId() + ".json");
- return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, role.getId()).build();
+ return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, role.getId()).entity(role).build();
}
@Override
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java?rev=1438530&r1=1438529&r2=1438530&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java Fri Jan 25 14:18:47 2013
@@ -70,7 +70,7 @@ public class RoleRestClient extends Abst
public RoleTO create(final RoleTO roleTO) {
Response response = getService(RoleService.class).create(roleTO);
- return (RoleTO) response.getEntity(); // FIXME after CXF migration
+ return response.readEntity(RoleTO.class);
}
public RoleTO read(final Long id) {
Added: 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=1438530&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java Fri Jan 25 14:18:47 2013
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.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;
+
+import org.apache.syncope.common.SyncopeConstants;
+import org.apache.syncope.common.mod.RoleMod;
+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.propagation.PropagationException;
+import org.apache.syncope.core.rest.controller.RoleController;
+import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
+import org.apache.syncope.core.util.NotFoundException;
+import org.apache.syncope.core.workflow.WorkflowException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RoleServiceImpl implements RoleService, ContextAware {
+
+ @Autowired
+ private RoleController roleController;
+
+ private UriInfo uriInfo;
+
+ @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);
+ }
+ }
+
+ @Override
+ public int count() {
+ return roleController.list().size();
+ }
+
+ @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);
+ }
+ }
+
+ @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);
+ }
+ }
+
+ @Override
+ public List<RoleTO> list() {
+ return roleController.list();
+ }
+
+ @Override
+ public List<RoleTO> list(final int page, final int size) {
+ throw new ServiceUnavailableException();
+ }
+
+ @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);
+ }
+ }
+
+ @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);
+ }
+ }
+
+ @Override
+ public List<RoleTO> search(final NodeCond searchCondition) {
+ try {
+ return roleController.search(searchCondition);
+ } catch (InvalidSearchConditionException e) {
+ throw new BadRequestException(e);
+ }
+ }
+
+ @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);
+ }
+ }
+
+ @Override
+ public int searchCount(final NodeCond searchCondition) {
+ try {
+ return (Integer) roleController.searchCount(searchCondition).getModel().values().iterator().next();
+ } catch (InvalidSearchConditionException e) {
+ throw new BadRequestException(e);
+ }
+ }
+
+ @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);
+ }
+ }
+
+ @Override
+ public void setUriInfo(final UriInfo ui) {
+ this.uriInfo = ui;
+ }
+
+ @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);
+ }
+ }
+
+}