Java Code Examples for javax.ejb.TransactionAttributeType#MANDATORY

The following examples show how to use javax.ejb.TransactionAttributeType#MANDATORY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarketplaceServiceLocalBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<Marketplace> getAllMarketplacesForTenant(Long tenantKey)
        throws ObjectNotFoundException {

    Query query;
    if (tenantKey != null && tenantKey.intValue() != 0) {
        Tenant tenant = ds.getReference(Tenant.class, tenantKey);
        query = ds.createNamedQuery("Marketplace.getAllForTenant");
        query.setParameter("tenant", tenant);
    } else {
        query = ds.createNamedQuery("Marketplace.getAllForDefaultTenant");
    }
    List<Marketplace> marketplaceList = ParameterizedTypes
            .list(query.getResultList(), Marketplace.class);

    return marketplaceList;
}
 
Example 2
Source File: DataServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<DomainHistoryObject<?>> findHistory(DomainObject<?> obj) {
    if (obj == null) {
        return null;
    }
    String className = DomainObject.getDomainClass(obj).getName();
    String histClassName = className
            .substring(className.lastIndexOf(".") + 1) + "History";
    String qryString = histClassName + ".findByObject";
    Query query = em.createNamedQuery(qryString);
    query.setParameter("objKey", Long.valueOf(obj.getKey()));
    List<?> qryresult = query.getResultList();
    List<DomainHistoryObject<?>> result = new ArrayList<DomainHistoryObject<?>>();
    for (Object o : qryresult) {
        if (!(o instanceof DomainHistoryObject<?>)) {
            throw new SaaSSystemException(
                    "findHistory loaded Non-History Object !");
        }
        result.add((DomainHistoryObject<?>) o);
    }
    return result;
}
 
Example 3
Source File: BillingDataRetrievalServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void updateBillingSubscriptionStatus(long subscriptionKey,
        long endOfLastBilledPeriod) throws NonUniqueBusinessKeyException {

    BillingSubscriptionStatus billingSubStatus = new BillingSubscriptionStatus();
    billingSubStatus.setSubscriptionKey(subscriptionKey);
    billingSubStatus = (BillingSubscriptionStatus) dm
            .find(billingSubStatus);

    if (billingSubStatus != null) {
        billingSubStatus.setEndOfLastBilledPeriod(Math.max(
                billingSubStatus.getEndOfLastBilledPeriod(),
                endOfLastBilledPeriod));
    } else {
        billingSubStatus = new BillingSubscriptionStatus();
        billingSubStatus.setSubscriptionKey(subscriptionKey);
        billingSubStatus.setEndOfLastBilledPeriod(endOfLastBilledPeriod);
        dm.persist(billingSubStatus);
        dm.flush();
    }
}
 
Example 4
Source File: ServiceProvisioningServiceLocalizationBean.java    From development with Apache License 2.0 6 votes vote down vote up
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void savePriceModelLocalizationForReseller(long serviceKey,
        boolean isChargable, VOPriceModelLocalization localization)
        throws ObjectNotFoundException, OperationNotPermittedException,
        ConcurrentModificationException {

    Product product = ds.getReference(Product.class, serviceKey);
    if (!checkIsAllowedForLocalizingService(serviceKey)) {
        throw new OperationNotPermittedException(
                "No rights for setting price model localizations.");
    }
    Organization customer = product.getTargetCustomer();
    VOPriceModelLocalization storedLocalization = getPriceModelLocalization(serviceKey);
    VOPriceModelLocalization newLocalization = new VOPriceModelLocalization();
    newLocalization = savePriceModelLocalizationAsReseller(serviceKey,
            localization);
    auditPriceModelLocalization(product, customer, storedLocalization,
            newLocalization);
}
 
Example 5
Source File: LocalizerServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public Properties loadLocalizedPropertiesFromDatabase(long objectKey,
        LocalizedObjectTypes objectType, String localeString) {
    Properties properties = new Properties();
    LocalizedResource template = new LocalizedResource(localeString,
            objectKey, objectType);
    LocalizedResource resource = (LocalizedResource) dm.find(template);
    if (resource != null && resource.getValue().length() > 0) {
        try {
            // Property files are always encoded in ISO-8859-1:
            final InputStream inputStream = new ByteArrayInputStream(
                    resource.getValue().getBytes("ISO-8859-1"));
            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            logger.logError(Log4jLogger.SYSTEM_LOG, e,
                    LogMessageIdentifier.ERROR_OBJECT_ENCODING_FAILED);
        }
    }

    return properties;
}
 
Example 6
Source File: ServiceProvisioningPartnerServiceLocalBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public Map<RevenueShareModelType, RevenueShareModel> getRevenueShareModelsForProduct(
        long serviceKey, boolean isStatusCheckNeeded)
        throws ObjectNotFoundException, OperationNotPermittedException,
        ServiceOperationException, ServiceStateException {

    Product product = loadProduct(serviceKey, isStatusCheckNeeded);

    verifyOwningPermission(product);

    checkTemplateOrPartnerSpecificCopy(product);

    CatalogEntry ce = product.getCatalogEntries().get(0);
    if (product.isCopy()) {
        validateRevenueShareOfProductCopy(ce);
    }
    Map<RevenueShareModelType, RevenueShareModel> revenueShareModels = getPriceModelsForEntry(ce);

    return revenueShareModels;
}
 
