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.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java
@Override @RolesAllowed({ "SERVICE_MANAGER", "RESELLER_MANAGER", "BROKER_MANAGER" }) @TransactionAttribute(TransactionAttributeType.MANDATORY) public VOServiceDetails getServiceDetails(Product product, LocalizerFacade facade) { TechnicalProduct tp = product.getTechnicalProduct(); List<ParameterDefinition> platformParameters = getPlatformParameterDefinitions(tp); List<Event> platformEvents = getPlatformEvents(tp); VOServiceDetails createdProduct = ProductAssembler.toVOProductDetails(product, platformParameters, platformEvents, isImageDefined(product), facade); return createdProduct; }
From source file:org.oscm.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void copyDefaultPaymentEnablement(Product product, Organization vendor) { List<OrganizationRefToPaymentType> types = vendor.getDefaultServicePaymentTypes(); for (OrganizationRefToPaymentType ref : types) { ProductToPaymentType ptpt = new ProductToPaymentType(product, ref.getPaymentType()); product.getPaymentTypes().add(ptpt); try {/* ww w . j ava2 s .c om*/ dm.persist(ptpt); } catch (NonUniqueBusinessKeyException e) { // must not happen as the product is a new one without // references to payment types SaaSSystemException sse = new SaaSSystemException("Caught unexpected NonUniqueBusinessKeyException", e); logger.logError(Log4jLogger.SYSTEM_LOG, sse, LogMessageIdentifier.ERROR_UNEXPECTED_BK_VIOLATION); throw sse; } } }
From source file:org.oscm.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void deleteProduct(Organization supplier, Product product) throws OperationNotPermittedException, ServiceOperationException, ServiceStateException { PermissionCheck.owns(product, supplier, logger, sessionCtx); List<CatalogEntry> catalogEntries = product.getCatalogEntries(); Marketplace marketplace = null;// w w w .j a va 2s . co m if (product.getCatalogEntries().size() > 0) { marketplace = catalogEntries.get(0).getMarketplace(); } // 2. if the product is subscription specific, throw an exception if (product.getOwningSubscription() != null) { ServiceOperationException sof = new ServiceOperationException(Reason.DELETION_FAILED_USED_BY_SUB); logger.logWarn(Log4jLogger.SYSTEM_LOG, sof, LogMessageIdentifier.WARN_PRODUCT_DELETION_FAILED_STILL_USED_BY_SUBSCRIPTION, Long.toString(product.getKey()), Long.toString(product.getOwningSubscription().getKey())); throw sof; } // 3. if it's a customer specific copy, delete it else if (product.getTemplate() != null && product.getTargetCustomer() != null) { ProductValidator.validateInactiveOrSuspended(ProductAssembler.getProductId(product), product.getStatus()); deletePriceModelForCustomer(product); } // 4. if the product is not a copy, set its status to deleted and delete // all customer specific copies that are not used by any subscription else { ProductValidator.validateInactiveOrSuspended(ProductAssembler.getProductId(product), product.getStatus()); // check if there are active customer specific services long count = countNonSubscriptionCopiesInState(product, EnumSet.of(ServiceStatus.ACTIVE)); if (count > 0) { String expected = ServiceStatus.INACTIVE.name() + ", " + ServiceStatus.SUSPENDED.name(); throw new ServiceStateException(ServiceStatus.ACTIVE, expected, ProductAssembler.getProductId(product)); } // validate that there are no resale permissions for the MS validateNotExistingResalePermissions(product); product.setStatus(ServiceStatus.DELETED); // rename to allow reuse of the id product.setProductId(product.getProductId() + "#" + String.valueOf(System.currentTimeMillis())); // now delete all it's customer specific copies List<Product> customerSpecificProductCopies = getCustomerSpecificProductCopies(product); for (Product copy : customerSpecificProductCopies) { dm.remove(copy); } } if (marketplace != null) { landingpageService.removeProductFromLandingpage(marketplace, product); } }
From source file:org.oscm.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public List<Product> getCustomerSpecificProducts(Organization cust, Organization seller) throws OperationNotPermittedException { PermissionCheck.supplierOfCustomer(seller, cust, logger, sessionCtx); Query query = dm.createNamedQuery("Product.getCustomerSpecificProducts"); query.setParameter("vendorKey", Long.valueOf(seller.getKey())); query.setParameter("customer", cust); List<Product> list = ParameterizedTypes.list(query.getResultList(), Product.class); return list;// w ww . j a v a 2 s .c om }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public Subscription subscribeToServiceInt(TriggerProcess tp) throws ObjectNotFoundException, ValidationException, OperationNotPermittedException, ServiceChangedException, PriceModelException, PaymentInformationException, NonUniqueBusinessKeyException, TechnicalServiceNotAliveException, TechnicalServiceOperationException, ServiceParameterException, SubscriptionAlreadyExistsException, ConcurrentModificationException, MandatoryUdaMissingException, MandatoryCustomerUdaMissingException, SubscriptionStateException { PlatformUser currentUser = dataManager.getCurrentUser(); Organization organization = currentUser.getOrganization(); // read parameters from trigger process VOSubscription subscription = tp.getParamValueForName(TriggerProcessParameterName.SUBSCRIPTION) .getValue(VOSubscription.class); VOService product = tp.getParamValueForName(TriggerProcessParameterName.PRODUCT).getValue(VOService.class); VOPaymentInfo voPaymentInfo = tp.getParamValueForName(TriggerProcessParameterName.PAYMENTINFO) .getValue(VOPaymentInfo.class); VOBillingContact voBillingContact = tp.getParamValueForName(TriggerProcessParameterName.BILLING_CONTACT) .getValue(VOBillingContact.class); List<?> udas = tp.getParamValueForName(TriggerProcessParameterName.UDAS).getValue(List.class); PlatformUser owner = dataManager.getReference(PlatformUser.class, tp.getUser().getKey()); Product productTemplate = dataManager.getReference(Product.class, product.getKey()); checkIfSubscriptionAlreadyExists(productTemplate); UserGroup unit = getUnit(subscription.getUnitKey(), subscription.getUnitName(), organization.getKey()); validateSettingsForSubscribing(subscription, product, voPaymentInfo, voBillingContact); Organization vendor = productTemplate.getVendor(); Organization supplier = dataManager.getReference(Product.class, product.getKey()) .getSupplierOrResellerTemplate().getVendor(); List<VOUda> originalCustomerUdas = getUdasForCustomer("CUSTOMER", dataManager.getCurrentUser().getOrganization().getKey(), supplier); OrganizationReference refVendorCust = null; if (!organization.getVendorsOfCustomer().contains(vendor)) { refVendorCust = new OrganizationReference(vendor, organization, OrganizationReferenceType.getOrgRefTypeForSourceRoles(vendor.getGrantedRoleTypes())); dataManager.persist(refVendorCust); }/*from w w w . j a v a 2s . c o m*/ if (vendor.getGrantedRoleTypes().contains(OrganizationRoleType.BROKER) && !organization.getVendorsOfCustomer().contains(productTemplate.getTemplate().getVendor())) { refVendorCust = new OrganizationReference(productTemplate.getTemplate().getVendor(), organization, OrganizationReferenceType.SUPPLIER_TO_CUSTOMER); dataManager.persist(refVendorCust); } if (refVendorCust != null) { enableDefaultPaymentsForCustomer(refVendorCust); } // Look for the marketplace where the service is published Marketplace mp = null; Product publishedService = productTemplate.getType() == ServiceType.CUSTOMER_TEMPLATE ? productTemplate.getTemplate() : productTemplate; List<Marketplace> mps = getMarketplaceDao().getMarketplaceByService(publishedService); for (Marketplace m : mps) { mp = m; // current assumption is that there's only one marketplace break; } // Create a new subscription object Subscription newSub = new Subscription(); Long creationTime = Long.valueOf(DateFactory.getInstance().getTransactionTime()); newSub.setCreationDate(creationTime); newSub.setStatus(SubscriptionStatus.PENDING); // set default cut-off day (db unique constrain) newSub.setCutOffDay(1); newSub.setSubscriptionId(subscription.getSubscriptionId().trim()); newSub.setPurchaseOrderNumber(subscription.getPurchaseOrderNumber()); newSub.setOrganization(organization); // for subscribing service, set the current user as subscription owner newSub.setOwner(owner); verifyUnitAndRoles(currentUser, unit, newSub); Product theProduct = productTemplate.copyForSubscription(productTemplate.getTargetCustomer(), newSub); if (theProduct.getPriceModel() != null) { // FIXME LG clean // The first target pricemodel version is created when subscription // is still in PENDING, but must be fitered for billing. Set the // indicating flag before persisting. theProduct.getPriceModel().setProvisioningCompleted(false); if (theProduct.getPriceModel().isExternal()) { newSub.setExternal(true); } } // to avoid id conflicts in high load scenarios add customer // organization hash theProduct.setProductId(theProduct.getProductId() + organization.hashCode()); theProduct.setOwningSubscription(null); // subscription copies do not have/need a CatalogEntry theProduct.setCatalogEntries(new ArrayList<CatalogEntry>()); try { dataManager.persist(theProduct); } catch (NonUniqueBusinessKeyException e) { SaaSSystemException sse = new SaaSSystemException("The product copy for product '" + product.getKey() + "' cannot be stored, as the business key already exists.", e); LOG.logError(Log4jLogger.SYSTEM_LOG, sse, LogMessageIdentifier.ERROR_CREATE_CUSTOMER_FOR_SPECIFIC_PRICEMODEL_FAILED, Long.toString(dataManager.getCurrentUser().getKey())); throw sse; } copyLocalizedPricemodelValues(theProduct, productTemplate); // update the subscription's configurable parameter List<Parameter> modifiedParametersForLog = updateConfiguredParameterValues(theProduct, product.getParameters(), null); // now bind the product and the price model to the subscription: newSub.bindToProduct(theProduct); // register the marketplace the subscription was coming from newSub.setMarketplace(mp); // Link the passed payment information to this subscription if (voPaymentInfo != null) { PaymentInfo paymentInfo = dataManager.getReference(PaymentInfo.class, voPaymentInfo.getKey()); newSub.setPaymentInfo(paymentInfo); } if (voBillingContact != null) { BillingContact bc = dataManager.getReference(BillingContact.class, voBillingContact.getKey()); newSub.setBillingContact(bc); } // persist the subscription. This is essential to ensure the // subscription exists and also eliminates all potential problems // with a subsequent call to the application. dataManager.persist(newSub); // save subscription attributes before provisioning call, to have them // available at the API saveUdasForSubscription(ParameterizedTypes.list(udas, VOUda.class), newSub); dataManager.flush(); // send customer udas to corresponding app appManager.saveAttributes(newSub); theProduct.setOwningSubscription(newSub); createAllowOnBehalfActingReference(newSub); TenantProvisioningResult provisioningResult = createInstanceAndAddUsersToSubscription(tp, newSub); newSub.setSuccessMessage(provisioningResult.getResultMesage()); dataManager.flush(); triggerQS.sendAllNonSuspendingMessages( TriggerMessage.create(TriggerType.SUBSCRIPTION_CREATION, tp.getTriggerProcessParameters(), vendor)); triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.SUBSCRIBE_TO_SERVICE, tp.getTriggerProcessParameters(), dataManager.getCurrentUser().getOrganization())); sendSubscriptionCreatedMailToAdministrators(newSub, newSub.getProduct().getTechnicalProduct().isAllowingOnBehalfActing()); // Used for Autoassign a service which was supended via trigger // (subscribeToService) autoAssignUserForTriggerProcess(tp, product, owner, newSub); audit.editSubscriptionParameterConfiguration(dataManager, theProduct, modifiedParametersForLog); audit.subscribeToService(dataManager, newSub); logSubscriptionAttributeForCreation(newSub, ParameterizedTypes.list(udas, VOUda.class), originalCustomerUdas); return newSub; }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @RolesAllowed("ORGANIZATION_ADMIN") @TransactionAttribute(TransactionAttributeType.MANDATORY) public void addRevokeUserInt(TriggerProcess tp) throws ObjectNotFoundException, ServiceParameterException, SubscriptionStateException, TechnicalServiceNotAliveException, TechnicalServiceOperationException, OperationNotPermittedException, ConcurrentModificationException { TriggerProcessParameter mod;/*w w w . j a va2 s . c om*/ mod = tp.getParamValueForName(TriggerProcessParameterName.SUBSCRIPTION); String subscriptionId = mod.getValue(String.class); mod = tp.getParamValueForName(TriggerProcessParameterName.USERS_TO_ADD); List<?> usersToBeAdded = mod.getValue(List.class); mod = tp.getParamValueForName(TriggerProcessParameterName.USERS_TO_REVOKE); List<?> usersToBeRevoked = mod.getValue(List.class); // Try to find the subscription Subscription subscription = manageBean.loadSubscription(subscriptionId, 0); List<UsageLicense> addedUsersLicenses = new ArrayList<>(); List<PlatformUser> usersToAdd = new ArrayList<>(); // loop for adding users if (usersToBeAdded != null) { for (Object entry : usersToBeAdded) { final VOUsageLicense lic = (VOUsageLicense) entry; final PlatformUser usr = dataManager.getReference(PlatformUser.class, lic.getUser().getKey()); final RoleDefinition roleDef = getAndCheckServiceRole(lic, subscription.getProduct()); final UsageLicense usageLicenseForUser = subscription.getUsageLicenseForUser(usr); try { if (usageLicenseForUser == null) { // Create a new usage License final UsageLicense newUsageLicense = addUserToSubscription(subscription, usr, roleDef); usersToAdd.add(usr); // store the new user's licenses for later mail sending addedUsersLicenses.add(newUsageLicense); } else { // Update an existing usage license: BaseAssembler.verifyVersionAndKey(usageLicenseForUser, lic); modifyUserRole(subscription, usr, roleDef); } } catch (UserNotAssignedException | UserAlreadyAssignedException e) { // Must not happen here throw new AssertionError(e); } } } // loop for revoking users if (usersToBeRevoked != null) { List<PlatformUser> platformUsers = new ArrayList<>(); for (Object qryUsr : usersToBeRevoked) { PlatformUser usr = dataManager.getReference(PlatformUser.class, VOUser.class.cast(qryUsr).getKey()); platformUsers.add(usr); } revokeUserFromSubscription(subscription, platformUsers); } verifyParameterNamedUser(subscription); informProductAboutNewUsers(subscription, usersToAdd); sendToSubscriptionAddedMail(subscription, addedUsersLicenses); // notify all listeners triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.ADD_REVOKE_USER, tp.getTriggerProcessParameters(), dataManager.getCurrentUser().getOrganization())); }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void modifyUserRole(Subscription subscription, PlatformUser usr, RoleDefinition roleDef) throws SubscriptionStateException, UserNotAssignedException, TechnicalServiceNotAliveException, TechnicalServiceOperationException { stateValidator.checkModifyUserRoleAllowed(subscription); UsageLicense license = subscription.getUsageLicenseForUser(usr); RoleDefinition oldRoleDef = null;/* www . j av a 2 s . co m*/ if (license != null) { oldRoleDef = license.getRoleDefinition(); if (oldRoleDef == roleDef) { // nothing to do - role not changed; avoid sending of mail and // notification of service return; } } UsageLicense targetLicense = subscription.changeRole(usr, roleDef); // Inform application about changed role if (canModifyApplicationUsers(subscription) && targetLicense != null) { appManager.updateUsers(subscription, Collections.singletonList(targetLicense)); // log deassign user role for service audit.deassignUserRoleForService(dataManager, subscription, usr, oldRoleDef); // log assign user role for service audit.assignUserRoleForService(dataManager, subscription, usr, roleDef); } try { String accessInfo = targetLicense == null ? "" : getAccessInfo(subscription, targetLicense.getUser()); commService.sendMail(usr, EmailType.SUBSCRIPTION_ACCESS_GRANTED, new Object[] { subscription.getSubscriptionId(), accessInfo }, subscription.getMarketplace()); } catch (MailOperationException e) { // only log the exception and proceed LOG.logWarn(Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.WARN_GRANT_ROLE_IN_SUBSCRIPTION_CONFIRMING_FAILED); } }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public UsageLicense addUserToSubscription(Subscription subscription, PlatformUser user, RoleDefinition serviceRole) throws UserAlreadyAssignedException { final UsageLicense usageLicense = subscription.addUser(user, serviceRole); audit.assignUserToSubscription(dataManager, subscription, usageLicense); return usageLicense; }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void revokeUserFromSubscription(final Subscription subscription, final List<PlatformUser> users) throws SubscriptionStateException, TechnicalServiceNotAliveException, TechnicalServiceOperationException { stateValidator.checkAddRevokeUserAllowed(subscription); revokeUserFromSubscriptionInt(subscription, users); }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void revokeUserFromSubscriptionInt(final Subscription subscription, final List<PlatformUser> users) throws TechnicalServiceNotAliveException, TechnicalServiceOperationException { List<UsageLicense> usageLicenses = doRevokeUserFromSubscriptionInt(subscription, users); audit.deassignUserFromSubscription(dataManager, subscription, usageLicenses); }