protected Module createModuleForCopying(ModuleFile aModuleFile) { Module aModule = null; if (aModuleFile.isWARFile()) { aModule = getApplicationFactory().createWebModule(); } else if (aModuleFile.isEJBJarFile()) { aModule = getApplicationFactory().createEjbModule(); } else if (aModuleFile.isApplicationClientFile()) { aModule = getApplicationFactory().createJavaClientModule(); } else if (aModuleFile.isRARFile()) { aModule = getApplicationFactory().createConnectorModule(); } aModule.setUri(aModuleFile.getURI()); return aModule; }
public static boolean isJ2EE13(ModuleFile aModuleFile) { try { XMLResource xmlResource = (XMLResource) aModuleFile.getDeploymentDescriptorResource(); return xmlResource.getJ2EEVersionID() == J2EEVersionConstants.J2EE_1_3_ID; } catch (FileNotFoundException ex) { return false; } }
public static boolean isJ2EE13FastCheck(ModuleFile moduleFile) { if (moduleFile == null) return false; else if (moduleFile.isRARFile()) return true; InputStream in = null; String uri = moduleFile.getDeploymentDescriptorUri(); try { in = moduleFile.getInputStream(uri); DocumentType docType = XmlDocumentReader.readDocumentType(in, uri); if (docType == null) return false; String[] ids = getJ2EE13PublicAndSystemIdFor(moduleFile); if (ids == null) return false; return ids[0].equals(docType.getPublicId()) && ids[1].equals(docType.getSystemId()); } catch (IOException ex) { return false; } finally { try { if (in != null) in.close(); } catch (IOException ex) { //Ignore } } }
protected void copyImportStrategyIfNecessary(ModuleFile aModuleFile, ModuleFile copy) { if (!aModuleFile.isDeploymentDescriptorSet()) copy.setImportStrategy(aModuleFile.getImportStrategy().createImportStrategy(aModuleFile, copy)); }
protected Object primAddCopyRef(ModuleFile aModuleFile) throws DuplicateObjectException { //force this list to get initialized before the add EList refs = getModuleRefs(); if (aModuleFile.isEARFile()) //If it's an ear then just treat it like any other archive return super.addCopy(aModuleFile); checkAddValid(aModuleFile); ModuleFile copy = getCommonArchiveFactory().copy(aModuleFile); Module newModule = createModuleForCopying(aModuleFile); getFiles().add(copy); copy.initializeClassLoader(); if (!copy.getURI().equals(newModule.getUri())) copy.setURI(newModule.getUri()); getDeploymentDescriptor().getModules().add(newModule); ModuleRef aRef = createModuleRef(newModule, copy); refs.add(aRef); return aRef; }
public String getUri() { if (module != null) return module.getUri(); if (moduleFile != null) return moduleFile.getURI(); return null; }
protected void export() throws SaveFailureException, CoreException, InvocationTargetException, InterruptedException { IProgressMonitor subMonitor = new SubProgressMonitor(progressMonitor, EXPORT_WORK); IArchive archiveFromComponent = null; try { archiveFromComponent = JavaEEArchiveUtilities.INSTANCE.openArchive(getComponent()); JavaEEQuickPeek quickPeek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(archiveFromComponent); if (quickPeek.getJavaEEVersion() == J2EEConstants.JEE_5_0_ID) { saveArchive(archiveFromComponent, getDestinationPath().toOSString(), subMonitor); } else { createModuleFile(); ((ComponentLoadStrategyImpl) (getModuleFile().getLoadStrategy())).setProgressMonitor(subMonitor); getModuleFile().saveAsNoReopen(getDestinationPath().toOSString()); } } catch (SaveFailureException ex) { throw ex; } catch (Exception e) { throw new SaveFailureException(EJBArchiveOpsResourceHandler.ARCHIVE_OPERATION_OpeningArchive, e); } finally { if (archiveFromComponent != null) JavaEEArchiveUtilities.INSTANCE.closeArchive(archiveFromComponent); subMonitor.done(); } }
public static int getFastSpecVersion(ModuleFile moduleFile) { InputStream in = null; String uri = moduleFile.getDeploymentDescriptorUri(); try { in = moduleFile.getInputStream(uri);
public void export() throws SaveFailureException, CoreException, InvocationTargetException, InterruptedException { IProgressMonitor subMonitor = new SubProgressMonitor(progressMonitor, EXPORT_WORK); IArchive archiveFromComponent = null; try { archiveFromComponent = JavaEEArchiveUtilities.INSTANCE.openArchive(getComponent()); JavaEEQuickPeek quickPeek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(archiveFromComponent); if (quickPeek.getJavaEEVersion() == J2EEConstants.JEE_5_0_ID) { saveArchive(archiveFromComponent, getDestinationPath().toOSString(), subMonitor); } else { CommonarchiveFactory caf = ((CommonarchivePackage) EPackage.Registry.INSTANCE.getEPackage(CommonarchivePackage.eNS_URI)).getCommonarchiveFactory(); AppClientComponentLoadStrategyImpl ls = new AppClientComponentLoadStrategyImpl(getComponent()); ls.setExportSource(isExportSource()); setModuleFile(caf.openApplicationClientFile(ls, getDestinationPath().toOSString())); ls.setProgressMonitor(subMonitor); getModuleFile().saveAsNoReopen(getDestinationPath().toOSString()); } } catch (SaveFailureException ex) { throw ex; } catch (Exception e) { throw new SaveFailureException(AppClientArchiveOpsResourceHandler.ARCHIVE_OPERATION_OpeningArchive, e); } finally { if (archiveFromComponent != null) JavaEEArchiveUtilities.INSTANCE.closeArchive(archiveFromComponent); subMonitor.done(); } }
/** * @generated This field/method will be replaced during code generation */ public ModuleFile getModuleFileGen() { if (moduleFile != null && moduleFile.eIsProxy()) { InternalEObject oldModuleFile = (InternalEObject)moduleFile; moduleFile = (ModuleFile)eResolveProxy(oldModuleFile); if (moduleFile != oldModuleFile) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, CommonarchivePackage.MODULE_REF__MODULE_FILE, oldModuleFile, moduleFile)); } } return moduleFile; }
/** * @see Command */ public void execute() { results = new ArrayList(); validatateXml(); if (isValidateNested()) { List archives = archive.getArchiveFiles(); for (int i = 0; i < archives.size(); i++) { Archive a = (Archive) archives.get(i); if (!a.isModuleFile()) continue; ModuleFile m = (ModuleFile) a; ValidateXmlCommand cmd = new ValidateXmlCommand(m); cmd.execute(); results.addAll(cmd.getResult()); } } }
protected boolean shouldSave(File aFile) { boolean loaded = isLoadedResourceOrManifest(aFile); if (loaded) { Resource res = archive.getLoadStrategy().getExistingMofResource(aFile.getURI()); if (res == null) return false; //must be manifest return !shouldSave(res); } if (getArchive().isModuleFile()) { ModuleFile m = (ModuleFile) getArchive(); if (m.getExportStrategy() != null && m.getExportStrategy().hasSaved(aFile.getURI())) return false; } return shouldSave(aFile.getURI()); }
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { setComponent((IVirtualComponent) model.getProperty(IJ2EEComponentExportDataModelProperties.COMPONENT)); setDestinationPath(new Path(model.getStringProperty(IJ2EEComponentExportDataModelProperties.ARCHIVE_DESTINATION))); setExportSource(model.getBooleanProperty(IJ2EEComponentExportDataModelProperties.EXPORT_SOURCE_FILES)); try { monitor.beginTask(ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Exporting_archive, new Object [] { getDestinationPath().lastSegment() }), computeTotalWork()); setProgressMonitor(monitor); // defect 240999 component.getProject().refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, REFRESH_WORK)); if (model.getBooleanProperty(IJ2EEComponentExportDataModelProperties.RUN_BUILD)) { runNecessaryBuilders(component, new SubProgressMonitor(monitor, JAVA_BUILDER_WORK + LIB_BUILDER_WORK)); } export(); } catch (Exception e) { if(moduleFile != null){ //The module fil will be closed if the export succeeds //Need to be careful not to close the archive twice because of ReferenceCounted Archives moduleFile.close(); monitor.worked(CLOSE_WORK); } throw new ExecutionException(EJBArchiveOpsResourceHandler.Error_exporting__UI_ + archiveString(), e); } finally { monitor.done(); } return OK_STATUS; }
protected void invalidDepedencyWarning(String entry, Archive anArchive, ModuleFile m) { String[] params = new String[3]; params[0] = m.getURI(); params[1] = entry; params[2] = anArchive.getURI(); String msg = NLS.bind(EARValidationMessageResourceHandler.INVALID_MANIFEST_CLASSPATH_DEPENDENCY_WARN_, params); addLocalizedWarning(msg, getManifestFile(anArchive), MANIFEST_GROUP_NAME); }
public static boolean isJ2EE13FastCheck(ModuleFile moduleFile) { if (moduleFile == null) return false; else if (moduleFile.isRARFile()) return true; InputStream in = null; String uri = moduleFile.getDeploymentDescriptorUri(); try { in = moduleFile.getInputStream(uri); DocumentType docType = XmlDocumentReader.readDocumentType(in, uri); if (docType == null) return false; String[] ids = getJ2EE13PublicAndSystemIdFor(moduleFile); if (ids == null) return false; return ids[0].equals(docType.getPublicId()) && ids[1].equals(docType.getSystemId()); } catch (IOException ex) { return false; } finally { try { if (in != null) in.close(); } catch (IOException ex) { //Ignore } } }
/** * Checks if the modules are a spec level too high for the EAR file. */ private void validateSpecLevel() { int earVersion = getVersionID(earFile); List modules = earFile.getModuleFiles(); if( !modules.isEmpty() ) { Iterator iterator = modules.iterator(); ModuleFile moduleFile = null; while (iterator.hasNext()) { moduleFile = (ModuleFile)iterator.next(); if (moduleFile != null && getVersionID(moduleFile) > earVersion) { String[] params = new String[] {moduleFile.getURI(), earFile.getName()}; String tmp = NLS.bind(EARValidationMessageResourceHandler.MESSAGE_INCOMPATIBLE_SPEC_WARNING_, params); addLocalizedWarning(tmp, appDD); } } } }
public static boolean isJ2EE14(ModuleFile aModuleFile) { try { XMLResource xmlResource = (XMLResource) aModuleFile.getDeploymentDescriptorResource(); return xmlResource.getJ2EEVersionID() == J2EEVersionConstants.J2EE_1_4_ID; } catch (FileNotFoundException ex) { return false; } }
/** * @param moduleFile * @return */ private int getVersionID(ModuleFile moduleFile) { XMLResource res = null; try { res = (XMLResource) moduleFile.getDeploymentDescriptorResource(); } catch (ResourceLoadException e) { //Ignore } catch (FileNotFoundException e) { //Ignore } if (res != null) return res.getJ2EEVersionID(); return -1; }
protected EObject primLoadDeploymentDescriptor() throws Exception { Resource resource = null; resource = getModuleFile().getDeploymentDescriptorResource(); EObject root = null; root = ArchiveUtil.getRoot(resource); return root; } }