protected void resetClassPath(List cp) { ArchiveManifest mf = outgoingArchive.getManifest(); if (cp.isEmpty()) mf.getMainAttributes().remove(Attributes.Name.CLASS_PATH); else { mf.setClassPath("");//$NON-NLS-1$ for (int i = 0; i < cp.size(); i++) { mf.appendClassPath((String) cp.get(i)); } } }
/** * @see com.ibm.etools.commonarchive.CommonarchiveFactory */ public java.lang.String[] getManifestClassPathValues(java.lang.String uri) throws org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException { Archive anArchive = primOpenArchive(uri); String[] result = anArchive.getManifest().getClassPathTokenized(); anArchive.close(); return result; }
protected void saveManifest() throws SaveFailureException { if (!shouldSave(J2EEConstants.MANIFEST_URI)) return; ArchiveManifest mf = getArchive().getManifest(); if (mf.getManifestVersion() == null || mf.getManifestVersion().equals(""))//$NON-NLS-1$ mf.setManifestVersion("1.0");//$NON-NLS-1$ save(mf); }
public void selectEAR(int index) { ArchiveManifest mf = new ArchiveManifestImpl((ArchiveManifestImpl) getArchive().getManifest()); JavaEEArchiveUtilities.INSTANCE.closeArchive(earFile); selectedEARComponent = availableEARComponents[index]; initializeSelection(mf); fireNotification(new ClasspathModelEvent(ClasspathModelEvent.EAR_PROJECT_CHANGED)); }
public void merge() { String[] cp = outgoingArchive.getManifest().getClassPathTokenized(); dependentArchives = new ArrayList(cp.length); List keepClassPaths = new ArrayList(); for (int i = 0; i < cp.length; i++) { Archive dependentJar = null; IFile file = null; try { file = project.getFile(cp[i]); } catch (IllegalArgumentException e) { continue; } if (file.exists() && cp[i].endsWith(J2EEImportConstants.IMPORTED_JAR_SUFFIX)) { try { dependentJar = getArchiveFactory().primOpenArchive(file.getLocation().toOSString()); } catch (OpenFailureException ex) { // Need to write this to the log file org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ex); continue; } dependentArchives.add(dependentJar); mergeFiles(dependentJar); } else keepClassPaths.add(cp[i]); } resetClassPath(keepClassPaths); }
protected void setProjectValues(ClasspathElement element, Archive referencedArchive) { IProject p = getProject(referencedArchive); if (p == null) return; element.setProject(p); //Handle the imported jars in the project String[] cp = null; try { cp = referencedArchive.getManifest().getClassPathTokenized(); } catch (ManifestException mfEx) { Logger.getLogger().logError(mfEx); cp = new String[]{}; } List paths = new ArrayList(cp.length); for (int i = 0; i < cp.length; i++) { IFile file = null; try { file = p.getFile(cp[i]); } catch (IllegalArgumentException invalidPath) { continue; } if (file.exists()) paths.add(file.getFullPath()); } if (!paths.isEmpty()) element.setImportedJarPaths(paths); }
public String[] getManifestClasspath() { if (null == manifestClasspath) { Archive archive = EnterpriseBinaryComponentHelper.ArchiveCache.getInstance().getArchive(this); if (null == archive) { EnterpriseBinaryComponentHelper helper = EnterpriseBinaryComponentHelper.getHelper(this); try { archive = helper.accessArchive(); ArchiveManifest manifest = archive.getManifest(); manifestClasspath = manifest.getClassPathTokenized(); } catch (Exception e) { } finally { if (null != archive) { archive.close(); } if (null != helper) { helper.dispose(); } } } else { ArchiveManifest manifest = archive.getManifest(); manifestClasspath = manifest.getClassPathTokenized(); } if (manifestClasspath == null) { manifestClasspath = new String[0]; } } return manifestClasspath; } }
protected void traverseClasspaths(List projectCpEntries, Set visited) { File aFile = null; try { aFile = getEARFile().getFile(getText()); } catch (FileNotFoundException notThere) { } if (aFile == null || !aFile.isArchive()) return; Archive depArchive = (Archive) aFile; String[] manifestCpEntries = depArchive.getManifest().getClassPathTokenized(); for (int i = 0; i < manifestCpEntries.length; i++) { String uri = ArchiveUtil.deriveEARRelativeURI(manifestCpEntries[i], depArchive); if (uri == null) continue; ClasspathElement other = parentSelection.getClasspathElement(uri); //If the other element is already selected, then // we don't need to add it again if (other == null || other.isSelected()) continue; IClasspathEntry[] cpEntries = other.newClasspathEntries(visited); for (int j = 0; j < cpEntries.length; j++) { if (!projectCpEntries.contains(cpEntries[j])) projectCpEntries.add(cpEntries[j]); } } }
protected Object getResourceInDependentJarInEAR(String name, Set visitedArchives, int type) { String[] classpath = archive.getManifest().getClassPathTokenized(); for (int i = 0; i < classpath.length; i++) { try { String uri = ArchiveUtil.deriveEARRelativeURI(classpath[i], archive); if (uri == null) continue; File jarFile = getEARFile().getFile(uri); if (jarFile.isArchive()) { Archive dep = (Archive) jarFile; switch (type) { case CLASS_TYPE : try { return ((ArchiveFileDynamicClassLoader) dep.getArchiveClassLoader()).loadClass(name, visitedArchives); } catch (ClassNotFoundException noDice) { continue; } case FILE_TYPE : try { return dep.getFile(name); } catch (FileNotFoundException noDice) { continue; } } } } catch (java.io.FileNotFoundException depJarNotInEAR) { } } return null; }
public void validateManifestClasspath(Archive anArchive) throws ValidationException { ArchiveManifest manifest = null; try{ manifest = anArchive.getManifest(); }catch( ManifestException mf){
copy.setXmlEncoding(source.getXmlEncoding()); if (source.isManifestSet()) { copy.setManifest(copy(source.getManifest())); } else { try {