Return-Path: X-Original-To: apmail-syncope-commits-archive@www.apache.org Delivered-To: apmail-syncope-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AF4D6E3C9 for ; Fri, 25 Jan 2013 14:19:13 +0000 (UTC) Received: (qmail 75980 invoked by uid 500); 25 Jan 2013 14:19:13 -0000 Delivered-To: apmail-syncope-commits-archive@syncope.apache.org Received: (qmail 75895 invoked by uid 500); 25 Jan 2013 14:19:12 -0000 Mailing-List: contact commits-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list commits@syncope.apache.org Received: (qmail 75858 invoked by uid 99); 25 Jan 2013 14:19:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jan 2013 14:19:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jan 2013 14:19:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0323223888E7; Fri, 25 Jan 2013 14:18:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Fri, 25 Jan 2013 14:18:47 -0000 To: commits@syncope.apache.org From: jbernhardt@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130125141848.0323223888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 list() { + return roleController.list(); + } + + @Override + public List 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 search(final NodeCond searchCondition) { + try { + return roleController.search(searchCondition); + } catch (InvalidSearchConditionException e) { + throw new BadRequestException(e); + } + } + + @Override + public List 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); + } + } + +}