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.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public List<Subscription> getSubscriptionsForUserInt(PlatformUser user) { return getSubscriptionDao().getSubscriptionsForUser(user); }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void unsubscribeFromServiceInt(TriggerProcess tp) throws ObjectNotFoundException, SubscriptionStateException, SubscriptionStillActiveException, TechnicalServiceNotAliveException, TechnicalServiceOperationException { String subId = tp.getParamValueForName(TriggerProcessParameterName.SUBSCRIPTION).getValue(String.class); Subscription subscription = validateSubsciptionForUnsubscribe(subId); stopInstance(subscription);/*from w w w . jav a 2s . co m*/ unsubscribe(subscription); manageBean.removeUsageLicenses(subscription); operationRecordBean.removeOperationsForSubscription(subscription.getKey()); // rename the subscription as last step because id is still used for // exceptions and mails rename to allow the reuse of the id final String oldSubscriptionId = subscription.getSubscriptionId(); subscription.setSubscriptionId(String.valueOf(System.currentTimeMillis())); boolean removed = removeOnBehalfActingReference(subscription); triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.UNSUBSCRIBE_FROM_SERVICE, tp.getTriggerProcessParameters(), dataManager.getCurrentUser().getOrganization())); tp.addTriggerProcessParameter(TriggerProcessParameterName.SUBSCRIPTION, buildNotification(oldSubscriptionId)); triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.SUBSCRIPTION_TERMINATION, tp.getTriggerProcessParameters(), subscription.getProduct().getVendor())); sendConfirmDeactivationEmail(removed, oldSubscriptionId, subscription); }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public Subscription loadSubscription(long subscriptionKey) throws ObjectNotFoundException { return dataManager.getReference(Subscription.class, subscriptionKey); }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public Subscription upgradeSubscriptionInt(TriggerProcess tp) throws ObjectNotFoundException, SubscriptionStateException, OperationNotPermittedException, ServiceChangedException, PriceModelException, PaymentInformationException, SubscriptionMigrationException, ConcurrentModificationException, TechnicalServiceNotAliveException, NonUniqueBusinessKeyException, ValidationException, MandatoryUdaMissingException, MandatoryCustomerUdaMissingException { VOSubscription current = tp.getParamValueForName(TriggerProcessParameterName.SUBSCRIPTION) .getValue(VOSubscription.class); VOService voTargetProduct = 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<VOUda> udas = ParameterizedTypes .list(tp.getParamValueForName(TriggerProcessParameterName.UDAS).getValue(List.class), VOUda.class); Product dbTargetProduct = dataManager.getReference(Product.class, voTargetProduct.getKey()); Subscription dbSubscription = dataManager.getReference(Subscription.class, current.getKey()); PlatformUser currentUser = dataManager.getCurrentUser(); Subscription subscription = manageBean.loadSubscription(current.getSubscriptionId(), 0); BaseAssembler.verifyVersionAndKey(subscription, current); Product initialProduct = subscription.getProduct(); PaymentInfo initialPaymentInfo = subscription.getPaymentInfo(); BillingContact initialBillingContact = subscription.getBillingContact(); validateSettingsForUpgrading(current, voTargetProduct, voPaymentInfo, voBillingContact); // validates parameter version and parameter values checkIfParametersAreModified(subscription, dbSubscription, initialProduct, dbTargetProduct, voTargetProduct.getParameters(), true); PaymentInfo paymentInfo = null;//from w w w . j a v a2s . com BillingContact bc = null; if (voPaymentInfo != null) { // Valid payment information have been passed -> use it for the // upgraded subscription paymentInfo = dataManager.getReference(PaymentInfo.class, voPaymentInfo.getKey()); } if (voBillingContact != null) { bc = dataManager.getReference(BillingContact.class, voBillingContact.getKey()); } // log payment info before subscription changed! audit.editPaymentType(dataManager, subscription, paymentInfo); // log billing address before subscription changed! audit.editBillingAddress(dataManager, subscription, bc); // update subscription subscription.setPaymentInfo(paymentInfo); subscription.setBillingContact(bc); try { appManager.saveAttributes(dbSubscription); } catch (TechnicalServiceOperationException e) { // Log and continue LOG.logWarn(Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.WARN_TECH_SERVICE_WS_ERROR, subscription.getSubscriptionId(), e.getMessage()); } List<Uda> existingUdas = manageBean.getExistingUdas(subscription); List<VOUda> updatedList = getUpdatedSubscriptionAttributes(udas, existingUdas); logSubscriptionAttributeForEdit(subscription, updatedList); // save subscription attributes before provisioning call, to have them // available at the API if (dbTargetProduct.getTechnicalProduct().getProvisioningType().equals(ProvisioningType.ASYNCHRONOUS)) { saveUdasForAsyncModifyOrUpgradeSubscription(udas, dbSubscription); } else { saveUdasForSubscription(udas, subscription); } // product and parameters are copied copyProductAndModifyParametersForUpgrade(subscription, dbTargetProduct, currentUser, voTargetProduct.getParameters()); if (dbTargetProduct.getTechnicalProduct().getProvisioningType().equals(ProvisioningType.SYNCHRONOUS)) { // bugfix 8068 String oldServiceId = initialProduct.getTemplate() != null ? initialProduct.getTemplate().getProductId() : initialProduct.getProductId(); String newServiceId = dbTargetProduct.getTemplate() != null ? dbTargetProduct.getTemplate().getProductId() : dbTargetProduct.getProductId(); // remove old product dataManager.remove(initialProduct); // finally send confirmation mail to the organization admin modUpgBean.sendConfirmUpgradationEmail(subscription, oldServiceId, newServiceId); } else if (dbTargetProduct.getTechnicalProduct().getProvisioningType() .equals(ProvisioningType.ASYNCHRONOUS)) { long subscriptionKey = subscription.getKey(); if (paymentInfo != null) { modUpgBean.storeModifiedEntity(subscriptionKey, ModifiedEntityType.SUBSCRIPTION_PAYMENTINFO, String.valueOf(paymentInfo.getKey())); } if (bc != null) { modUpgBean.storeModifiedEntity(subscriptionKey, ModifiedEntityType.SUBSCRIPTION_BILLINGCONTACT, String.valueOf(bc.getKey())); } subscription.setPaymentInfo(initialPaymentInfo); subscription.setBillingContact(initialBillingContact); } dataManager.flush(); triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.UPGRADE_SUBSCRIPTION, tp.getTriggerProcessParameters(), dataManager.getCurrentUser().getOrganization())); // log upDowngrade subscription audit.upDowngradeSubscription(dataManager, subscription, initialProduct, dbTargetProduct); return subscription; }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public VOSubscriptionDetails modifySubscriptionInt(TriggerProcess tp) throws ObjectNotFoundException, NonUniqueBusinessKeyException, ValidationException, OperationNotPermittedException, SubscriptionMigrationException, ConcurrentModificationException, TechnicalServiceNotAliveException, MandatoryUdaMissingException, SubscriptionStateException, MandatoryCustomerUdaMissingException { VOSubscription subscription = tp.getParamValueForName(TriggerProcessParameterName.SUBSCRIPTION) .getValue(VOSubscription.class); List<VOParameter> modifiedParameters = ParameterizedTypes.list( tp.getParamValueForName(TriggerProcessParameterName.PARAMETERS).getValue(List.class), VOParameter.class); List<VOUda> udas = ParameterizedTypes .list(tp.getParamValueForName(TriggerProcessParameterName.UDAS).getValue(List.class), VOUda.class); Subscription dbSubscription = validateSubscriptionSettings(subscription); final PlatformUser currentUser = dataManager.getCurrentUser(); Organization organization = currentUser.getOrganization(); UserGroup unit = getUnit(subscription.getUnitKey(), subscription.getUnitName(), organization.getKey()); stateValidator.checkModifyAllowedForUpdating(dbSubscription); // get initial values of subscription String dbSubscriptionId = dbSubscription.getSubscriptionId(); boolean subIdChanged = !dbSubscriptionId.equals(subscription.getSubscriptionId()); String dbReferenceId = dbSubscription.getPurchaseOrderNumber(); boolean refIdChanged = dbReferenceId == null && subscription.getPurchaseOrderNumber() != null || dbReferenceId != null && !dbReferenceId.equals(subscription.getPurchaseOrderNumber()); PlatformUser dbOwner = dbSubscription.getOwner(); Product dbProduct = dbSubscription.getProduct(); String dbPurchaseNumber = dbSubscription.getPurchaseOrderNumber(); UserGroup dbUnit = dbSubscription.getUserGroup(); // set new values for subscription dbSubscription.setSubscriptionId(subscription.getSubscriptionId()); dbSubscription.setPurchaseOrderNumber(subscription.getPurchaseOrderNumber()); if (currentUser.isOrganizationAdmin() || currentUser.isUnitAdmin()) { dbSubscription.setUserGroup(unit); }/*from w w w. ja v a2 s .c om*/ manageBean.setSubscriptionOwner(dbSubscription, subscription.getOwnerId(), true); try { appManager.saveAttributes(dbSubscription); } catch (TechnicalServiceOperationException e) { // Log and continue LOG.logWarn(Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.WARN_TECH_SERVICE_WS_ERROR, subscription.getSubscriptionId(), e.getMessage()); } List<Uda> existingUdas = manageBean.getExistingUdas(dbSubscription); List<VOUda> updatedUdas = getUpdatedSubscriptionAttributes(udas, existingUdas); boolean changedValues = false; try { changedValues = subIdChanged || refIdChanged || checkIfParametersAreModified(dbSubscription, dbSubscription, dbProduct, dbProduct, modifiedParameters, false) || updatedUdas.size() > 0; } catch (ServiceChangedException e) { throw new ConcurrentModificationException(e.getMessage()); } boolean asynch = dbProduct.getTechnicalProduct().getProvisioningType() .equals(ProvisioningType.ASYNCHRONOUS); logSubscriptionAttributeForEdit(dbSubscription, updatedUdas); logSubscriptionOwner(dbSubscription, dbOwner); if (changedValues && asynch) { long subscriptionKey = dbSubscription.getKey(); modUpgBean.storeModifiedEntity(subscriptionKey, ModifiedEntityType.SUBSCRIPTION_SUBSCRIPTIONID, subscription.getSubscriptionId()); modUpgBean.storeModifiedEntity(subscriptionKey, ModifiedEntityType.SUBSCRIPTION_ORGANIZATIONID, dbSubscription.getOrganization().getOrganizationId()); modUpgBean.storeModifiedEntity(subscriptionKey, ModifiedEntityType.SUBSCRIPTION_PURCHASEORDERNUMBER, subscription.getPurchaseOrderNumber()); modUpgBean.storeModifiedEntity(subscriptionKey, ModifiedEntityType.SUBSCRIPTION_OWNERID, subscription.getOwnerId()); modUpgBean.storeModifiedEntity(subscriptionKey, ModifiedEntityType.SUBSCRIPTION_UNIT, String.valueOf(subscription.getUnitKey())); // save subscription attributes before provisioning call, to have // them // available at the API saveUdasForAsyncModifyOrUpgradeSubscription(udas, dbSubscription); } else { saveUdasForSubscription(udas, dbSubscription); } dataManager.flush(); if (changedValues) { copyProductAndModifyParametersForUpdate(dbSubscription, dbProduct, currentUser, modifiedParameters); } if (changedValues && asynch) { // set initial values again dbSubscription.setSubscriptionId(dbSubscriptionId); dbSubscription.setPurchaseOrderNumber(dbPurchaseNumber); String dbOwnerId = dbOwner == null ? null : dbOwner.getUserId(); manageBean.setSubscriptionOwner(dbSubscription, dbOwnerId, true); dbSubscription.setUserGroup(dbUnit); } LocalizerFacade facade = new LocalizerFacade(localizer, currentUser.getLocale()); VOSubscriptionDetails result = SubscriptionAssembler.toVOSubscriptionDetails(dbSubscription, facade); triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.MODIFY_SUBSCRIPTION, tp.getTriggerProcessParameters(), dataManager.getCurrentUser().getOrganization())); triggerQS.sendAllNonSuspendingMessages(TriggerMessage.create(TriggerType.SUBSCRIPTION_MODIFICATION, tp.getTriggerProcessParameters(), dbSubscription.getProduct().getVendor())); return result; }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public boolean expireOverdueSubscriptions(long currentTime) { return terminateBean.expireOverdueSubscriptions(currentTime); }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void informProductAboutNewUsers(Subscription sub, List<PlatformUser> users) throws SubscriptionStateException, TechnicalServiceNotAliveException, TechnicalServiceOperationException { stateValidator.checkInformProductAboutNewUsers(sub); if (!canModifyApplicationUsers(sub)) { return;//from w w w. j av a 2 s . c o m } List<UsageLicense> licenses = getUsageLicensesForUsers(sub, users); User[] createdUsers = appManager.createUsers(sub, licenses); mapApplicationUserIdToLicense(licenses, createdUsers); }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public boolean notifyAboutTimedoutSubscriptions(long currentTime) { // we could also use a separate query inclusing the checked conditions List<Subscription> subscriptions = getSubscriptionDao() .getSubscriptionsByStatus(SubscriptionStatus.PENDING); for (Subscription subscription : subscriptions) { Long timeout = subscription.getProduct().getTechnicalProduct().getProvisioningTimeout(); if (!subscription.isTimeoutMailSent() && subscription.getCreationDate().longValue() + timeout.longValue() < currentTime) { List<PlatformUser> users = subscription.getProduct().getTechnicalProduct().getOrganization() .getPlatformUsers(); if (notifyTechnicalAdminsAboutTimeout(subscription, users)) { // if at least one mail was sent, set the mail sent flag of // the subscription subscription.setTimeoutMailSent(true); }/* ww w . j a v a2 s .c o m*/ } } return true; }
From source file:org.oscm.subscriptionservice.bean.SubscriptionServiceBean.java
@TransactionAttribute(TransactionAttributeType.MANDATORY) private List<Subscription> getSubscriptionsForUserInt(PlatformUser user, PaginationFullTextFilter pagination) { String fullTextFilterValue = pagination.getFullTextFilterValue(); List<Subscription> subscriptions = Collections.emptyList(); if (StringUtils.isNotEmpty(fullTextFilterValue)) { Collection<Long> subscriptionKeys = Collections.emptySet(); try {//from w w w . ja v a 2 s. co m subscriptionKeys = getFilteredOutSubscriptionKeys(fullTextFilterValue); } catch (InvalidPhraseException e) { LOG.logError(Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.ERROR); } catch (ObjectNotFoundException e) { LOG.logDebug("No subscription keys found"); } if (!subscriptionKeys.isEmpty()) { subscriptions = getSubscriptionDao().getSubscriptionsForUserWithSubscriptionKeys(user, pagination, subscriptionKeys); } } else { subscriptions = getSubscriptionDao().getSubscriptionsForUser(user, pagination); } return subscriptions; }