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.TreeEngineBean.java
/** * {@inheritDoc}//from w ww. j a v a 2 s . co m */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String getPathById(FxTreeMode mode, long nodeId) throws FxApplicationException { Connection con = null; try { con = Database.getDbConnection(); return StorageManager.getTreeStorage().getPathById(con, mode, nodeId); } catch (FxApplicationException ae) { throw ae; } catch (Throwable t) { throw new FxTreeException(LOG, t, "ex.tree.getPathById.failed", nodeId, mode); } finally { Database.closeObjects(TreeEngineBean.class, con, null); } }
From source file:fr.ortolang.diffusion.store.binary.BinaryStoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String type(String identifier, String filename) throws BinaryStoreServiceException, DataNotFoundException { Path path = getPathForIdentifier(identifier); if (!Files.exists(path)) { throw new DataNotFoundException("Unable to find an object with id [" + identifier + "] in the storage"); }/*from w w w . j av a 2s. c o m*/ try (InputStream is = Files.newInputStream(path)) { Tika tika = new Tika(); String type; if (Files.size(path) < 50000000) { LOGGER.log(Level.FINEST, "file size is not too large, trying to detect also containers"); try (TikaInputStream tis = TikaInputStream.get(is)) { type = tika.detect(tis, filename); } } else { LOGGER.log(Level.FINEST, "file size is TOO large, does not detect types inside containers"); type = tika.detect(is, filename); } return type; } catch (Exception e) { throw new BinaryStoreServiceException(e); } }
From source file:com.flexive.ejb.beans.TreeEngineBean.java
/** * {@inheritDoc}//w ww . j av a 2 s .c om */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public long[] getIdChain(FxTreeMode mode, long nodeId) throws FxApplicationException { Connection con = null; try { con = Database.getDbConnection(); return StorageManager.getTreeStorage().getIdChain(con, mode, nodeId); } catch (FxApplicationException ae) { throw ae; } catch (Throwable t) { throw new FxTreeException(LOG, t, "ex.tree.getIdChain.failed", nodeId, mode); } finally { Database.closeObjects(TreeEngineBean.class, con, null); } }
From source file:com.flexive.ejb.beans.ContentEngineBean.java
/** * {@inheritDoc}/*from www. j ava2 s.co m*/ */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public FxContent initialize(long typeId) throws FxApplicationException { FxType type = CacheAdmin.getEnvironment().getType(typeId); UserTicket ticket = FxContext.getUserTicket(); return initialize(type.getId(), ticket.getMandatorId(), type.hasDefaultInstanceACL() ? type.getDefaultInstanceACL().getId() : -1 /*invalid ACL will cause a lookup for best-fit ACL*/, -1 /*invalid Step will cause a lookup for best-fit Step*/, ticket.getLanguage().getId()); }
From source file:fr.ortolang.diffusion.store.binary.BinaryStoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String extract(String identifier) throws BinaryStoreServiceException, DataNotFoundException { Path path = getPathForIdentifier(identifier); if (!Files.exists(path)) { throw new DataNotFoundException("Unable to find an object with id [" + identifier + "] in the storage"); }/*from w w w. j a v a2s.com*/ try { Tika tika = new Tika(); tika.setMaxStringLength(20000000); return tika.parseToString(path.toFile()); } catch (Exception e) { throw new BinaryStoreServiceException(e); } }
From source file:com.flexive.ejb.beans.ContentEngineBean.java
/** * {@inheritDoc}//from w ww . ja va 2 s . com */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public FxContent initialize(String typeName) throws FxApplicationException { return initialize(CacheAdmin.getEnvironment().getType(typeName).getId()); }
From source file:com.flexive.ejb.beans.ContentEngineBean.java
/** * {@inheritDoc}//from w w w. jav a 2 s .c om */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public FxContent load(FxPK pk) throws FxApplicationException { // long time = System.currentTimeMillis(); // System.out.println("=> Cache check for " + pk); FxCachedContent cachedContent = CacheAdmin.getCachedContent(pk); FxEnvironment env = CacheAdmin.getEnvironment(); Connection con = null; PreparedStatement ps = null; try { if (cachedContent == null) { ContentStorage storage = StorageManager.getContentStorage(pk.getStorageMode()); StringBuilder sql = new StringBuilder(2000); con = Database.getDbConnection(); FxContent rawContent = storage.contentLoad(con, pk, env, sql).copy(); final FxContentSecurityInfo securityInfo = storage.getContentSecurityInfo(con, pk, rawContent); rawContent.updateLock(securityInfo.getLock()); cachedContent = new FxCachedContent(rawContent, securityInfo); CacheAdmin.cacheContent(cachedContent, false); } FxContent content = cachedContent.getContent().copy(); //security check start UserTicket ticket = FxContext.getUserTicket(); FxType type = env.getType(cachedContent.getContent().getTypeId()); FxPermissionUtils.checkPermission(ticket, content.getLifeCycleInfo().getCreatorId(), ACLPermission.READ, type, cachedContent.getSecurityInfo().getStepACL(), cachedContent.getSecurityInfo().getContentACLs(), true); FxPermissionUtils.checkMandatorExistance(content.getMandatorId()); FxPermissionUtils.checkTypeAvailable(type.getId(), true); if (type.isUsePropertyPermissions() && !ticket.isGlobalSupervisor()) { //wrap with FxNoAccess or set to readonly when appropriate FxPermissionUtils.wrapNoAccessValues(ticket, cachedContent.getSecurityInfo(), content, type, env); } //security check end //scripting after start FxScriptBinding binding = null; long[] scripts = env.getType(content.getTypeId()).getScriptMapping(FxScriptEvent.AfterContentLoad); if (scripts != null) for (long script : scripts) { if (binding == null) binding = new FxScriptBinding(); binding.setVariable("content", content); scripting.runScript(script, binding); } //scripting after end content.getRootGroup().removeEmptyEntries(); content.getRootGroup().compactPositions(true); return content; } catch (SQLException e) { throw new FxLoadException(LOG, e, "ex.db.sqlError", e.getMessage()); } finally { Database.closeObjects(ContentEngineBean.class, con, ps); } }
From source file:fr.ortolang.diffusion.store.binary.BinaryStoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String put(InputStream content) throws BinaryStoreServiceException, DataCollisionException { try {//from w w w . j av a2 s.c om HashedFilterInputStream input = factory.getHashedFilterInputStream(content); try { Path tmpfile = Paths.get(working.toString(), Long.toString(System.nanoTime())); Files.copy(input, tmpfile); LOGGER.log(Level.FINE, "content stored in local temporary file: " + tmpfile.toString()); String hash = input.getHash(); LOGGER.log(Level.FINE, "content based generated sha1 hash: " + hash); String digit = hash.substring(0, DISTINGUISH_SIZE); Path volume = Paths.get(base.toString(), BinaryStoreVolumeMapper.getVolume(digit)); Path parent = Paths.get(base.toString(), BinaryStoreVolumeMapper.getVolume(digit), digit); Path file = Paths.get(base.toString(), BinaryStoreVolumeMapper.getVolume(digit), digit, hash); if (!Files.exists(volume)) { Files.createDirectory(volume); } if (!Files.exists(parent)) { Files.createDirectory(parent); } if (!Files.exists(file)) { Files.move(tmpfile, file); LOGGER.log(Level.FINE, "content moved in local definitive file: " + file.toString()); } else { LOGGER.log(Level.FINE, "a file with same hash already exists, trying to detect collision"); try (InputStream input1 = Files.newInputStream(file); InputStream input2 = Files.newInputStream(tmpfile)) { if (IOUtils.contentEquals(input1, input2)) { Files.delete(tmpfile); } else { LOGGER.log(Level.SEVERE, "BINARY COLLISION DETECTED - storing colliding files in dedicated folder"); Files.copy(file, Paths.get(collide.toString(), hash + ".origin")); Files.move(tmpfile, Paths.get(collide.toString(), hash + ".colliding")); throw new DataCollisionException(); } } } return hash; } catch (IOException | VolumeNotFoundException e) { throw new BinaryStoreServiceException(e); } finally { IOUtils.closeQuietly(input); } } catch (NoSuchAlgorithmException e) { throw new BinaryStoreServiceException(e); } }
From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftExporterBean.java
/** * {@inheritDoc}//www. ja va2 s . c o m */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public List<PackagingInfo> getAvailablePackagingInfos(Project project) { final List<PackagingInfo> infos = new ArrayList<PackagingInfo>(); final Experiment experiment = project.getExperiment(); String name = experiment.getPublicIdentifier() + PackagingInfo.PackagingMethod.TGZ.getExtension(); PackagingInfo.PackagingMethod method = PackagingInfo.PackagingMethod.TGZ; infos.add(new PackagingInfo(name, method)); final long size = getEstimatedPackageSize(experiment); if (size < PackagingInfo.MAX_ZIP_SIZE) { name = experiment.getPublicIdentifier() + PackagingInfo.PackagingMethod.ZIP.getExtension(); method = PackagingInfo.PackagingMethod.ZIP; infos.add(new PackagingInfo(name, method)); } return infos; }
From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftExporterBean.java
/** * {@inheritDoc}/*www. j ava 2s.co m*/ */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public void writeGeoSoftFile(Project project, String permaLinkUrl, PrintWriter out) throws IOException { if (!validateForExport(project.getExperiment()).isEmpty()) { throw new IllegalArgumentException("experiment not valid for export"); } GeoSoftFileWriterUtil.writeSoftFile(project.getExperiment(), permaLinkUrl, out); }