private String getProfileMemberQuerySuffix(final String memberType) throws SBonitaReadException { if (ProfileMemberUtils.USER_TYPE.equals(memberType)) { return ProfileMemberUtils.USER_SUFFIX; } else if (ProfileMemberUtils.GROUP_TYPE.equals(memberType)) { return ProfileMemberUtils.GROUP_SUFFIX; } else if (ProfileMemberUtils.ROLE_TYPE.equals(memberType)) { return ProfileMemberUtils.ROLE_SUFFIX; } else if (ProfileMemberUtils.ROLE_AND_GROUP_TYPE.equals(memberType)) { return ProfileMemberUtils.ROLE_AND_GROUP_SUFFIX; } else { throw new SBonitaReadException("Member type must be equalse to user,group,role or roleAndGroup."); } }
private static final String formatMessage(final Throwable cause) { String message = null; if (cause instanceof SBonitaReadException) { final AbstractSelectDescriptor<?> descriptor = ((SBonitaReadException) cause).getSelectDescriptor(); if (descriptor != null) { message = descriptor.toString(); } } return message; }
@Override public List<STenant> getTenants(final QueryOptions queryOptions) throws STenantException { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), LOG_GET_TENANTS)); } List<STenant> tenants; try { tenants = platformPersistenceService.selectList(new SelectListDescriptor<STenant>(LOG_GET_TENANTS, null, STenant.class, queryOptions)); } catch (final SBonitaReadException e) { throw new STenantException("Problem getting list of tenants : " + e.getMessage(), e); } if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogAfterMethod(this.getClass(), LOG_GET_TENANTS)); } return tenants; }
/** * @return true if the given user is allowed to start the given processDefinition respectively. */ @Override public Serializable execute(final Map<String, Serializable> parameters, final TenantServiceAccessor serviceAccessor) throws SCommandParameterizationException, SCommandExecutionException { this.serviceAccessor = serviceAccessor; final ActorMappingService actorMappingService = this.serviceAccessor.getActorMappingService(); final Map<Long, Boolean> resMap = new HashMap<Long, Boolean>(); final List<Long> processDefinitionIds = getMandatoryParameter(parameters, PROCESSDEFINITION_IDS_KEY, "Mandatory parameter " + PROCESSDEFINITION_IDS_KEY + " is missing or not convertible to List<Long>."); final long userId = getLongMandadoryParameter(parameters, USER_ID_KEY); checkIfUserExists(userId); if (!processDefinitionIds.isEmpty()) { for (final Long processDefinitionId : processDefinitionIds) { try { resMap.put(processDefinitionId, actorMappingService.canUserStartProcessDefinition(userId, processDefinitionId)); } catch (final SBonitaReadException e) { e.setProcessDefinitionIdOnContext(processDefinitionId); throw new SCommandExecutionException("No actor of user who can start the processDefinition.", e); } } } return (Serializable) resMap; }
@Override public List<STenant> getTenants(final QueryOptions queryOptions) throws STenantException { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), LOG_GET_TENANTS)); } List<STenant> tenants; try { tenants = platformPersistenceService.selectList(new SelectListDescriptor<STenant>(LOG_GET_TENANTS, null, STenant.class, queryOptions)); } catch (final SBonitaReadException e) { throw new STenantException("Problem getting list of tenants : " + e.getMessage(), e); } if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogAfterMethod(this.getClass(), LOG_GET_TENANTS)); } return tenants; }
/** * @return true if the given user is allowed to start the given processDefinition respectively. */ @Override public Serializable execute(final Map<String, Serializable> parameters, final TenantServiceAccessor serviceAccessor) throws SCommandParameterizationException, SCommandExecutionException { this.serviceAccessor = serviceAccessor; final ActorMappingService actorMappingService = this.serviceAccessor.getActorMappingService(); final Map<Long, Boolean> resMap = new HashMap<Long, Boolean>(); final List<Long> processDefinitionIds = getMandatoryParameter(parameters, PROCESSDEFINITION_IDS_KEY, "Mandatory parameter " + PROCESSDEFINITION_IDS_KEY + " is missing or not convertible to List<Long>."); final long userId = getLongMandadoryParameter(parameters, USER_ID_KEY); checkIfUserExists(userId); if (!processDefinitionIds.isEmpty()) { for (final Long processDefinitionId : processDefinitionIds) { try { resMap.put(processDefinitionId, actorMappingService.canUserStartProcessDefinition(userId, processDefinitionId)); } catch (final SBonitaReadException e) { e.setProcessDefinitionIdOnContext(processDefinitionId); throw new SCommandExecutionException("No actor of user who can start the processDefinition.", e); } } } return (Serializable) resMap; }
private String getProfileMemberQuerySuffix(final String memberType) throws SBonitaReadException { if (ProfileMemberUtils.USER_TYPE.equals(memberType)) { return ProfileMemberUtils.USER_SUFFIX; } else if (ProfileMemberUtils.GROUP_TYPE.equals(memberType)) { return ProfileMemberUtils.GROUP_SUFFIX; } else if (ProfileMemberUtils.ROLE_TYPE.equals(memberType)) { return ProfileMemberUtils.ROLE_SUFFIX; } else if (ProfileMemberUtils.ROLE_AND_GROUP_TYPE.equals(memberType)) { return ProfileMemberUtils.ROLE_AND_GROUP_SUFFIX; } else { throw new SBonitaReadException("Member type must be equalse to user,group,role or roleAndGroup."); } }
@Override public STenant getDefaultTenant() throws STenantNotFoundException { try { STenant tenant = platformPersistenceService.selectOne(new SelectOneDescriptor<STenant>(QUERY_GET_DEFAULT_TENANT, null, STenant.class)); if (tenant == null) { throw new STenantNotFoundException("No default tenant found"); } return tenant; } catch (final SBonitaReadException e) { throw new STenantNotFoundException("Unable to check if a default tenant already exists: " + e.getMessage(), e); } }
private static final String formatMessage(final Throwable cause) { String message = null; if (cause instanceof SBonitaReadException) { final AbstractSelectDescriptor<?> descriptor = ((SBonitaReadException) cause).getSelectDescriptor(); if (descriptor != null) { message = descriptor.toString(); } } return message; }
private void appendClassAlias(final StringBuilder builder, final Class<? extends PersistentObject> clazz) throws SBonitaReadException { final String className = clazz.getName(); final String classAlias = classAliasMappings.get(className); if (classAlias == null || classAlias.trim().isEmpty()) { throw new SBonitaReadException("No class alias found for class " + className); } builder.append(classAlias); builder.append('.'); }
@Override public List<STenant> getTenants(final Collection<Long> ids, final QueryOptions queryOptions) throws STenantNotFoundException, STenantException { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), LOG_GET_TENANTS)); } List<STenant> tenants; try { final Map<String, Object> parameters = CollectionUtil.buildSimpleMap("ids", ids); tenants = platformPersistenceService .selectList(new SelectListDescriptor<STenant>(QUERY_GET_TENANTS_BY_IDS, parameters, STenant.class, queryOptions)); if (tenants.size() != ids.size()) { throw new STenantNotFoundException("Unable to retrieve all tenants by ids. Expected: " + ids + ", retrieved: " + tenants); } } catch (final SBonitaReadException e) { throw new STenantException("Problem getting list of tenants: " + e.getMessage(), e); } if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogAfterMethod(this.getClass(), LOG_GET_TENANTS)); } return tenants; }
private void appendClassAlias(final StringBuilder builder, final Class<? extends PersistentObject> clazz) throws SBonitaReadException { final String className = clazz.getName(); final String classAlias = classAliasMappings.get(className); if (classAlias == null || classAlias.trim().isEmpty()) { throw new SBonitaReadException("No class alias found for class " + className); } builder.append(classAlias); builder.append('.'); }
@Override public STenant getDefaultTenant() throws STenantNotFoundException { try { STenant tenant = platformPersistenceService.selectOne(new SelectOneDescriptor<STenant>(QUERY_GET_DEFAULT_TENANT, null, STenant.class)); if (tenant == null) { throw new STenantNotFoundException("No default tenant found"); } return tenant; } catch (final SBonitaReadException e) { throw new STenantNotFoundException("Unable to check if a default tenant already exists: " + e.getMessage(), e); } }
@Override public List<STheme> searchThemes(final QueryOptions queryOptions) throws SBonitaReadException { try { final Map<String, Object> parameters = Collections.emptyMap(); return persistenceService.searchEntity(STheme.class, queryOptions, parameters); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }
@Override public SPlatform getPlatform() throws SPlatformNotFoundException { try { SPlatform platform = platformPersistenceService.selectOne(new SelectOneDescriptor<SPlatform>(QUERY_GET_PLATFORM, null, SPlatform.class)); if (platform == null) { throw new SPlatformNotFoundException("No platform found"); } return platform; } catch (final SBonitaReadException e) { throw new SPlatformNotFoundException("Unable to check if a platform already exists : " + e.getMessage(), e); } }
@Override public long getNumberOfCustomUserInfoValue(final QueryOptions options) throws SBonitaReadException { try { return persistenceService.getNumberOfEntities(SCustomUserInfoValue.class, options, null); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }
@Override public SPlatform getPlatform() throws SPlatformNotFoundException { try { SPlatform platform = platformPersistenceService.selectOne(new SelectOneDescriptor<SPlatform>(QUERY_GET_PLATFORM, null, SPlatform.class)); if (platform == null) { throw new SPlatformNotFoundException("No platform found"); } return platform; } catch (final SBonitaReadException e) { throw new SPlatformNotFoundException("Unable to check if a platform already exists : " + e.getMessage(), e); } }
@Override public long getNumberOfCustomUserInfoValue(final QueryOptions options) throws SBonitaReadException { try { return persistenceService.getNumberOfEntities(SCustomUserInfoValue.class, options, null); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }
@Override public List<STenant> getTenants(final Collection<Long> ids, final QueryOptions queryOptions) throws STenantNotFoundException, STenantException { if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), LOG_GET_TENANTS)); } List<STenant> tenants; try { final Map<String, Object> parameters = CollectionUtil.buildSimpleMap("ids", ids); tenants = platformPersistenceService .selectList(new SelectListDescriptor<STenant>(QUERY_GET_TENANTS_BY_IDS, parameters, STenant.class, queryOptions)); if (tenants.size() != ids.size()) { throw new STenantNotFoundException("Unable to retrieve all tenants by ids. Expected: " + ids + ", retrieved: " + tenants); } } catch (final SBonitaReadException e) { throw new STenantException("Problem getting list of tenants: " + e.getMessage(), e); } if (isTraced) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogAfterMethod(this.getClass(), LOG_GET_TENANTS)); } return tenants; }
@Override public long executeCount(final QueryOptions queryOptions) throws SBonitaReadException { try { return pageService.getNumberOfPages(queryOptions); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }