List of usage examples for javax.ejb TransactionAttributeType REQUIRED
TransactionAttributeType REQUIRED
To view the source code for javax.ejb TransactionAttributeType REQUIRED.
Click Source Link
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
@Override @Asynchronous/*from w ww .j a va 2 s . c o m*/ @TransactionAttribute(TransactionAttributeType.REQUIRED) public void notifySubscriptionsAboutUserUpdate(PlatformUser existingUser) { // 2. notify all products the user is subscribed to List<Subscription> subscriptions = sm.getSubscriptionsForUserInt(existingUser); List<TaskMessage> messages = new ArrayList<>(); for (Subscription subscription : subscriptions) { SubscriptionStatus status = subscription.getStatus(); // in these states the product instance is not existing if (status != SubscriptionStatus.PENDING && status != SubscriptionStatus.INVALID) { UsageLicense license = getUsgeLicenseForUserAndSubscription(existingUser, subscription); if (license != null) { UpdateUserPayload payload = new UpdateUserPayload(subscription.getKey(), license.getKey()); TaskMessage message = new TaskMessage(UpdateUserHandler.class, payload); messages.add(message); } } } tqs.sendAllMessages(messages); }
From source file:org.nightlabs.jfire.store.StoreManagerBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRED) @RolesAllowed("_Guest_") @Override/*from w ww. j a v a 2 s .c o m*/ public ModeOfDeliveryFlavourProductTypeGroupCarrier getModeOfDeliveryFlavourProductTypeGroupCarrier( Collection<ProductTypeID> productTypeIDs, Collection<CustomerGroupID> customerGroupIDs, byte mergeMode, boolean filterByConfig, String[] fetchGroups, int maxFetchDepth) { PersistenceManager pm = createPersistenceManager(); try { ModeOfDeliveryFlavourProductTypeGroupCarrier res = ModeOfDeliveryFlavour .getModeOfDeliveryFlavourProductTypeGroupCarrier(pm, productTypeIDs, customerGroupIDs, mergeMode, filterByConfig); pm.getFetchPlan().setMaxFetchDepth(maxFetchDepth); if (fetchGroups != null) pm.getFetchPlan().setGroups(fetchGroups); ModeOfDeliveryFlavourProductTypeGroupCarrier res_detached = new ModeOfDeliveryFlavourProductTypeGroupCarrier( customerGroupIDs); for (Iterator<ModeOfDeliveryFlavour> it = res.getModeOfDeliveryFlavours().iterator(); it.hasNext();) { ModeOfDeliveryFlavour modf = it.next(); res_detached.addModeOfDeliveryFlavour(pm.detachCopy(modf)); } for (Iterator<ModeOfDeliveryFlavourProductTypeGroup> it = res .getModeOfDeliveryFlavourProductTypeGroups().iterator(); it.hasNext();) { ModeOfDeliveryFlavourProductTypeGroup group = it.next(); res_detached.addModeOfDeliveryFlavourProductTypeGroup(group); } return res_detached; } finally { pm.close(); } }
From source file:com.flexive.ejb.beans.AccountEngineBean.java
/** * {@inheritDoc}// www . ja va 2 s . c o m */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void setRoles(long accountId, List<Role> roles) throws FxApplicationException { if (roles != null && roles.size() > 0) { setRoles(accountId, roles.toArray(new Role[roles.size()])); } else { setRoles(accountId); } }
From source file:com.flexive.ejb.beans.ContentEngineBean.java
/** * {@inheritDoc}/*ww w. ja v a 2s. c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public int getReferencedContentCount(FxPK pk) throws FxApplicationException { FxSharedUtils.checkParameterNull(pk, "pk"); Connection con = null; try { ContentStorage storage = StorageManager.getContentStorage(pk.getStorageMode()); con = Database.getDbConnection(); return storage.getReferencedContentCount(con, pk.getId()) + (int) FxFlatStorageManager.getInstance().getReferencedContentCount(con, pk.getId()); } catch (FxNotFoundException e) { throw new FxLoadException(e); } catch (SQLException e) { throw new FxLoadException(LOG, e, "ex.db.sqlError", e.getMessage()); } finally { Database.closeObjects(ContentEngineBean.class, con, null); } }
From source file:org.cesecore.certificates.certificate.CertificateStoreSessionBean.java
License:asdf
@Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public boolean setRevokeStatus(AuthenticationToken admin, Certificate certificate, int reason, String userDataDN) throws CertificateRevokeException, AuthorizationDeniedException { return setRevokeStatus(admin, certificate, new Date(), reason, userDataDN); }
From source file:com.flexive.ejb.beans.AccountEngineBean.java
/** * {@inheritDoc}/*from ww w . j a v a 2 s . c om*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void setRoles(long accountId, long... roles) throws FxApplicationException { if (roles == null) roles = new long[0]; final Account account = load(accountId); if (!_checkPermissions(account)[MAY_SET_ROLES]) throw new FxNoAccessException("ex.account.roles.noAssignPermission", accountId); // Write roles to database Connection con = null; PreparedStatement ps = null; StringBuilder sbHistory = new StringBuilder(1000); try { roles = FxArrayUtils.removeDuplicates(roles); con = Database.getDbConnection(); UserTicket ticket = FxContext.getUserTicket(); List<Role> orgRoles = getRoles(accountId, RoleLoadMode.FROM_USER_ONLY); sbHistory.append("<original>\n"); for (Role org : orgRoles) sbHistory.append(" <role id=\"").append(org.getId()).append("\">").append(org.getName()) .append("</role>\n"); sbHistory.append("</original>\n"); //only allow to assign roles which the calling user is a member of (unless it is a global supervisor) if (!ticket.isGlobalSupervisor() && !(ticket.isMandatorSupervisor() && account.getMandatorId() == ticket.getMandatorId())) { final List<Long> orgRoleIds = FxSharedUtils.getSelectableObjectIdList(orgRoles); //check removed roles for (long check : orgRoleIds) { if (!ArrayUtils.contains(roles, check)) { if (!ticket.isInRole(Role.getById(check))) { EJBUtils.rollback(ctx); throw new FxNoAccessException("ex.account.roles.assign.noMember.remove", Role.getById(check).getName()); } } } //check added roles for (long check : roles) { if (!orgRoleIds.contains(check)) { if (!ticket.isInRole(Role.getById(check))) { EJBUtils.rollback(ctx); throw new FxNoAccessException("ex.account.roles.assign.noMember.add", Role.getById(check).getName()); } } } } // Delete the old assignments of the user ps = con.prepareStatement("DELETE FROM " + TBL_ROLE_MAPPING + " WHERE ACCOUNT=?"); ps.setLong(1, accountId); ps.executeUpdate(); if (roles.length > 0) { ps.close(); ps = con.prepareStatement( "INSERT INTO " + TBL_ROLE_MAPPING + " (ACCOUNT,USERGROUP,ROLE) VALUES (?,?,?)"); } sbHistory.append("<new>\n"); // Store the new assignments of the account for (long role : roles) { if (Role.isUndefined(role)) continue; ps.setLong(1, accountId); ps.setLong(2, UserGroup.GROUP_NULL); ps.setLong(3, role); ps.executeUpdate(); sbHistory.append(" <role id=\"").append(role).append("\">").append(Role.getById(role).getName()) .append("</role>\n"); } sbHistory.append("</new>\n"); LifeCycleInfoImpl.updateLifeCycleInfo(TBL_ACCOUNTS, "ID", accountId); // Ensure any active ticket of the updated account are refreshed UserTicketStore.flagDirtyHavingUserId(accountId); EJBLookup.getHistoryTrackerEngine().trackData(sbHistory.toString(), "history.account.setRoles", account.getLoginName()); } catch (SQLException exc) { EJBUtils.rollback(ctx); throw new FxUpdateException(LOG, exc, "ex.account.roles.updateFailed.sql", accountId, exc.getMessage()); } finally { Database.closeObjects(AccountEngineBean.class, con, ps); } }
From source file:org.cesecore.certificates.certificate.CertificateStoreSessionBean.java
License:asdf
@Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public boolean setRevokeStatus(AuthenticationToken admin, Certificate certificate, Date revokedDate, int reason, String userDataDN) throws CertificateRevokeException, AuthorizationDeniedException { if (certificate == null) { return false; }//from w w w. j av a2 s . co m // Must be authorized to CA in order to change status is certificates issued by the CA int caid = CertTools.getIssuerDN(certificate).hashCode(); authorizedToCA(admin, caid); return setRevokeStatusNoAuth(admin, certificate, revokedDate, reason, userDataDN); }
From source file:org.nightlabs.jfire.accounting.AccountingManagerBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRED) @RolesAllowed("org.nightlabs.jfire.accounting.editAccount") @Override/*from w w w . j a va2 s . c om*/ public void setSummaryAccountSummedAccounts(final AnchorID summaryAccountID, final Collection<AnchorID> _summedAccountIDs) { final PersistenceManager pm = createPersistenceManager(); try { final Set<AnchorID> summedAccountIDs = new HashSet<AnchorID>(_summedAccountIDs); final SummaryAccount summaryAccount = (SummaryAccount) pm.getObjectById(summaryAccountID); final Set<Account> accountsToRemove = new HashSet<Account>(); for (final Account a : summaryAccount.getSummedAccounts()) { if (!summedAccountIDs.remove(JDOHelper.getObjectId(a))) accountsToRemove.add(a); } for (final Account account : accountsToRemove) summaryAccount.removeSummedAccount(account); for (final Iterator<AnchorID> iter = summedAccountIDs.iterator(); iter.hasNext();) { final AnchorID accountID = iter.next(); final Account account = (Account) pm.getObjectById(accountID); summaryAccount.addSummedAccount(account); } } finally { pm.close(); } }
From source file:fr.ortolang.diffusion.core.CoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void changeWorkspaceOwner(String wskey, String newOwner) throws CoreServiceException { LOGGER.log(Level.FINE, "changing workspace [" + wskey + "] owner to: " + newOwner); try {/*ww w . j a v a 2 s . c o m*/ Workspace workspace = readWorkspace(wskey); security.changeOwner(wskey, newOwner); membership.addMemberInGroup(workspace.getMembers(), newOwner); security.changeOwner(workspace.getMembers(), newOwner); } catch (SecurityServiceException | AccessDeniedException | KeyNotFoundException | MembershipServiceException e) { ctx.setRollbackOnly(); LOGGER.log(Level.SEVERE, "unexpected error occurred while changing workspace owner", e); throw new CoreServiceException("unable to change owner of workspace with key [" + wskey + "]", e); } }
From source file:com.flexive.ejb.beans.PhraseEngineBean.java
/** * {@inheritDoc}/* w w w . ja va2s . c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void clearPhrases(long mandatorId) throws FxNoAccessException, FxEntryInUseException { checkMandatorAccess(mandatorId, FxContext.getUserTicket()); Connection con = null; PreparedStatement ps = null; try { // Obtain a database connection con = Database.getDbConnection(); ps = con.prepareStatement("DELETE FROM " + TBL_PHRASE_VALUES + " WHERE MANDATOR=?"); ps.setLong(1, mandatorId); ps.executeUpdate(); ps.close(); ps = con.prepareStatement("DELETE FROM " + TBL_PHRASE + " WHERE MANDATOR=?"); ps.setLong(1, mandatorId); ps.executeUpdate(); removePhraseSequencer(mandatorId); } catch (SQLException exc) { EJBUtils.rollback(ctx); throw new FxDbException(LOG, exc, "ex.db.sqlError", exc.getMessage()).asRuntimeException(); } finally { Database.closeObjects(PhraseEngineBean.class, con, ps); } }