public static BonitaResource resource(String name, byte[] content) { return new BonitaResource(name, content); }
File writeResource(BonitaResource resource) throws IOException { final File file = File.createTempFile(resource.getName(), ".jar", temporaryDirectory); IOUtil.write(file, resource.getContent()); return file; }
Stream<BonitaResource> getDependenciesResources(final ScopeType type, final long id) throws SDependencyException { List<Long> dependencyIds = getDependencyIds(id, type, 0, Integer.MAX_VALUE); return dependencyIds.stream() .map(dependencyId -> { try { // get only the content of the dependency to avoid having connected objects return getDependencyContentOnly(dependencyId); } catch (SDependencyNotFoundException | SBonitaReadException e) { throw new SBonitaRuntimeException(e); } }) .map(dependency -> resource(dependency.getFileName(), dependency.getContent())); }
Stream<BonitaResource> getDependenciesResources(final ScopeType type, final long id) throws SDependencyException { List<Long> dependencyIds = getDependencyIds(id, type, 0, Integer.MAX_VALUE); return dependencyIds.stream() .map(dependencyId -> { try { // get only the content of the dependency to avoid having connected objects return getDependencyContentOnly(dependencyId); } catch (SDependencyNotFoundException | SBonitaReadException e) { throw new SBonitaRuntimeException(e); } }) .map(dependency -> resource(dependency.getFileName(), dependency.getContent())); }
File writeResource(BonitaResource resource) throws IOException { final File file = File.createTempFile(resource.getName(), ".jar", temporaryDirectory); IOUtil.write(file, resource.getContent()); return file; }
public static BonitaResource resource(String name, byte[] content) { return new BonitaResource(name, content); }
protected void addResources(final Stream<BonitaResource> resources) { if (resources == null) { return; } resources.forEach((resource)->{ if (resource.getName().matches(".*\\.jar")) { try { final File file = writeResource(resource); final String path = file.getAbsolutePath(); final URL url = new File(path).toURI().toURL(); urls.add(url); } catch (final IOException e) { throw new BonitaRuntimeException(e); } } else { nonJarResources.put(resource.getName(), resource.getContent()); } }); }
protected void addResources(final Stream<BonitaResource> resources) { if (resources == null) { return; } resources.forEach((resource)->{ if (resource.getName().matches(".*\\.jar")) { try { final File file = writeResource(resource); final String path = file.getAbsolutePath(); final URL url = new File(path).toURI().toURL(); urls.add(url); } catch (final IOException e) { throw new BonitaRuntimeException(e); } } else { nonJarResources.put(resource.getName(), resource.getContent()); } }); }