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=1615910&r1=1615909&r2=1615910&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 Tue Aug 5 11:20:00 2014 @@ -1,116 +1,116 @@ -/* - * 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.text.ParseException; -import java.util.List; - -import javax.ws.rs.BadRequestException; -import javax.ws.rs.NotFoundException; - -import org.apache.syncope.common.services.LoggerService; -import org.apache.syncope.common.to.EventCategoryTO; -import org.apache.syncope.common.to.LoggerTO; -import org.apache.syncope.common.types.AuditLoggerName; -import org.apache.syncope.common.types.LoggerType; -import org.apache.syncope.common.util.CollectionWrapper; -import org.apache.syncope.core.rest.controller.LoggerController; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class LoggerServiceImpl extends AbstractServiceImpl implements LoggerService { - - @Autowired - private LoggerController controller; - - @Override - public void delete(final LoggerType type, final String name) { - switch (type) { - case LOG: - controller.deleteLog(name); - break; - - case AUDIT: - try { - controller.disableAudit(AuditLoggerName.fromLoggerName(name)); - } catch (IllegalArgumentException e) { - throw new BadRequestException(e); - } catch (ParseException e) { - throw new BadRequestException(e); - } - break; - - default: - throw new BadRequestException(); - } - - } - - @Override - public List<LoggerTO> list(final LoggerType type) { - switch (type) { - case LOG: - return controller.listLogs(); - - case AUDIT: - List<AuditLoggerName> auditLogger = controller.listAudits(); - return CollectionWrapper.unwrapLogger(auditLogger); - - default: - throw new BadRequestException(); - } - } - - @Override - public LoggerTO read(final LoggerType type, final String name) { - List<LoggerTO> logger = list(type); - for (LoggerTO l : logger) { - if (l.getName().equals(name)) { - return l; - } - } - throw new NotFoundException(); - } - - @Override - public void update(final LoggerType type, final String name, final LoggerTO logger) { - switch (type) { - case LOG: - controller.setLogLevel(name, logger.getLevel().getLevel()); - break; - - case AUDIT: - try { - controller.enableAudit(AuditLoggerName.fromLoggerName(name)); - } catch (Exception e) { - throw new BadRequestException(e); - } - break; - - default: - throw new BadRequestException(); - } - } - - @Override - public List<EventCategoryTO> events() { - return controller.listAuditEvents(); - } -} +/* + * 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.text.ParseException; +import java.util.List; + +import javax.ws.rs.BadRequestException; +import javax.ws.rs.NotFoundException; + +import org.apache.syncope.common.services.LoggerService; +import org.apache.syncope.common.to.EventCategoryTO; +import org.apache.syncope.common.to.LoggerTO; +import org.apache.syncope.common.types.AuditLoggerName; +import org.apache.syncope.common.types.LoggerType; +import org.apache.syncope.common.util.CollectionWrapper; +import org.apache.syncope.core.rest.controller.LoggerController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class LoggerServiceImpl extends AbstractServiceImpl implements LoggerService { + + @Autowired + private LoggerController controller; + + @Override + public void delete(final LoggerType type, final String name) { + switch (type) { + case LOG: + controller.deleteLog(name); + break; + + case AUDIT: + try { + controller.disableAudit(AuditLoggerName.fromLoggerName(name)); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e); + } catch (ParseException e) { + throw new BadRequestException(e); + } + break; + + default: + throw new BadRequestException(); + } + + } + + @Override + public List<LoggerTO> list(final LoggerType type) { + switch (type) { + case LOG: + return controller.listLogs(); + + case AUDIT: + List<AuditLoggerName> auditLogger = controller.listAudits(); + return CollectionWrapper.unwrapLogger(auditLogger); + + default: + throw new BadRequestException(); + } + } + + @Override + public LoggerTO read(final LoggerType type, final String name) { + List<LoggerTO> logger = list(type); + for (LoggerTO l : logger) { + if (l.getName().equals(name)) { + return l; + } + } + throw new NotFoundException(); + } + + @Override + public void update(final LoggerType type, final String name, final LoggerTO logger) { + switch (type) { + case LOG: + controller.setLogLevel(name, logger.getLevel().getLevel()); + break; + + case AUDIT: + try { + controller.enableAudit(AuditLoggerName.fromLoggerName(name)); + } catch (Exception e) { + throw new BadRequestException(e); + } + break; + + default: + throw new BadRequestException(); + } + } + + @Override + public List<EventCategoryTO> events() { + return controller.listAuditEvents(); + } +}
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=1615910&r1=1615909&r2=1615910&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 Tue Aug 5 11:20:00 2014 @@ -1,125 +1,125 @@ -/* - * 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.core.Response; -import org.apache.syncope.common.services.PolicyService; -import org.apache.syncope.common.to.AccountPolicyTO; -import org.apache.syncope.common.wrap.CorrelationRuleClass; -import org.apache.syncope.common.to.PasswordPolicyTO; -import org.apache.syncope.common.to.AbstractPolicyTO; -import org.apache.syncope.common.to.SyncPolicyTO; -import org.apache.syncope.common.types.RESTHeaders; -import org.apache.syncope.common.types.PolicyType; -import org.apache.syncope.common.util.CollectionWrapper; -import org.apache.syncope.core.rest.controller.PolicyController; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class PolicyServiceImpl extends AbstractServiceImpl implements PolicyService { - - @Autowired - private PolicyController policyController; - - @Override - public <T extends AbstractPolicyTO> Response create(final T policyTO) { - AbstractPolicyTO policy = policyController.create(policyTO); - URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(policy.getId())).build(); - return Response.created(location). - header(RESTHeaders.RESOURCE_ID.toString(), policy.getId()). - build(); - } - - @Override - public void delete(final Long policyId) { - policyController.delete(policyId); - } - - @Override - public <T extends AbstractPolicyTO> List<T> list(final PolicyType type) { - return policyController.list(type); - } - - @Override - public <T extends AbstractPolicyTO> T read(final Long policyId) { - return policyController.read(policyId); - } - - @SuppressWarnings("unchecked") - @Override - public <T extends AbstractPolicyTO> T readGlobal(final PolicyType type) { - T result = null; - - switch (type) { - case ACCOUNT: - case GLOBAL_ACCOUNT: - result = (T) policyController.getGlobalAccountPolicy(); - break; - - case PASSWORD: - case GLOBAL_PASSWORD: - result = (T) policyController.getGlobalPasswordPolicy(); - break; - - case SYNC: - case GLOBAL_SYNC: - result = (T) policyController.getGlobalSyncPolicy(); - break; - - default: - throw new BadRequestException(); - } - - return result; - } - - @Override - public <T extends AbstractPolicyTO> void update(final Long policyId, final T policyTO) { - policyTO.setId(policyId); - - switch (policyTO.getType()) { - 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; - } - } - - @Override - public List<CorrelationRuleClass> getSyncCorrelationRuleClasses() { - return CollectionWrapper.wrap(policyController.getSyncCorrelationRuleClasses(), CorrelationRuleClass.class); - } -} +/* + * 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.core.Response; +import org.apache.syncope.common.services.PolicyService; +import org.apache.syncope.common.to.AccountPolicyTO; +import org.apache.syncope.common.wrap.CorrelationRuleClass; +import org.apache.syncope.common.to.PasswordPolicyTO; +import org.apache.syncope.common.to.AbstractPolicyTO; +import org.apache.syncope.common.to.SyncPolicyTO; +import org.apache.syncope.common.types.RESTHeaders; +import org.apache.syncope.common.types.PolicyType; +import org.apache.syncope.common.util.CollectionWrapper; +import org.apache.syncope.core.rest.controller.PolicyController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class PolicyServiceImpl extends AbstractServiceImpl implements PolicyService { + + @Autowired + private PolicyController policyController; + + @Override + public <T extends AbstractPolicyTO> Response create(final T policyTO) { + AbstractPolicyTO policy = policyController.create(policyTO); + URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(policy.getId())).build(); + return Response.created(location). + header(RESTHeaders.RESOURCE_ID.toString(), policy.getId()). + build(); + } + + @Override + public void delete(final Long policyId) { + policyController.delete(policyId); + } + + @Override + public <T extends AbstractPolicyTO> List<T> list(final PolicyType type) { + return policyController.list(type); + } + + @Override + public <T extends AbstractPolicyTO> T read(final Long policyId) { + return policyController.read(policyId); + } + + @SuppressWarnings("unchecked") + @Override + public <T extends AbstractPolicyTO> T readGlobal(final PolicyType type) { + T result = null; + + switch (type) { + case ACCOUNT: + case GLOBAL_ACCOUNT: + result = (T) policyController.getGlobalAccountPolicy(); + break; + + case PASSWORD: + case GLOBAL_PASSWORD: + result = (T) policyController.getGlobalPasswordPolicy(); + break; + + case SYNC: + case GLOBAL_SYNC: + result = (T) policyController.getGlobalSyncPolicy(); + break; + + default: + throw new BadRequestException(); + } + + return result; + } + + @Override + public <T extends AbstractPolicyTO> void update(final Long policyId, final T policyTO) { + policyTO.setId(policyId); + + switch (policyTO.getType()) { + 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; + } + } + + @Override + public List<CorrelationRuleClass> getSyncCorrelationRuleClasses() { + return CollectionWrapper.wrap(policyController.getSyncCorrelationRuleClasses(), CorrelationRuleClass.class); + } +} 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=1615910&r1=1615909&r2=1615910&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 Tue Aug 5 11:20:00 2014 @@ -1,151 +1,151 @@ -/* - * 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.Collections; -import java.util.List; -import java.util.Set; -import javax.ws.rs.core.Response; -import org.apache.syncope.common.reqres.BulkAction; -import org.apache.syncope.common.reqres.BulkActionResult; -import org.apache.syncope.common.services.ResourceService; -import org.apache.syncope.common.to.AbstractAttributableTO; -import org.apache.syncope.common.to.ConnObjectTO; -import org.apache.syncope.common.to.ResourceTO; -import org.apache.syncope.common.types.RESTHeaders; -import org.apache.syncope.common.types.ResourceDeassociationActionType; -import org.apache.syncope.common.types.SubjectType; -import org.apache.syncope.common.util.CollectionWrapper; -import org.apache.syncope.common.wrap.PropagationActionClass; -import org.apache.syncope.common.wrap.SubjectId; -import org.apache.syncope.core.rest.controller.AbstractResourceAssociator; -import org.apache.syncope.core.rest.controller.ResourceController; -import org.apache.syncope.core.rest.controller.RoleController; -import org.apache.syncope.core.rest.controller.UserController; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ResourceServiceImpl extends AbstractServiceImpl implements ResourceService { - - @Autowired - private ResourceController controller; - - @Autowired - private UserController userController; - - @Autowired - private RoleController roleController; - - @Override - public Response create(final ResourceTO resourceTO) { - ResourceTO created = controller.create(resourceTO); - URI location = uriInfo.getAbsolutePathBuilder().path(created.getName()).build(); - return Response.created(location). - header(RESTHeaders.RESOURCE_ID, created.getName()). - build(); - } - - @Override - public void update(final String resourceName, final ResourceTO resourceTO) { - resourceTO.setName(resourceName); - controller.update(resourceTO); - } - - @Override - public void delete(final String resourceName) { - controller.delete(resourceName); - } - - @Override - public ResourceTO read(final String resourceName) { - return controller.read(resourceName); - } - - @Override - public List<PropagationActionClass> getPropagationActionsClasses() { - return CollectionWrapper.wrap(controller.getPropagationActionsClasses(), PropagationActionClass.class); - } - - @Override - public List<ResourceTO> list() { - return controller.list(null); - } - - @Override - public List<ResourceTO> list(final Long connInstanceId) { - return controller.list(connInstanceId); - } - - @Override - public ConnObjectTO getConnectorObject(final String resourceName, final SubjectType type, final Long id) { - return controller.getConnectorObject(resourceName, type, id); - } - - @Override - public boolean check(final ResourceTO resourceTO) { - return controller.check(resourceTO); - } - - @Override - public BulkActionResult bulk(final BulkAction bulkAction) { - return controller.bulk(bulkAction); - } - - @Override - public BulkActionResult bulkDeassociation(final String resourceName, final SubjectType subjectType, - final ResourceDeassociationActionType type, final List<SubjectId> subjectIds) { - - AbstractResourceAssociator<? extends AbstractAttributableTO> associator = subjectType == SubjectType.USER - ? userController - : roleController; - - final BulkActionResult res = new BulkActionResult(); - - for (SubjectId id : subjectIds) { - final Set<String> resources = Collections.singleton(resourceName); - try { - switch (type) { - case DEPROVISION: - associator.deprovision(id.getElement(), resources); - break; - - case UNASSIGN: - associator.unassign(id.getElement(), resources); - break; - - case UNLINK: - associator.unlink(id.getElement(), resources); - break; - - default: - } - - res.add(id, BulkActionResult.Status.SUCCESS); - } catch (Exception e) { - LOG.warn("While executing {} on {} {}", type, subjectType, id.getElement(), e); - res.add(id, BulkActionResult.Status.FAILURE); - } - } - - return res; - } - -} +/* + * 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.Collections; +import java.util.List; +import java.util.Set; +import javax.ws.rs.core.Response; +import org.apache.syncope.common.reqres.BulkAction; +import org.apache.syncope.common.reqres.BulkActionResult; +import org.apache.syncope.common.services.ResourceService; +import org.apache.syncope.common.to.AbstractAttributableTO; +import org.apache.syncope.common.to.ConnObjectTO; +import org.apache.syncope.common.to.ResourceTO; +import org.apache.syncope.common.types.RESTHeaders; +import org.apache.syncope.common.types.ResourceDeassociationActionType; +import org.apache.syncope.common.types.SubjectType; +import org.apache.syncope.common.util.CollectionWrapper; +import org.apache.syncope.common.wrap.PropagationActionClass; +import org.apache.syncope.common.wrap.SubjectId; +import org.apache.syncope.core.rest.controller.AbstractResourceAssociator; +import org.apache.syncope.core.rest.controller.ResourceController; +import org.apache.syncope.core.rest.controller.RoleController; +import org.apache.syncope.core.rest.controller.UserController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ResourceServiceImpl extends AbstractServiceImpl implements ResourceService { + + @Autowired + private ResourceController controller; + + @Autowired + private UserController userController; + + @Autowired + private RoleController roleController; + + @Override + public Response create(final ResourceTO resourceTO) { + ResourceTO created = controller.create(resourceTO); + URI location = uriInfo.getAbsolutePathBuilder().path(created.getName()).build(); + return Response.created(location). + header(RESTHeaders.RESOURCE_ID, created.getName()). + build(); + } + + @Override + public void update(final String resourceName, final ResourceTO resourceTO) { + resourceTO.setName(resourceName); + controller.update(resourceTO); + } + + @Override + public void delete(final String resourceName) { + controller.delete(resourceName); + } + + @Override + public ResourceTO read(final String resourceName) { + return controller.read(resourceName); + } + + @Override + public List<PropagationActionClass> getPropagationActionsClasses() { + return CollectionWrapper.wrap(controller.getPropagationActionsClasses(), PropagationActionClass.class); + } + + @Override + public List<ResourceTO> list() { + return controller.list(null); + } + + @Override + public List<ResourceTO> list(final Long connInstanceId) { + return controller.list(connInstanceId); + } + + @Override + public ConnObjectTO getConnectorObject(final String resourceName, final SubjectType type, final Long id) { + return controller.getConnectorObject(resourceName, type, id); + } + + @Override + public boolean check(final ResourceTO resourceTO) { + return controller.check(resourceTO); + } + + @Override + public BulkActionResult bulk(final BulkAction bulkAction) { + return controller.bulk(bulkAction); + } + + @Override + public BulkActionResult bulkDeassociation(final String resourceName, final SubjectType subjectType, + final ResourceDeassociationActionType type, final List<SubjectId> subjectIds) { + + AbstractResourceAssociator<? extends AbstractAttributableTO> associator = subjectType == SubjectType.USER + ? userController + : roleController; + + final BulkActionResult res = new BulkActionResult(); + + for (SubjectId id : subjectIds) { + final Set<String> resources = Collections.singleton(resourceName); + try { + switch (type) { + case DEPROVISION: + associator.deprovision(id.getElement(), resources); + break; + + case UNASSIGN: + associator.unassign(id.getElement(), resources); + break; + + case UNLINK: + associator.unlink(id.getElement(), resources); + break; + + default: + } + + res.add(id, BulkActionResult.Status.SUCCESS); + } catch (Exception e) { + LOG.warn("While executing {} on {} {}", type, subjectType, id.getElement(), e); + res.add(id, BulkActionResult.Status.FAILURE); + } + } + + return res; + } + +} 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=1615910&r1=1615909&r2=1615910&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 Tue Aug 5 11:20:00 2014 @@ -1,222 +1,222 @@ -/* - * 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.util.List; - -import javax.ws.rs.core.Response; -import org.apache.syncope.common.mod.RoleMod; -import org.apache.syncope.common.reqres.BulkActionResult; -import org.apache.syncope.common.services.RoleService; -import org.apache.syncope.common.reqres.PagedResult; -import org.apache.syncope.common.to.PropagationStatus; -import org.apache.syncope.common.wrap.ResourceName; -import org.apache.syncope.common.to.RoleTO; -import org.apache.syncope.common.types.ResourceAssociationActionType; -import org.apache.syncope.common.types.ResourceDeassociationActionType; -import org.apache.syncope.common.util.CollectionWrapper; -import org.apache.syncope.core.persistence.dao.search.OrderByClause; -import org.apache.syncope.core.persistence.dao.search.SearchCond; -import org.apache.syncope.core.rest.controller.RoleController; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class RoleServiceImpl extends AbstractServiceImpl implements RoleService { - - @Autowired - private RoleController controller; - - @Override - public List<RoleTO> children(final Long roleId) { - return controller.children(roleId); - } - - @Override - public Response create(final RoleTO roleTO) { - RoleTO created = controller.create(roleTO); - return createResponse(created.getId(), created); - } - - @Override - public Response delete(final Long roleId) { - RoleTO role = controller.read(roleId); - - checkETag(role.getETagValue()); - - RoleTO deleted = controller.delete(roleId); - return modificationResponse(deleted); - } - - @Override - public PagedResult<RoleTO> list() { - return list(DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, null); - } - - @Override - public PagedResult<RoleTO> list(final String orderBy) { - return list(DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, orderBy); - } - - @Override - public PagedResult<RoleTO> list(final Integer page, final Integer size) { - return list(page, size, null); - } - - @Override - public PagedResult<RoleTO> list(final Integer page, final Integer size, final String orderBy) { - List<OrderByClause> orderByClauses = getOrderByClauses(orderBy); - return buildPagedResult(controller.list(page, size, orderByClauses), page, size, controller.count()); - } - - @Override - public RoleTO parent(final Long roleId) { - return controller.parent(roleId); - } - - @Override - public RoleTO read(final Long roleId) { - return controller.read(roleId); - } - - @Override - public PagedResult<RoleTO> search(final String fiql) { - return search(fiql, DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, null); - } - - @Override - public PagedResult<RoleTO> search(final String fiql, final String orderBy) { - return search(fiql, DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, orderBy); - } - - @Override - public PagedResult<RoleTO> search(final String fiql, final Integer page, final Integer size) { - return search(fiql, page, size, null); - } - - @Override - public PagedResult<RoleTO> search(final String fiql, final Integer page, final Integer size, final String orderBy) { - SearchCond cond = getSearchCond(fiql); - List<OrderByClause> orderByClauses = getOrderByClauses(orderBy); - return buildPagedResult( - controller.search(cond, page, size, orderByClauses), page, size, controller.searchCount(cond)); - } - - @Override - public RoleTO readSelf(final Long roleId) { - return controller.readSelf(roleId); - } - - @Override - public Response update(final Long roleId, final RoleMod roleMod) { - RoleTO role = controller.read(roleId); - - checkETag(role.getETagValue()); - - roleMod.setId(roleId); - RoleTO updated = controller.update(roleMod); - return modificationResponse(updated); - } - - @Override - public Response bulkDeassociation( - final Long roleId, final ResourceDeassociationActionType type, final List<ResourceName> resourceNames) { - - RoleTO role = controller.read(roleId); - - checkETag(role.getETagValue()); - - RoleTO updated; - switch (type) { - case UNLINK: - updated = controller.unlink(roleId, CollectionWrapper.unwrap(resourceNames)); - break; - - case UNASSIGN: - updated = controller.unassign(roleId, CollectionWrapper.unwrap(resourceNames)); - break; - - case DEPROVISION: - updated = controller.deprovision(roleId, CollectionWrapper.unwrap(resourceNames)); - break; - - default: - updated = controller.read(roleId); - } - - final BulkActionResult res = new BulkActionResult(); - - if (type == ResourceDeassociationActionType.UNLINK) { - for (ResourceName resourceName : resourceNames) { - res.add(resourceName.getElement(), updated.getResources().contains(resourceName.getElement()) - ? BulkActionResult.Status.FAILURE - : BulkActionResult.Status.SUCCESS); - } - } else { - for (PropagationStatus propagationStatusTO : updated.getPropagationStatusTOs()) { - res.add(propagationStatusTO.getResource(), propagationStatusTO.getStatus().toString()); - } - } - - return modificationResponse(res); - } - - @Override - public Response bulkAssociation( - final Long roleId, final ResourceAssociationActionType type, final List<ResourceName> resourceNames) { - - RoleTO role = controller.read(roleId); - - checkETag(role.getETagValue()); - - RoleTO updated; - switch (type) { - case LINK: - updated = controller.link(roleId, CollectionWrapper.unwrap(resourceNames)); - break; - - case ASSIGN: - updated = controller.assign(roleId, CollectionWrapper.unwrap(resourceNames), false, null); - break; - - case PROVISION: - updated = controller.provision(roleId, CollectionWrapper.unwrap(resourceNames), false, null); - break; - - default: - updated = controller.read(roleId); - } - - final BulkActionResult res = new BulkActionResult(); - - if (type == ResourceAssociationActionType.LINK) { - for (ResourceName resourceName : resourceNames) { - res.add(resourceName.getElement(), updated.getResources().contains(resourceName.getElement()) - ? BulkActionResult.Status.FAILURE - : BulkActionResult.Status.SUCCESS); - } - } else { - for (PropagationStatus propagationStatusTO : updated.getPropagationStatusTOs()) { - res.add(propagationStatusTO.getResource(), propagationStatusTO.getStatus().toString()); - } - } - - return modificationResponse(res); - } -} +/* + * 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.util.List; + +import javax.ws.rs.core.Response; +import org.apache.syncope.common.mod.RoleMod; +import org.apache.syncope.common.reqres.BulkActionResult; +import org.apache.syncope.common.services.RoleService; +import org.apache.syncope.common.reqres.PagedResult; +import org.apache.syncope.common.to.PropagationStatus; +import org.apache.syncope.common.wrap.ResourceName; +import org.apache.syncope.common.to.RoleTO; +import org.apache.syncope.common.types.ResourceAssociationActionType; +import org.apache.syncope.common.types.ResourceDeassociationActionType; +import org.apache.syncope.common.util.CollectionWrapper; +import org.apache.syncope.core.persistence.dao.search.OrderByClause; +import org.apache.syncope.core.persistence.dao.search.SearchCond; +import org.apache.syncope.core.rest.controller.RoleController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class RoleServiceImpl extends AbstractServiceImpl implements RoleService { + + @Autowired + private RoleController controller; + + @Override + public List<RoleTO> children(final Long roleId) { + return controller.children(roleId); + } + + @Override + public Response create(final RoleTO roleTO) { + RoleTO created = controller.create(roleTO); + return createResponse(created.getId(), created); + } + + @Override + public Response delete(final Long roleId) { + RoleTO role = controller.read(roleId); + + checkETag(role.getETagValue()); + + RoleTO deleted = controller.delete(roleId); + return modificationResponse(deleted); + } + + @Override + public PagedResult<RoleTO> list() { + return list(DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, null); + } + + @Override + public PagedResult<RoleTO> list(final String orderBy) { + return list(DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, orderBy); + } + + @Override + public PagedResult<RoleTO> list(final Integer page, final Integer size) { + return list(page, size, null); + } + + @Override + public PagedResult<RoleTO> list(final Integer page, final Integer size, final String orderBy) { + List<OrderByClause> orderByClauses = getOrderByClauses(orderBy); + return buildPagedResult(controller.list(page, size, orderByClauses), page, size, controller.count()); + } + + @Override + public RoleTO parent(final Long roleId) { + return controller.parent(roleId); + } + + @Override + public RoleTO read(final Long roleId) { + return controller.read(roleId); + } + + @Override + public PagedResult<RoleTO> search(final String fiql) { + return search(fiql, DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, null); + } + + @Override + public PagedResult<RoleTO> search(final String fiql, final String orderBy) { + return search(fiql, DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, orderBy); + } + + @Override + public PagedResult<RoleTO> search(final String fiql, final Integer page, final Integer size) { + return search(fiql, page, size, null); + } + + @Override + public PagedResult<RoleTO> search(final String fiql, final Integer page, final Integer size, final String orderBy) { + SearchCond cond = getSearchCond(fiql); + List<OrderByClause> orderByClauses = getOrderByClauses(orderBy); + return buildPagedResult( + controller.search(cond, page, size, orderByClauses), page, size, controller.searchCount(cond)); + } + + @Override + public RoleTO readSelf(final Long roleId) { + return controller.readSelf(roleId); + } + + @Override + public Response update(final Long roleId, final RoleMod roleMod) { + RoleTO role = controller.read(roleId); + + checkETag(role.getETagValue()); + + roleMod.setId(roleId); + RoleTO updated = controller.update(roleMod); + return modificationResponse(updated); + } + + @Override + public Response bulkDeassociation( + final Long roleId, final ResourceDeassociationActionType type, final List<ResourceName> resourceNames) { + + RoleTO role = controller.read(roleId); + + checkETag(role.getETagValue()); + + RoleTO updated; + switch (type) { + case UNLINK: + updated = controller.unlink(roleId, CollectionWrapper.unwrap(resourceNames)); + break; + + case UNASSIGN: + updated = controller.unassign(roleId, CollectionWrapper.unwrap(resourceNames)); + break; + + case DEPROVISION: + updated = controller.deprovision(roleId, CollectionWrapper.unwrap(resourceNames)); + break; + + default: + updated = controller.read(roleId); + } + + final BulkActionResult res = new BulkActionResult(); + + if (type == ResourceDeassociationActionType.UNLINK) { + for (ResourceName resourceName : resourceNames) { + res.add(resourceName.getElement(), updated.getResources().contains(resourceName.getElement()) + ? BulkActionResult.Status.FAILURE + : BulkActionResult.Status.SUCCESS); + } + } else { + for (PropagationStatus propagationStatusTO : updated.getPropagationStatusTOs()) { + res.add(propagationStatusTO.getResource(), propagationStatusTO.getStatus().toString()); + } + } + + return modificationResponse(res); + } + + @Override + public Response bulkAssociation( + final Long roleId, final ResourceAssociationActionType type, final List<ResourceName> resourceNames) { + + RoleTO role = controller.read(roleId); + + checkETag(role.getETagValue()); + + RoleTO updated; + switch (type) { + case LINK: + updated = controller.link(roleId, CollectionWrapper.unwrap(resourceNames)); + break; + + case ASSIGN: + updated = controller.assign(roleId, CollectionWrapper.unwrap(resourceNames), false, null); + break; + + case PROVISION: + updated = controller.provision(roleId, CollectionWrapper.unwrap(resourceNames), false, null); + break; + + default: + updated = controller.read(roleId); + } + + final BulkActionResult res = new BulkActionResult(); + + if (type == ResourceAssociationActionType.LINK) { + for (ResourceName resourceName : resourceNames) { + res.add(resourceName.getElement(), updated.getResources().contains(resourceName.getElement()) + ? BulkActionResult.Status.FAILURE + : BulkActionResult.Status.SUCCESS); + } + } else { + for (PropagationStatus propagationStatusTO : updated.getPropagationStatusTOs()) { + res.add(propagationStatusTO.getResource(), propagationStatusTO.getStatus().toString()); + } + } + + return modificationResponse(res); + } +} 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=1615910&r1=1615909&r2=1615910&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 Tue Aug 5 11:20:00 2014 @@ -1,77 +1,77 @@ -/* - * 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.core.Response; - -import org.apache.syncope.common.services.SchemaService; -import org.apache.syncope.common.to.AbstractSchemaTO; -import org.apache.syncope.common.types.AttributableType; -import org.apache.syncope.common.types.RESTHeaders; -import org.apache.syncope.common.types.SchemaType; -import org.apache.syncope.core.rest.controller.SchemaController; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class SchemaServiceImpl extends AbstractServiceImpl implements SchemaService { - - @Autowired - private SchemaController controller; - - @Override - public <T extends AbstractSchemaTO> Response create(final AttributableType attrType, final SchemaType schemaType, - final T schemaTO) { - - T response = controller.create(attrType, schemaType, schemaTO); - - URI location = uriInfo.getAbsolutePathBuilder().path(response.getName()).build(); - return Response.created(location). - header(RESTHeaders.RESOURCE_ID, response.getName()). - build(); - } - - @Override - public void delete(final AttributableType attrType, final SchemaType schemaType, final String schemaName) { - controller.delete(attrType, schemaType, schemaName); - } - - @Override - public <T extends AbstractSchemaTO> List<T> list(final AttributableType attrType, final SchemaType schemaType) { - return controller.list(attrType, schemaType); - } - - @Override - public <T extends AbstractSchemaTO> T read(final AttributableType attrType, final SchemaType schemaType, - final String schemaName) { - - return controller.read(attrType, schemaType, schemaName); - } - - @Override - public <T extends AbstractSchemaTO> void update(final AttributableType attrType, final SchemaType schemaType, - final String schemaName, final T schemaTO) { - - schemaTO.setName(schemaName); - controller.update(attrType, schemaType, schemaTO); - } -} +/* + * 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.core.Response; + +import org.apache.syncope.common.services.SchemaService; +import org.apache.syncope.common.to.AbstractSchemaTO; +import org.apache.syncope.common.types.AttributableType; +import org.apache.syncope.common.types.RESTHeaders; +import org.apache.syncope.common.types.SchemaType; +import org.apache.syncope.core.rest.controller.SchemaController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SchemaServiceImpl extends AbstractServiceImpl implements SchemaService { + + @Autowired + private SchemaController controller; + + @Override + public <T extends AbstractSchemaTO> Response create(final AttributableType attrType, final SchemaType schemaType, + final T schemaTO) { + + T response = controller.create(attrType, schemaType, schemaTO); + + URI location = uriInfo.getAbsolutePathBuilder().path(response.getName()).build(); + return Response.created(location). + header(RESTHeaders.RESOURCE_ID, response.getName()). + build(); + } + + @Override + public void delete(final AttributableType attrType, final SchemaType schemaType, final String schemaName) { + controller.delete(attrType, schemaType, schemaName); + } + + @Override + public <T extends AbstractSchemaTO> List<T> list(final AttributableType attrType, final SchemaType schemaType) { + return controller.list(attrType, schemaType); + } + + @Override + public <T extends AbstractSchemaTO> T read(final AttributableType attrType, final SchemaType schemaType, + final String schemaName) { + + return controller.read(attrType, schemaType, schemaName); + } + + @Override + public <T extends AbstractSchemaTO> void update(final AttributableType attrType, final SchemaType schemaType, + final String schemaName, final T schemaTO) { + + schemaTO.setName(schemaName); + controller.update(attrType, schemaType, schemaTO); + } +} Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java?rev=1615910&r1=1615909&r2=1615910&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java Tue Aug 5 11:20:00 2014 @@ -1,158 +1,158 @@ -/* - * 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.core.Response; -import org.apache.syncope.common.services.TaskService; -import org.apache.syncope.common.reqres.BulkAction; -import org.apache.syncope.common.reqres.BulkActionResult; -import org.apache.syncope.common.wrap.JobClass; -import org.apache.syncope.common.to.ReportExecTO; -import org.apache.syncope.common.to.SchedTaskTO; -import org.apache.syncope.common.wrap.SyncActionClass; -import org.apache.syncope.common.to.SyncTaskTO; -import org.apache.syncope.common.to.TaskExecTO; -import org.apache.syncope.common.to.AbstractTaskTO; -import org.apache.syncope.common.reqres.PagedResult; -import org.apache.syncope.common.to.PushTaskTO; -import org.apache.syncope.common.types.RESTHeaders; -import org.apache.syncope.common.types.PropagationTaskExecStatus; -import org.apache.syncope.common.types.TaskType; -import org.apache.syncope.common.util.CollectionWrapper; -import org.apache.syncope.common.wrap.PushActionClass; -import org.apache.syncope.core.persistence.dao.search.OrderByClause; -import org.apache.syncope.core.rest.controller.TaskController; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class TaskServiceImpl extends AbstractServiceImpl implements TaskService { - - @Autowired - private TaskController controller; - - @Override - public <T extends SchedTaskTO> Response create(final T taskTO) { - T createdTask; - if (taskTO instanceof SyncTaskTO || taskTO instanceof PushTaskTO || taskTO instanceof SchedTaskTO) { - createdTask = controller.createSchedTask(taskTO); - } else { - throw new BadRequestException(); - } - - URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(createdTask.getId())).build(); - return Response.created(location). - header(RESTHeaders.RESOURCE_ID, createdTask.getId()). - build(); - } - - @Override - public void delete(final Long taskId) { - controller.delete(taskId); - } - - @Override - public void deleteExecution(final Long executionId) { - controller.deleteExecution(executionId); - } - - @Override - public TaskExecTO execute(final Long taskId, final boolean dryRun) { - return controller.execute(taskId, dryRun); - } - - @Override - public List<JobClass> getJobClasses() { - return CollectionWrapper.wrap(controller.getJobClasses(), JobClass.class); - } - - @Override - public List<SyncActionClass> getSyncActionsClasses() { - return CollectionWrapper.wrap(controller.getSyncActionsClasses(), SyncActionClass.class); - } - - @Override - public List<PushActionClass> getPushActionsClasses() { - return CollectionWrapper.wrap(controller.getPushActionsClasses(), PushActionClass.class); - } - - @Override - public <T extends AbstractTaskTO> PagedResult<T> list(final TaskType taskType) { - return list(taskType, DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, null); - } - - @Override - public <T extends AbstractTaskTO> PagedResult<T> list(final TaskType taskType, final String orderBy) { - return list(taskType, DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, orderBy); - } - - @Override - public <T extends AbstractTaskTO> PagedResult<T> list( - final TaskType taskType, final Integer page, final Integer size) { - - return list(taskType, page, size, null); - } - - @Override - @SuppressWarnings("unchecked") - public <T extends AbstractTaskTO> PagedResult<T> list(final TaskType taskType, - final Integer page, final Integer size, final String orderBy) { - - List<OrderByClause> orderByClauses = getOrderByClauses(orderBy); - return (PagedResult<T>) buildPagedResult( - controller.list(taskType, page, size, orderByClauses), page, size, controller.count(taskType)); - } - - @Override - public <T extends AbstractTaskTO> T read(final Long taskId) { - return controller.read(taskId); - } - - @Override - public TaskExecTO readExecution(final Long executionId) { - return controller.readExecution(executionId); - } - - @Override - public void report(final Long executionId, final ReportExecTO reportExec) { - reportExec.setId(executionId); - controller.report( - executionId, PropagationTaskExecStatus.fromString(reportExec.getStatus()), reportExec.getMessage()); - } - - @Override - public void update(final Long taskId, final AbstractTaskTO taskTO) { - taskTO.setId(taskId); - if (taskTO instanceof SyncTaskTO) { - controller.updateSync((SyncTaskTO) taskTO); - } else if (taskTO instanceof SchedTaskTO) { - controller.updateSched((SchedTaskTO) taskTO); - } else { - throw new BadRequestException(); - } - } - - @Override - public BulkActionResult bulk(final BulkAction bulkAction) { - return controller.bulk(bulkAction); - } -} +/* + * 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.core.Response; +import org.apache.syncope.common.services.TaskService; +import org.apache.syncope.common.reqres.BulkAction; +import org.apache.syncope.common.reqres.BulkActionResult; +import org.apache.syncope.common.wrap.JobClass; +import org.apache.syncope.common.to.ReportExecTO; +import org.apache.syncope.common.to.SchedTaskTO; +import org.apache.syncope.common.wrap.SyncActionClass; +import org.apache.syncope.common.to.SyncTaskTO; +import org.apache.syncope.common.to.TaskExecTO; +import org.apache.syncope.common.to.AbstractTaskTO; +import org.apache.syncope.common.reqres.PagedResult; +import org.apache.syncope.common.to.PushTaskTO; +import org.apache.syncope.common.types.RESTHeaders; +import org.apache.syncope.common.types.PropagationTaskExecStatus; +import org.apache.syncope.common.types.TaskType; +import org.apache.syncope.common.util.CollectionWrapper; +import org.apache.syncope.common.wrap.PushActionClass; +import org.apache.syncope.core.persistence.dao.search.OrderByClause; +import org.apache.syncope.core.rest.controller.TaskController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class TaskServiceImpl extends AbstractServiceImpl implements TaskService { + + @Autowired + private TaskController controller; + + @Override + public <T extends SchedTaskTO> Response create(final T taskTO) { + T createdTask; + if (taskTO instanceof SyncTaskTO || taskTO instanceof PushTaskTO || taskTO instanceof SchedTaskTO) { + createdTask = controller.createSchedTask(taskTO); + } else { + throw new BadRequestException(); + } + + URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(createdTask.getId())).build(); + return Response.created(location). + header(RESTHeaders.RESOURCE_ID, createdTask.getId()). + build(); + } + + @Override + public void delete(final Long taskId) { + controller.delete(taskId); + } + + @Override + public void deleteExecution(final Long executionId) { + controller.deleteExecution(executionId); + } + + @Override + public TaskExecTO execute(final Long taskId, final boolean dryRun) { + return controller.execute(taskId, dryRun); + } + + @Override + public List<JobClass> getJobClasses() { + return CollectionWrapper.wrap(controller.getJobClasses(), JobClass.class); + } + + @Override + public List<SyncActionClass> getSyncActionsClasses() { + return CollectionWrapper.wrap(controller.getSyncActionsClasses(), SyncActionClass.class); + } + + @Override + public List<PushActionClass> getPushActionsClasses() { + return CollectionWrapper.wrap(controller.getPushActionsClasses(), PushActionClass.class); + } + + @Override + public <T extends AbstractTaskTO> PagedResult<T> list(final TaskType taskType) { + return list(taskType, DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, null); + } + + @Override + public <T extends AbstractTaskTO> PagedResult<T> list(final TaskType taskType, final String orderBy) { + return list(taskType, DEFAULT_PARAM_PAGE_VALUE, DEFAULT_PARAM_SIZE_VALUE, orderBy); + } + + @Override + public <T extends AbstractTaskTO> PagedResult<T> list( + final TaskType taskType, final Integer page, final Integer size) { + + return list(taskType, page, size, null); + } + + @Override + @SuppressWarnings("unchecked") + public <T extends AbstractTaskTO> PagedResult<T> list(final TaskType taskType, + final Integer page, final Integer size, final String orderBy) { + + List<OrderByClause> orderByClauses = getOrderByClauses(orderBy); + return (PagedResult<T>) buildPagedResult( + controller.list(taskType, page, size, orderByClauses), page, size, controller.count(taskType)); + } + + @Override + public <T extends AbstractTaskTO> T read(final Long taskId) { + return controller.read(taskId); + } + + @Override + public TaskExecTO readExecution(final Long executionId) { + return controller.readExecution(executionId); + } + + @Override + public void report(final Long executionId, final ReportExecTO reportExec) { + reportExec.setId(executionId); + controller.report( + executionId, PropagationTaskExecStatus.fromString(reportExec.getStatus()), reportExec.getMessage()); + } + + @Override + public void update(final Long taskId, final AbstractTaskTO taskTO) { + taskTO.setId(taskId); + if (taskTO instanceof SyncTaskTO) { + controller.updateSync((SyncTaskTO) taskTO); + } else if (taskTO instanceof SchedTaskTO) { + controller.updateSched((SchedTaskTO) taskTO); + } else { + throw new BadRequestException(); + } + } + + @Override + public BulkActionResult bulk(final BulkAction bulkAction) { + return controller.bulk(bulkAction); + } +} Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java?rev=1615910&r1=1615909&r2=1615910&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java Tue Aug 5 11:20:00 2014 @@ -1,116 +1,116 @@ -/* - * 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.io.IOException; -import java.io.OutputStream; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.StreamingOutput; -import org.apache.syncope.common.services.WorkflowService; -import org.apache.syncope.common.types.RESTHeaders; -import org.apache.syncope.common.types.SubjectType; -import org.apache.syncope.core.rest.controller.WorkflowController; -import org.apache.syncope.core.workflow.ActivitiDetector; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class WorkflowServiceImpl extends AbstractServiceImpl implements WorkflowService { - - @Autowired - private WorkflowController controller; - - @Override - public Response getOptions(final SubjectType kind) { - String key; - String value; - if (kind == SubjectType.USER) { - key = RESTHeaders.ACTIVITI_USER_ENABLED; - value = Boolean.toString(ActivitiDetector.isActivitiEnabledForUsers()); - } else { - key = RESTHeaders.ACTIVITI_ROLE_ENABLED; - value = Boolean.toString(ActivitiDetector.isActivitiEnabledForRoles()); - } - - Response.ResponseBuilder builder = Response.ok().header(HttpHeaders.ALLOW, OPTIONS_ALLOW); - if (key != null && value != null) { - builder.header(key, value); - } - return builder.build(); - } - - @Override - public Response exportDefinition(final SubjectType kind) { - final MediaType accept = - messageContext.getHttpHeaders().getAcceptableMediaTypes().contains(MediaType.APPLICATION_JSON_TYPE) - ? MediaType.APPLICATION_JSON_TYPE - : MediaType.APPLICATION_XML_TYPE; - - StreamingOutput sout = new StreamingOutput() { - - @Override - public void write(final OutputStream os) throws IOException { - if (kind == SubjectType.USER) { - controller.exportUserDefinition(accept, os); - } else { - controller.exportRoleDefinition(accept, os); - } - } - }; - - return Response.ok(sout). - type(accept). - build(); - } - - @Override - public Response exportDiagram(final SubjectType kind) { - StreamingOutput sout = new StreamingOutput() { - - @Override - public void write(final OutputStream os) throws IOException { - if (kind == SubjectType.USER) { - controller.exportUserDiagram(os); - } else { - controller.exportRoleDiagram(os); - } - } - }; - - return Response.ok(sout). - type(RESTHeaders.MEDIATYPE_IMAGE_PNG). - build(); - } - - @Override - public void importDefinition(final SubjectType kind, final String definition) { - final MediaType contentType = - messageContext.getHttpHeaders().getMediaType().equals(MediaType.APPLICATION_JSON_TYPE) - ? MediaType.APPLICATION_JSON_TYPE - : MediaType.APPLICATION_XML_TYPE; - - if (kind == SubjectType.USER) { - controller.importUserDefinition(contentType, definition); - } else { - controller.importRoleDefinition(contentType, definition); - } - } -} +/* + * 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.io.IOException; +import java.io.OutputStream; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import org.apache.syncope.common.services.WorkflowService; +import org.apache.syncope.common.types.RESTHeaders; +import org.apache.syncope.common.types.SubjectType; +import org.apache.syncope.core.rest.controller.WorkflowController; +import org.apache.syncope.core.workflow.ActivitiDetector; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class WorkflowServiceImpl extends AbstractServiceImpl implements WorkflowService { + + @Autowired + private WorkflowController controller; + + @Override + public Response getOptions(final SubjectType kind) { + String key; + String value; + if (kind == SubjectType.USER) { + key = RESTHeaders.ACTIVITI_USER_ENABLED; + value = Boolean.toString(ActivitiDetector.isActivitiEnabledForUsers()); + } else { + key = RESTHeaders.ACTIVITI_ROLE_ENABLED; + value = Boolean.toString(ActivitiDetector.isActivitiEnabledForRoles()); + } + + Response.ResponseBuilder builder = Response.ok().header(HttpHeaders.ALLOW, OPTIONS_ALLOW); + if (key != null && value != null) { + builder.header(key, value); + } + return builder.build(); + } + + @Override + public Response exportDefinition(final SubjectType kind) { + final MediaType accept = + messageContext.getHttpHeaders().getAcceptableMediaTypes().contains(MediaType.APPLICATION_JSON_TYPE) + ? MediaType.APPLICATION_JSON_TYPE + : MediaType.APPLICATION_XML_TYPE; + + StreamingOutput sout = new StreamingOutput() { + + @Override + public void write(final OutputStream os) throws IOException { + if (kind == SubjectType.USER) { + controller.exportUserDefinition(accept, os); + } else { + controller.exportRoleDefinition(accept, os); + } + } + }; + + return Response.ok(sout). + type(accept). + build(); + } + + @Override + public Response exportDiagram(final SubjectType kind) { + StreamingOutput sout = new StreamingOutput() { + + @Override + public void write(final OutputStream os) throws IOException { + if (kind == SubjectType.USER) { + controller.exportUserDiagram(os); + } else { + controller.exportRoleDiagram(os); + } + } + }; + + return Response.ok(sout). + type(RESTHeaders.MEDIATYPE_IMAGE_PNG). + build(); + } + + @Override + public void importDefinition(final SubjectType kind, final String definition) { + final MediaType contentType = + messageContext.getHttpHeaders().getMediaType().equals(MediaType.APPLICATION_JSON_TYPE) + ? MediaType.APPLICATION_JSON_TYPE + : MediaType.APPLICATION_XML_TYPE; + + if (kind == SubjectType.USER) { + controller.importUserDefinition(contentType, definition); + } else { + controller.importRoleDefinition(contentType, definition); + } + } +} Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/WorkflowTestITCase.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/WorkflowTestITCase.java?rev=1615910&r1=1615909&r2=1615910&view=diff ============================================================================== --- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/WorkflowTestITCase.java (original) +++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/WorkflowTestITCase.java Tue Aug 5 11:20:00 2014 @@ -1,87 +1,87 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.rest; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; - -import java.io.IOException; -import java.io.InputStream; -import javax.ws.rs.core.Response; -import org.apache.commons.io.IOUtils; -import org.apache.syncope.common.types.SubjectType; -import org.apache.syncope.core.workflow.ActivitiDetector; -import org.junit.Assume; -import org.junit.Test; - -public class WorkflowTestITCase extends AbstractTest { - - @Test - public void isActivitiEnabled() { - assertEquals(ActivitiDetector.isActivitiEnabledForUsers(), - adminClient.isActivitiEnabledFor(SubjectType.USER)); - assertEquals(ActivitiDetector.isActivitiEnabledForRoles(), - adminClient.isActivitiEnabledFor(SubjectType.ROLE)); - } - - private void exportDefinition(final SubjectType type) throws IOException { - Response response = workflowService.exportDefinition(type); - assertTrue(response.getMediaType().toString(). - startsWith(clientFactory.getContentType().getMediaType().toString())); - assertTrue(response.getEntity() instanceof InputStream); - String definition = IOUtils.toString((InputStream) response.getEntity()); - assertNotNull(definition); - assertFalse(definition.isEmpty()); - } - - @Test - public void exportUserDefinition() throws IOException { - Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers()); - exportDefinition(SubjectType.USER); - } - - @Test - public void getRoleDefinition() throws IOException { - Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForRoles()); - exportDefinition(SubjectType.ROLE); - } - - private void importDefinition(final SubjectType type) throws IOException { - Response response = workflowService.exportDefinition(type); - String definition = IOUtils.toString((InputStream) response.getEntity()); - - workflowService.importDefinition(type, definition); - } - - @Test - public void updateUserDefinition() throws IOException { - Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers()); - - importDefinition(SubjectType.USER); - } - - @Test - public void updateRoleDefinition() throws IOException { - Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForRoles()); - - importDefinition(SubjectType.ROLE); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.core.rest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.io.IOException; +import java.io.InputStream; +import javax.ws.rs.core.Response; +import org.apache.commons.io.IOUtils; +import org.apache.syncope.common.types.SubjectType; +import org.apache.syncope.core.workflow.ActivitiDetector; +import org.junit.Assume; +import org.junit.Test; + +public class WorkflowTestITCase extends AbstractTest { + + @Test + public void isActivitiEnabled() { + assertEquals(ActivitiDetector.isActivitiEnabledForUsers(), + adminClient.isActivitiEnabledFor(SubjectType.USER)); + assertEquals(ActivitiDetector.isActivitiEnabledForRoles(), + adminClient.isActivitiEnabledFor(SubjectType.ROLE)); + } + + private void exportDefinition(final SubjectType type) throws IOException { + Response response = workflowService.exportDefinition(type); + assertTrue(response.getMediaType().toString(). + startsWith(clientFactory.getContentType().getMediaType().toString())); + assertTrue(response.getEntity() instanceof InputStream); + String definition = IOUtils.toString((InputStream) response.getEntity()); + assertNotNull(definition); + assertFalse(definition.isEmpty()); + } + + @Test + public void exportUserDefinition() throws IOException { + Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers()); + exportDefinition(SubjectType.USER); + } + + @Test + public void getRoleDefinition() throws IOException { + Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForRoles()); + exportDefinition(SubjectType.ROLE); + } + + private void importDefinition(final SubjectType type) throws IOException { + Response response = workflowService.exportDefinition(type); + String definition = IOUtils.toString((InputStream) response.getEntity()); + + workflowService.importDefinition(type, definition); + } + + @Test + public void updateUserDefinition() throws IOException { + Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers()); + + importDefinition(SubjectType.USER); + } + + @Test + public void updateRoleDefinition() throws IOException { + Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForRoles()); + + importDefinition(SubjectType.ROLE); + } +} Modified: syncope/trunk/core/src/test/resources/jboss/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/jboss/META-INF/MANIFEST.MF?rev=1615910&r1=1615909&r2=1615910&view=diff ============================================================================== --- syncope/trunk/core/src/test/resources/jboss/META-INF/MANIFEST.MF (original) +++ syncope/trunk/core/src/test/resources/jboss/META-INF/MANIFEST.MF Tue Aug 5 11:20:00 2014 @@ -1,6 +1,6 @@ -Manifest-Version: 1.0 -Built-By: developer -Build-Jdk: ${java.version} -Created-By: Apache Maven 3.0.4 -Archiver-Version: Plexus Archiver - +Manifest-Version: 1.0 +Built-By: developer +Build-Jdk: ${java.version} +Created-By: Apache Maven 3.0.4 +Archiver-Version: Plexus Archiver +
