List of usage examples for javax.ejb TransactionAttributeType MANDATORY
TransactionAttributeType MANDATORY
To view the source code for javax.ejb TransactionAttributeType MANDATORY.
Click Source Link
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
/** * Method has been deprecated. Use #{@getPlatformUser} * with tenant parmeter./*from w ww . j a v a2 s . c om*/ * * @param userId * The user identifying attributes' representation. * @param validateOrganization * <code>true</code> if the calling user must be part of the same * organization as the requested user. * @return * @throws ObjectNotFoundException * @throws OperationNotPermittedException */ @Deprecated @Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public PlatformUser getPlatformUser(String userId, boolean validateOrganization) throws ObjectNotFoundException, OperationNotPermittedException { return getPlatformUser(userId, null, validateOrganization); }
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public PlatformUser getPlatformUser(String userId, String tenantId, boolean validateOrganization) throws ObjectNotFoundException, OperationNotPermittedException { PlatformUser platformUser = new PlatformUser(); platformUser.setUserId(userId);/*from w ww. ja v a 2 s .c o m*/ platformUser.setTenantId(tenantId); platformUser = dm.find(platformUser); if (platformUser == null) { ObjectNotFoundException onf = new ObjectNotFoundException(ObjectNotFoundException.ClassEnum.USER, userId); logger.logWarn(Log4jLogger.SYSTEM_LOG, onf, LogMessageIdentifier.WARN_USER_NOT_FOUND); throw onf; } if (validateOrganization) { // Validate whether the calling user belongs to the same // organization as the requested user. Otherwise an exception will // be thrown. PermissionCheck.sameOrg(dm.getCurrentUser(), platformUser, logger); } return platformUser; }
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public List<PlatformUser> getOverdueOrganizationAdmins(long currentTime) { String period = cs.getConfigurationSetting(ConfigurationKey.PERMITTED_PERIOD_UNCONFIRMED_ORGANIZATIONS, Configuration.GLOBAL_CONTEXT).getValue(); long maxTime = currentTime - Long.parseLong(period); Query query = dm.createNamedQuery("PlatformUser.getOverdueOrganizationAdmins"); query.setParameter("status", UserAccountStatus.LOCKED_NOT_CONFIRMED); query.setParameter("date", Long.valueOf(maxTime)); return ParameterizedTypes.list(query.getResultList(), PlatformUser.class); }
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void sendMailToCreatedUser(String password, boolean userLocalLdap, Marketplace marketplace, PlatformUser pu) throws MailOperationException { String tenantId = getTenantIdForEmail(pu); if (!SendMailControl.isSendMail()) { // keep password for later sending SendMailControl.setMailData(password, marketplace); return;/*from ww w.java 2 s .c o m*/ } String marketplaceId = null; if (marketplace != null) { marketplaceId = marketplace.getMarketplaceId(); } if (userLocalLdap) { // if the user role is manager and the marketplaceId exists, which // happens only by registering users as a supplier in the // marketplace portal, then append both the base url and the // marketplace url. if (pu.hasManagerRole()) { if (marketplaceId != null) { if (cs.isServiceProvider()) { cm.sendMail( pu, EmailType.USER_CREATED_WITH_MARKETPLACE_SAML_SP, new Object[] { pu.getUserId(), cm.getBaseUrlWithTenant(tenantId), cm.getMarketplaceUrl(marketplaceId) }, marketplace); } else { cm.sendMail(pu, EmailType.USER_CREATED_WITH_MARKETPLACE, new Object[] { pu.getUserId(), password, cm.getBaseUrl(), cm.getMarketplaceUrl(marketplaceId), String.valueOf(pu.getKey()) }, marketplace); } } else { if (cs.isServiceProvider()) { cm.sendMail(pu, EmailType.USER_CREATED_SAML_SP, new Object[] { pu.getUserId(), cm.getBaseUrlWithTenant(tenantId) }, marketplace); } else { cm.sendMail(pu, EmailType.USER_CREATED, new Object[] { pu.getUserId(), password, cm.getBaseUrl(), String.valueOf(pu.getKey()) }, marketplace); } } } else { if (cs.isServiceProvider()) { cm.sendMail(pu, EmailType.USER_CREATED_SAML_SP, new Object[] { pu.getUserId(), cm.getMarketplaceUrl(marketplaceId) }, marketplace); } else { cm.sendMail( pu, EmailType.USER_CREATED, new Object[] { pu.getUserId(), password, cm.getMarketplaceUrl(marketplaceId), String.valueOf(pu.getKey()) }, marketplace); } } } else { if (pu.hasManagerRole()) { if (marketplaceId != null) { cm.sendMail(pu, EmailType.USER_IMPORTED_WITH_MARKETPLACE, new Object[] { pu.getUserId(), "", cm.getBaseUrl(), cm.getMarketplaceUrl(marketplaceId), String.valueOf(pu.getKey()) }, marketplace); } else { cm.sendMail(pu, EmailType.USER_IMPORTED, new Object[] { pu.getUserId(), "", cm.getBaseUrl(), String.valueOf(pu.getKey()) }, marketplace); } } else { cm.sendMail(pu, EmailType.USER_IMPORTED, new Object[] { pu.getUserId(), "", cm.getMarketplaceUrl(marketplaceId), String.valueOf(pu.getKey()) }, marketplace); } } }
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void setUserRolesInt(Set<UserRoleType> roles, PlatformUser pUser) throws UserModificationConstraintException, UserActiveException, OperationNotPermittedException, UserRoleAssignmentException, ObjectNotFoundException { List<UserRoleType> listForRevoke = new ArrayList<>(); Iterator<RoleAssignment> roleIterator = pUser.getAssignedRoles().iterator(); while (roleIterator.hasNext()) { RoleAssignment roleAssignment = roleIterator.next(); if (!roles.contains(roleAssignment.getRole().getRoleName()) && !roleAssignment.getRole().getRoleName().isUnitRole()) { listForRevoke.add(roleAssignment.getRole().getRoleName()); }//w ww . j ava2s. c o m } revokeUserRolesInt(pUser, listForRevoke); grantUserRoles(pUser, new ArrayList<>(roles)); }
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public Set<UserRoleType> getAvailableUserRolesForUser(PlatformUser pu) { Query query = dm.createNamedQuery("UserRole.getAllUserRoles"); List<UserRole> userRoleList = ParameterizedTypes.list(query.getResultList(), UserRole.class); Organization org = pu.getOrganization(); Set<UserRoleType> roleList = new HashSet<>(); for (UserRole userRole : userRoleList) { if (isAllowedUserRole(org, userRole.getRoleName())) { roleList.add(userRole.getRoleName()); }//w ww. jav a 2s . c o m } return roleList; }
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public boolean removeInactiveOnBehalfUsers() { return prepareForNewTransaction().removeInactiveOnBehalfUsersImpl(); }
From source file:org.oscm.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public boolean isSubscriptionLimitReached(Product product) { if (dm.getCurrentUserIfPresent() != null && product.getTechnicalProduct().isOnlyOneSubscriptionAllowed()) { return hasOneSubscription(product); }// ww w .j a v a2 s. c o m return false; }
From source file:org.oscm.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java
@Override @RolesAllowed({ "SERVICE_MANAGER", "RESELLER_MANAGER", "BROKER_MANAGER" }) @TransactionAttribute(TransactionAttributeType.MANDATORY) public void activateServiceInt(TriggerProcess tp) throws ObjectNotFoundException, ServiceOperationException, TechnicalServiceNotAliveException, ServiceStateException, OrganizationAuthoritiesException, OperationNotPermittedException, ServiceNotPublishedException, ConcurrentModificationException { TriggerProcessParameter tpParam = tp.getParamValueForName(TriggerProcessParameterName.PRODUCT); VOService product = tpParam.getValue(VOService.class); // obtain the user that should be used for authority checks PlatformUser user = tp.getUser();/*from ww w .j ava2 s . c om*/ Product prod = validateForProductActivation(product); setStatus(prod, product, ServiceStatus.ACTIVE, ServiceStatus.INACTIVE, user); // Update visibility (if catalog entries are given) TriggerProcessParameter tpCatEntries = tp.getParamValueForName(TriggerProcessParameterName.CATALOG_ENTRIES); if (tpCatEntries != null) { List<VOCatalogEntry> entries = ParameterizedTypes.list(tpCatEntries.getValue(List.class), VOCatalogEntry.class); if (entries != null && !entries.isEmpty()) { // Set visibility states of entries updateCatalogEntryVisibility(prod, entries); } } triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.ACTIVATE_SERVICE, tp.getTriggerProcessParameters(), dm.getCurrentUser().getOrganization())); }
From source file:org.oscm.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java
@Override @RolesAllowed({ "SERVICE_MANAGER", "RESELLER_MANAGER", "BROKER_MANAGER" }) @TransactionAttribute(TransactionAttributeType.MANDATORY) public void deactivateServiceInt(TriggerProcess tp) throws ObjectNotFoundException, ServiceStateException, OrganizationAuthoritiesException, OperationNotPermittedException, ServiceOperationException, ConcurrentModificationException { VOService product = tp.getParamValueForName(TriggerProcessParameterName.PRODUCT).getValue(VOService.class); Product prod = dm.getReference(Product.class, product.getKey()); setStatus(prod, product, ServiceStatus.INACTIVE, ServiceStatus.ACTIVE, tp.getUser()); // Update visibility (if catalog entries are given) TriggerProcessParameter tpCatEntries = tp.getParamValueForName(TriggerProcessParameterName.CATALOG_ENTRIES); if (tpCatEntries != null) { List<VOCatalogEntry> entries = ParameterizedTypes.list(tpCatEntries.getValue(List.class), VOCatalogEntry.class); if (entries != null && !entries.isEmpty()) { // Set visibility states of entries updateCatalogEntryVisibility(prod, entries); }/*from w w w. j av a 2 s . c o m*/ } triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.DEACTIVATE_SERVICE, tp.getTriggerProcessParameters(), dm.getCurrentUser().getOrganization())); }