List of usage examples for javax.ejb TransactionAttributeType SUPPORTS
TransactionAttributeType SUPPORTS
To view the source code for javax.ejb TransactionAttributeType SUPPORTS.
Click Source Link
REQUIRED
case. From source file:com.flexive.ejb.beans.AccountEngineBean.java
/** * {@inheritDoc}//w w w. j a v a 2s.co m */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public long getAssignedUsersCount(long groupId, boolean includeInvisible) throws FxApplicationException { if (groupId < 0 || groupId == UserGroup.GROUP_UNDEFINED) return 0; final UserTicket ticket = FxContext.getUserTicket(); Connection con = null; Statement stmt = null; String sCurSql = null; try { // Obtain a database connection con = Database.getDbConnection(); // Nothing is invisible for the GLOBAL_SUPERVISOR if (ticket.isGlobalSupervisor()) includeInvisible = true; // Load the count stmt = con.createStatement(); if (includeInvisible) { sCurSql = "SELECT COUNT(*) FROM " + TBL_ASSIGN_GROUPS + " WHERE USERGROUP=" + groupId; } else { sCurSql = "SELECT COUNT(*) FROM " + TBL_ASSIGN_GROUPS + " ln, " + TBL_ACCOUNTS + " usr WHERE ln.ACCOUNT=usr.ID AND usr.MANDATOR=" + ticket.getMandatorId() + " AND ln.USERGROUP=" + groupId; } ResultSet rs = stmt.executeQuery(sCurSql); long result = 0; if (rs != null && rs.next()) result = rs.getLong(1); if (LOG.isDebugEnabled()) LOG.debug("Users in group [" + groupId + "]:" + result + ", caller=" + ticket); return result; } catch (SQLException exc) { FxLoadException ce = new FxLoadException( "Database error! Last stmt was [" + sCurSql + "]:" + exc.getMessage(), exc); LOG.error(ce); throw ce; } finally { Database.closeObjects(UserGroupEngineBean.class, con, stmt); } }
From source file:fr.ortolang.diffusion.core.CoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String findWorkspaceLatestPublishedSnapshot(String wskey) throws CoreServiceException, KeyNotFoundException { LOGGER.log(Level.FINE, "find workspace [" + wskey + "] latest published snapshot"); try {/*from w w w. jav a 2s . com*/ OrtolangObjectIdentifier identifier = registry.lookup(wskey); checkObjectType(identifier, Workspace.OBJECT_TYPE); Workspace workspace = em.find(Workspace.class, identifier.getId()); if (workspace == null) { throw new CoreServiceException( "unable to load workspace with id [" + identifier.getId() + "] from storage"); } workspace.setKey(wskey); String current = workspace.getHead(); boolean found = false; while (!found && current != null) { String parent = registry.getParent(current); if (parent != null && registry.getPublicationStatus(parent) .equals(OrtolangObjectState.Status.PUBLISHED.value())) { found = true; } current = parent; } if (current != null) { SnapshotElement snapshot = workspace.findSnapshotByKey(current); if (snapshot != null) { return snapshot.getName(); } } return null; } catch (RegistryServiceException e) { LOGGER.log(Level.SEVERE, "unexpected error occurred while finding workspace latest published snapshot", e); throw new CoreServiceException( "unable to find latest published snapshot for workspace with key [" + wskey + "]", e); } }
From source file:com.flexive.ejb.beans.PhraseEngineBean.java
/** * {@inheritDoc}// www . j a v a 2 s . c om */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public FxPhraseQueryResult search(FxPhraseQuery query) { return search(query, 1, Integer.MAX_VALUE); }
From source file:com.flexive.ejb.beans.PhraseEngineBean.java
/** * {@inheritDoc}//from w w w. java2 s . c o m */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public FxPhraseQueryResult search(FxPhraseQuery query, int page, int pageSize) { return query.isLanguageFallback() ? searchWithFallback(query, page, pageSize) : searchNoFallback(query, page, pageSize); }
From source file:fr.ortolang.diffusion.core.CoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public List<String> findLinksForTarget(String target) throws CoreServiceException { LOGGER.log(Level.FINE, "finding links for target [" + target + "]"); try {//from ww w. ja va 2 s. co m TypedQuery<Link> query = em.createNamedQuery("findLinksForTarget", Link.class).setParameter("target", target); List<Link> links = query.getResultList(); List<String> results = new ArrayList<String>(); for (Link link : links) { String key = registry.lookup(link.getObjectIdentifier()); results.add(key); } return results; } catch (RegistryServiceException | IdentifierNotRegisteredException e) { LOGGER.log(Level.SEVERE, "unexpected error occurred during finding links for target", e); throw new CoreServiceException("unable to find link for target [" + target + "]", e); } }
From source file:fr.ortolang.diffusion.core.CoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String resolveLinkTarget(String target) throws CoreServiceException, InvalidPathException, PathNotFoundException, AccessDeniedException, AliasNotFoundException { LOGGER.log(Level.FINE, "resolving link target [" + target + "]"); PathBuilder tpath = PathBuilder.fromPath(target); String[] tparts = tpath.buildParts(); if (tparts.length < 2) { throw new CoreServiceException( "unable to resolve target, path must contains at least an alias and a version"); }/*w w w .j av a 2 s.c o m*/ String wskey = resolveWorkspaceAlias(tparts[0]); String root = tparts[1]; String path = tpath.relativize(2).build(); if (root.equals(Workspace.HEAD) || root.equals(Workspace.LATEST)) { throw new CoreServiceException("unable to resolve target due to " + Workspace.HEAD + " or " + Workspace.LATEST + " version reference"); } return resolveWorkspacePath(wskey, root, path); }
From source file:com.flexive.ejb.beans.structure.AssignmentEngineBean.java
/** * {@inheritDoc}/*ww w. ja v a 2s. co m*/ */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public Map<String, List<FxPropertyAssignment>> getPotentialFlatAssignments(FxType type) { return FxFlatStorageManager.getInstance().getPotentialFlatAssignments(type, null); }
From source file:com.flexive.ejb.beans.structure.AssignmentEngineBean.java
/** * {@inheritDoc}// ww w . j a v a 2 s .c om */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public boolean isFlattenable(FxPropertyAssignment pa) { return FxFlatStorageManager.getInstance().isFlattenable(pa); }
From source file:fr.ortolang.diffusion.core.CoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public MetadataObject readMetadataObject(String key) throws CoreServiceException, KeyNotFoundException, AccessDeniedException { LOGGER.log(Level.FINE, "reading metadata for key [" + key + "]"); try {/* w w w. j a v a2s. c o m*/ List<String> subjects = membership.getConnectedIdentifierSubjects(); authorisation.checkPermission(key, subjects, "read"); OrtolangObjectIdentifier identifier = registry.lookup(key); checkObjectType(identifier, MetadataObject.OBJECT_TYPE); MetadataObject meta = em.find(MetadataObject.class, identifier.getId()); if (meta == null) { throw new CoreServiceException( "unable to load metadata with id [" + identifier.getId() + "] from storage"); } meta.setKey(key); return meta; } catch (RegistryServiceException | AuthorisationServiceException | MembershipServiceException e) { LOGGER.log(Level.SEVERE, "unexpected error occurred during reading metadata", e); throw new CoreServiceException("unable to read metadata with key [" + key + "]", e); } }
From source file:fr.ortolang.diffusion.core.CoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String readPublicationPolicy(String key) throws KeyNotFoundException, RegistryServiceException, DataNotFoundException, BinaryStoreServiceException, IOException, CoreServiceException { OrtolangObjectIdentifier identifier = registry.lookup(key); OrtolangObject object;/*w w w .j a v a2 s.co m*/ switch (identifier.getType()) { case Collection.OBJECT_TYPE: object = em.find(Collection.class, identifier.getId()); break; case DataObject.OBJECT_TYPE: object = em.find(DataObject.class, identifier.getId()); break; case Link.OBJECT_TYPE: object = em.find(Link.class, identifier.getId()); break; default: throw new CoreServiceException( "Cannot read publication policy of an object of type: " + identifier.getType()); } MetadataElement metadataElement = null; if (object != null) { metadataElement = ((MetadataSource) object).findMetadataByName(MetadataFormat.ACL); } if (metadataElement != null) { OrtolangObjectIdentifier mdIdentifier = registry.lookup(metadataElement.getKey()); MetadataObject metadataObject = em.find(MetadataObject.class, mdIdentifier.getId()); ObjectMapper mapper = new ObjectMapper(); PublicationPolicy publicationPolicy = mapper.readValue(binarystore.getFile(metadataObject.getStream()), PublicationPolicy.class); return publicationPolicy.getTemplate(); } return null; }