protected void addConnectorImplementation( ConnectorImplementation impl, List<IResource> resourcesToExport, boolean includeSources) throws FileNotFoundException, CoreException { final IRepositoryStore store = getImplementationStore(); String fileName = NamingUtils.getEResourceFileName(impl, true); final EMFFileStore fileStore = (EMFFileStore) store.getChild(fileName); if (!fileStore.canBeShared()) { File f = new File(fileStore.getEMFResource().getURI().toFileString()); if (f.exists()) { IFile implFile = store.getResource().getFile(f.getName()); implFile.create(new FileInputStream(f), true, Repository.NULL_PROGRESS_MONITOR); resourcesToExport.add(implFile); cleanAfterExport.add(implFile); } } else { implBackup = EcoreUtil.copy(impl); String jarName = NamingUtils.toConnectorImplementationFilename( impl.getImplementationId(), impl.getImplementationVersion(), false) + ".jar"; if (!impl.getJarDependencies().getJarDependency().contains(jarName)) { impl.getJarDependencies().getJarDependency().add(jarName); } impl.setHasSources(includeSources); IRepositoryFileStore file = store.getChild(fileName); file.save(EcoreUtil.copy(impl)); resourcesToExport.add(file.getResource()); } }
protected IStatus addDependencies(ConnectorImplementation impl, IFolder classpathFolder) throws CoreException { final IDefinitionRepositoryStore store = (IDefinitionRepositoryStore) getDefinitionStore(); final DependencyRepositoryStore depStore = (DependencyRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(DependencyRepositoryStore.class); final DefinitionResourceProvider resourceProvider = DefinitionResourceProvider.getInstance(getDefinitionStore(), getBundle()); ConnectorDefinition def = store.getDefinition(impl.getDefinitionId(), impl.getDefinitionVersion()); for (String jarName : def.getJarDependency()) { if (ignoredLibs.contains(jarName)) { continue; } IRepositoryFileStore file = depStore.getChild(jarName); if (file != null) { if (file.getResource().exists()) { if (!classpathFolder.getFile(file.getName()).exists()) { try { file.getResource() .copy( classpathFolder.getFullPath().append(file.getName()), true, Repository.NULL_PROGRESS_MONITOR); } catch (CoreException e) { BonitaStudioLog.error(e); } } } } else { // Search in provided jars InputStream is = resourceProvider.getDependencyInputStream(jarName); if (is != null) { IFile jarFile = classpathFolder.getFile(jarName); if (!jarFile.exists()) { jarFile.create(is, true, Repository.NULL_PROGRESS_MONITOR); } } else { return ValidationStatus.error(Messages.bind(Messages.implementationDepNotFound, jarName)); } } } for (String jarName : impl.getJarDependencies().getJarDependency()) { if (ignoredLibs.contains(jarName)) { continue; } IRepositoryFileStore file = depStore.getChild(jarName); if (file != null) { if (file.getResource().exists()) { if (!classpathFolder.getFile(file.getName()).exists()) { try { file.getResource() .copy( classpathFolder.getFullPath().append(file.getName()), true, Repository.NULL_PROGRESS_MONITOR); } catch (CoreException e) { BonitaStudioLog.error(e); } } } } else { // Search in provided jars InputStream is = resourceProvider.getDependencyInputStream(jarName); if (is != null) { IFile jarFile = classpathFolder.getFile(jarName); if (!jarFile.exists()) { jarFile.create(is, true, Repository.NULL_PROGRESS_MONITOR); } } else { return ValidationStatus.error(Messages.bind(Messages.implementationDepNotFound, jarName)); } } } return Status.OK_STATUS; }