Example 7
Source File: MarketplaceServiceLocalBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void removeOwnerRole(Organization org) {
    // Get role marketplace owner
    OrganizationRole orgRole = new OrganizationRole();
    orgRole.setRoleName(OrganizationRoleType.MARKETPLACE_OWNER);
    orgRole = (OrganizationRole) ds.find(orgRole);
    if (orgRole == null) {
        return;
    }
    // second retrieve relevant marketplaces by query
    Query query = ds.createNamedQuery(
            "OrganizationToRole.getByOrganizationAndRole");
    query.setParameter("orgTKey", new Long(org.getKey()));
    query.setParameter("orgRoleTKey", new Long(orgRole.getKey()));
    List<OrganizationToRole> tempList = ParameterizedTypes
            .list(query.getResultList(), OrganizationToRole.class);

    if (tempList.isEmpty()) {
        return;
    }
    // Remove relation
    OrganizationToRole orgToRole = tempList.get(0);
    ds.remove(orgToRole);
    ds.flush();
    org.getGrantedRoles().remove(orgToRole);
}
 
Example 8
Source File: MarketplaceServiceLocalBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public String getTrackingCodeFromMarketplace(String marketplaceID)
        throws ObjectNotFoundException {
    Marketplace dbMarketplace = getMarketplace(marketplaceID);
    return dbMarketplace.getTrackingCode();
}
 
Example 9
Source File: ServiceProvisioningPartnerServiceLocalBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public CatalogEntry getCatalogEntryForProduct(long serviceKey)
        throws ObjectNotFoundException, ServiceOperationException {

    Product product = dm.getReference(Product.class, serviceKey);
    checkTemplateOrPartnerSpecificCopy(product);

    if (product.getCatalogEntries().isEmpty()) {
        return null;
    }
    return product.getCatalogEntries().get(0);
}
 
Example 10
Source File: LocalizerServiceBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void storeLocalizedResources(long objectKey,
        LocalizedObjectTypes objectType, List<VOLocalizedText> values) {
    if (values != null) {
        for (final VOLocalizedText v : values) {
            storeLocalizedResource(v.getLocale(), objectKey, objectType,
                    v.getText());
        }
    }
}
 
Example 11
Source File: ApplicationServiceStub.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void deleteInstance(Subscription subscription)
        throws TechnicalServiceNotAliveException,
        TechnicalServiceOperationException {
    if (throwProductOperationFailed) {
        throw new TechnicalServiceOperationException("");
    }
    isProductDeleted = true;
}
 
Example 12
Source File: AccountServiceStub.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public Discount updateCustomerDiscount(Organization organization,
        Discount discount, Integer discountVersion)
        throws ObjectNotFoundException, ValidationException,
        OperationNotPermittedException, ConcurrentModificationException {

    return null;
}
 
Example 13
Source File: BillingDataRetrievalServiceBean.java    From development with Apache License 2.0 5 votes vote down vote up
/**
 * @return role pricing data, never null
 */
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public RolePricingData loadRoleRelatedCostsForParameters(
        long priceModelKey, long periodEndTime) {

    List<Object[]> pricedRoles = findRoleRelatedCostsForParameters(
            priceModelKey, periodEndTime);

    final RolePricingData result = new RolePricingData();
    for (Object[] entry : pricedRoles) {
        PricedProductRoleHistory pricedRole = (PricedProductRoleHistory) entry[0];
        String roleId = (String) entry[1];
        Long currentParamKey = pricedRole.getPricedParameterObjKey();
        // if nothing is stored, initialize with empty list
        if (!result.getContainerKeys().contains(currentParamKey)) {
            result.addRolePricesForContainerKey(currentParamKey,
                    new HashMap<Long, RolePricingDetails>());
        }
        Map<Long, RolePricingDetails> currentRolePrices = result
                .getRolePricesForContainerKey(currentParamKey);
        if (!currentRolePrices.keySet().contains(
                Long.valueOf(pricedRole.getRoleDefinitionObjKey()))) {
            RolePricingDetails returnObject = new RolePricingDetails(result);
            returnObject.setPricedProductRoleHistory(pricedRole);
            returnObject.setRoleId(roleId);
            currentRolePrices.put(
                    Long.valueOf(pricedRole.getRoleDefinitionObjKey()),
                    returnObject);
        }
    }
    return result;
}
 
Example 14
Source File: SessionServiceBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public boolean hasTechnicalProductActiveSessions(long technicalProductKey) {

    Query query = dm
            .createNamedQuery("Session.getNumOfActiveSessionsForTechProduct");
    query.setParameter("technicalProductKey",
            Long.valueOf(technicalProductKey));
    Long num = (Long) query.getSingleResult();

    return num.longValue() != 0;
}
 
Example 15
Source File: ApplicationServiceStub.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public User[] createUsersForSubscription(Subscription subscription)
        throws TechnicalServiceNotAliveException,
        TechnicalServiceOperationException {
    List<UsageLicense> licenses = subscription.getUsageLicenses();
    return createUsers(subscription, licenses);
}
 
Example 16
Source File: EJB_07_MANDATORY.java    From testing_security_development_enterprise_systems with GNU Lesser General Public License v3.0 4 votes vote down vote up
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void createFooMandatory(String name){
    Foo foo = new Foo(name);
    em.persist(foo);
}
 
Example 17
Source File: AccountServiceStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void processImage(ImageResource imageResource, long organizationKey)
        throws ValidationException {

}
 
Example 18
Source File: PaymentServiceStub.java    From development with Apache License 2.0 4 votes vote down vote up
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public boolean chargeCustomer(BillingResult billingResult) {
    return false;
}
 
Example 19
Source File: IdManagementStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void deletePlatformUser(PlatformUser user, Marketplace marketplace)
        throws UserDeletionConstraintException {

}
 
Example 20
Source File: IdentityServiceBean.java    From development with Apache License 2.0 3 votes vote down vote up
/**
 * Method has been deprecated. Use #{@getPlatformUser} with tenant parmeter.
 * 
 * @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);
}