@Override public ProcessDefinition deploy(final BusinessArchive businessArchive) throws DeploymentException { FacadeUtil.checkArgsNotNull(businessArchive); try { return Deployer.deploy(businessArchive); } catch (final Exception e) { throw new DeploymentException(e.getMessage(), e); } }
private Set<byte[]> getClasses(final File tmpDir) throws DeploymentException { if (ManagementAPIImpl.LOG.isLoggable(Level.FINE)) { ManagementAPIImpl.LOG.fine("Looking for datas in directory: " + tmpDir); } final List<File> classFiles = this.getMatchingFiles(tmpDir, ".class"); final Set<byte[]> classes = new HashSet<byte[]>(); try { for (final File classFile : classFiles) { final String className = this.getClassName(classFile, tmpDir); final URL classURL = classFile.toURL(); if (ManagementAPIImpl.LOG.isLoggable(Level.FINE)) { ManagementAPIImpl.LOG.fine("Found class: " + className + " with URL: " + classURL); } classes.add(Misc.getAllContentFrom(classURL)); } } catch (final IOException e) { throw new DeploymentException("Error when getting classDatas at deployment ", e); } return classes; }
throw new DeploymentException("Cannot create the temporary directory:' " + tmpDir); in.close(); } catch (final IOException e) { throw new DeploymentException("Problem while exploding jar file at deployment", e);
private Map<String, ProcessDefinition> deployArchive(final URL archiveURL) throws DeploymentException { InputStream stream = null; try { stream = archiveURL.openStream(); return this.deployArchive(Misc.getAllContentFrom(stream)); } catch (final IOException e) { throw new DeploymentException("Problem while deploying bar: ", e); } finally { Misc.close(stream); } }
private Map<String, ProcessDefinition> deployArchive(final byte[] barFile) throws DeploymentException { File tmpDir = null; Map<String, ProcessDefinition> processes = null; try { tmpDir = this.explodeArchive(barFile, "tmpBonitaBar"); final List<File> xpdlFiles = this.getMatchingFiles(tmpDir, ".xpdl"); if (xpdlFiles.isEmpty()) { throw new DeploymentException("The given bar archive does not contain any '.xpdl' file"); } if (xpdlFiles.size() > 1) { throw new DeploymentException("The given bar archive contains many '.xpdl' files"); } URL xpdlURL; try { xpdlURL = xpdlFiles.get(0).toURL(); if (ManagementAPIImpl.LOG.isLoggable(Level.FINE)) { ManagementAPIImpl.LOG.fine("Xpdl file currently deployed: " + xpdlURL); } } catch (final MalformedURLException e) { throw new DeploymentException("Error when deploying the bar file", e); } processes = this.deploy(new Deployment(xpdlURL, this.getClasses(tmpDir))); } finally { if (tmpDir != null) { Misc.deleteDir(tmpDir); } } return processes; }
public Map<String, ProcessDefinition> deploy(final Deployment deployment) throws DeploymentException { FacadeUtil.checkArgsNotNull(deployment); try { return Deployer.deploy(deployment, EnvTool.getUserId()); } catch (final DeploymentRuntimeException e) { throw new DeploymentException(e.getMessage(), e); } catch (final XpdlParserException e) { throw new DeploymentException(e.getMessage(), e); } }
@Override public void disable(final ProcessDefinitionUUID processUUID) throws DeploymentException { FacadeUtil.checkArgsNotNull(processUUID); try { Deployer.disableProcess(processUUID); } catch (final DeploymentRuntimeException e) { throw new DeploymentException(e.getMessage(), e); } }
@Override public void disable(final Collection<ProcessDefinitionUUID> processUUIDs) throws DeploymentException { FacadeUtil.checkArgsNotNull(processUUIDs); for (final ProcessDefinitionUUID processUUID : processUUIDs) { try { Deployer.disableProcess(processUUID); } catch (final DeploymentRuntimeException e) { throw new DeploymentException(e.getMessage(), e, processUUID); } } }
@Override public void enable(final ProcessDefinitionUUID processUUID) throws DeploymentException { FacadeUtil.checkArgsNotNull(processUUID); try { Deployer.enableProcess(processUUID); } catch (final DeploymentRuntimeException e) { throw new DeploymentException(e.getMessage(), e); } }
@Override public void deployJar(final String jarName, final byte[] jar) throws DeploymentException { FacadeUtil.checkArgsNotNull(jarName, jar); if (!jarName.endsWith(".jar")) { throw new DeploymentException("Invalid jar name: " + jarName + ". A jar file name must ends with .jar extension."); } final LargeDataRepository ldr = EnvTool.getLargeDataRepository(); if (ldr.getData(byte[].class, Misc.getGlobalClassDataCategories(), jarName) != null) { throw new DeploymentException("A jar with name: " + jarName + " already exists in repository."); } ldr.storeData(Misc.getGlobalClassDataCategories(), jarName, jar, true); EnvTool.getClassDataLoader().resetCommonClassloader(); }
@Override public void removeJar(final String jarName) throws DeploymentException { FacadeUtil.checkArgsNotNull(jarName); if (!jarName.endsWith(".jar")) { throw new DeploymentException("Invalid jar name: " + jarName + ". A jar file name must ends with .jar extension."); } final LargeDataRepository ldr = EnvTool.getLargeDataRepository(); final boolean found = ldr.deleteData(Misc.getGlobalClassDataCategories(), jarName); if (!found) { final String message = ExceptionManager.getInstance().getFullMessage("bai_MAPII_6"); throw new DeploymentException(message, jarName); } EnvTool.getClassDataLoader().resetCommonClassloader(); }
@Override public void archive(final ProcessDefinitionUUID processUUID) throws DeploymentException { FacadeUtil.checkArgsNotNull(processUUID); try { Deployer.archiveProcess(processUUID, EnvTool.getUserId()); } catch (final DeploymentRuntimeException e) { throw new DeploymentException(e.getMessage(), e); } }
@Override public void archive(final Collection<ProcessDefinitionUUID> processUUIDs) throws DeploymentException { FacadeUtil.checkArgsNotNull(processUUIDs); for (final ProcessDefinitionUUID processUUID : processUUIDs) { try { Deployer.archiveProcess(processUUID, EnvTool.getUserId()); } catch (final DeploymentRuntimeException e) { throw new DeploymentException(e.getMessage(), e); } } }
public void undeploy(final PackageDefinitionUUID packageUUID) throws DeploymentException { FacadeUtil.checkArgsNotNull(packageUUID); try { Deployer.undeployPackage(packageUUID, EnvTool.getUserId()); } catch (final DeploymentRuntimeException e) { throw new DeploymentException(e.getMessage(), e); } }
public void deployClass(final byte[] clazz) throws DeploymentException { FacadeUtil.checkArgsNotNull(clazz); String className; try { className = Tool.visitClass(clazz).getClassName(); } catch (final ArrayIndexOutOfBoundsException e) { throw new DeploymentException("The byte table is not correct parameter."); } final Repository repository = EnvTool.getRepository(); final GlobalClassData globalClassData = repository.getGlobalClassData(className); if (globalClassData != null) { // this class was already deployed throw new DeploymentException("There is already a deployed class with this name: ", className); } repository.storeGlobalClassData(new GlobalClassData(className, clazz)); }
public void removeClass(final String className) throws DeploymentException { FacadeUtil.checkArgsNotNull(className); final Repository repository = EnvTool.getRepository(); if (repository.getGlobalClassData(className) == null) { throw new DeploymentException("There is no class defined in global class repository with name: ", className); } // check that no process is still using this class final Set<PackageDependency> packageDependencies = repository.getPackageDependencies(className); if (packageDependencies != null && !packageDependencies.isEmpty()) { for (final PackageDependency packageDependency : packageDependencies) { final PackageClassData data = repository.getPackageClassData(packageDependency.getPackageDefinitionUUID()); if (data == null || !data.getClasses().containsKey(className)) { throw new DeploymentException("Package is still using global class. " + "Cannot undeploy class.", className, packageDependency.getPackageDefinitionUUID()); } } } repository.removeGlobalClassData(className); ClassDataLoader.removeGlobalClassLoader(className); }
final ProcessDefinitionUUID processUUID = businessArchive.getProcessUUID(); if (processUUID == null) { throw new DeploymentException("The given businessArchive does not contain any process.");