diff options
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive')
28 files changed, 0 insertions, 3165 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientArchiveOpsResourceHandler.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientArchiveOpsResourceHandler.java deleted file mode 100644 index 8111e913d..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientArchiveOpsResourceHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.osgi.util.NLS; - -public final class AppClientArchiveOpsResourceHandler extends NLS { - - private static final String BUNDLE_NAME = "appclientarchiveops";//$NON-NLS-1$ - - private AppClientArchiveOpsResourceHandler() { - // Do not instantiate - } - - public static String ARCHIVE_OPERATION_SaveFile; - public static String ARCHIVE_OPERATION_ProjectNature; - public static String ARCHIVE_OPERATION_SaveManifest; - public static String ARCHIVE_OPERATION_FileNotFound; - public static String ARCHIVE_OPERATION_OpeningArchive; - public static String ARCHIVE_OPERATION_ImportOperation; - public static String IMPORT_MOFRESOURCE_STRING; - public static String APPCLIENT_IMPORT_OPERATION_STRING; - public static String APPCLIENT_IMPORT_FILE_STRING; - public static String APPCLIENT_IMPORT_ERROR; - public static String ARCHIVE_OPERATION_ErrorOccured; - public static String Application_Client_File_UI_; - public static String _c__Copyright_IBM_Corporation_2001_1; - - static { - NLS.initializeMessages(BUNDLE_NAME, AppClientArchiveOpsResourceHandler.class); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentExportOperation.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentExportOperation.java deleted file mode 100644 index fb1f245b3..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentExportOperation.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory; -import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class AppClientComponentExportOperation extends J2EEArtifactExportOperation { - - public AppClientComponentExportOperation(IDataModel model) { - super(model); - } - - public void export() throws SaveFailureException, CoreException, InvocationTargetException, InterruptedException { - IProgressMonitor subMonitor = new SubProgressMonitor(progressMonitor, EXPORT_WORK); - try { - 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 { - subMonitor.done(); - } - } - - protected String archiveString() { - return AppClientArchiveOpsResourceHandler.Application_Client_File_UI_; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentImportOperation.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentImportOperation.java deleted file mode 100644 index 5f88a9581..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentImportOperation.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategy; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class AppClientComponentImportOperation extends J2EEArtifactImportOperation { - - public AppClientComponentImportOperation(IDataModel model) { - super(model); - } - - protected SaveStrategy createSaveStrategy(IVirtualComponent virtualComponent) { - AppClientComponentSaveStrategyImpl saveStrat = new AppClientComponentSaveStrategyImpl(virtualComponent); - return saveStrat; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentLoadStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentLoadStrategyImpl.java deleted file mode 100644 index 953444498..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentLoadStrategyImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class AppClientComponentLoadStrategyImpl extends ComponentLoadStrategyImpl { - - public AppClientComponentLoadStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentSaveStrategyImpl.java deleted file mode 100644 index 7c769bd1e..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/AppClientComponentSaveStrategyImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class AppClientComponentSaveStrategyImpl extends J2EEComponentSaveStrategyImpl { - - public AppClientComponentSaveStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentLoadStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentLoadStrategyImpl.java deleted file mode 100644 index 4366f10bf..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentLoadStrategyImpl.java +++ /dev/null @@ -1,616 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ResourceLoadException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.FileIterator; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.FileIteratorImpl; -import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ContainerImpl; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.LoadStrategyImpl; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.DependencyType; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualContainer; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -public abstract class ComponentLoadStrategyImpl extends LoadStrategyImpl { - - protected static final String DOT_PROJECT = ".project"; //$NON-NLS-1$ - protected static final String DOT_CLASSPATH = ".classpath"; //$NON-NLS-1$ - protected static final String DOT_SETTINGS = ".settings"; //$NON-NLS-1$ - protected static final String DOT_CVS_IGORE = ".cvsignore"; //$NON-NLS-1$ - - protected IVirtualComponent vComponent; - protected boolean exportSource; - private ArtifactEdit artifactEdit; - private List zipFiles = new ArrayList(); - - protected class FilesHolder { - - private Map urisToFiles = new HashMap(); - private Map urisToResources = new HashMap(); - private Map resourcesToURI = new HashMap(); - private Map urisToDiskFiles; - private Map urisToZipEntry = new HashMap(); - - public void removeIFile(IFile file) { - String uri = (String) resourcesToURI.get(file); - remove(uri); - } - - public void remove(String uri) { - urisToFiles.remove(uri); - Object resource = urisToResources.remove(uri); - if (resource != null) { - resourcesToURI.remove(resource); - } - if (urisToDiskFiles != null) { - urisToDiskFiles.remove(uri); - } - } - - public void addDirectory(File directory) { - String uri = directory.getURI(); - urisToFiles.put(uri, directory); - } - - public void addFile(File file) { - String uri = file.getURI(); - urisToFiles.put(uri, file); - } - - public void addFile(File file, java.io.File externalDiskFile) { - String uri = file.getURI(); - urisToFiles.put(uri, file); - if (null == urisToDiskFiles) { - urisToDiskFiles = new HashMap(); - } - urisToDiskFiles.put(uri, externalDiskFile); - } - - public void addFile(File file, IResource resource) { - String uri = file.getURI(); - urisToFiles.put(uri, file); - urisToResources.put(uri, resource); - } - - public InputStream getInputStream(String uri) throws IOException, FileNotFoundException { - java.io.File diskFile = null; - - if (urisToDiskFiles != null && urisToDiskFiles.containsKey(uri)) { - diskFile = (java.io.File) urisToDiskFiles.get(uri); - } else if (urisToResources != null && urisToResources.containsKey(uri)) { - IResource resource = (IResource) urisToResources.get(uri); - diskFile = new java.io.File(resource.getLocation().toOSString()); - } else { - Map fileURIMap = (Map) urisToZipEntry.get(uri); - Iterator it = fileURIMap.keySet().iterator(); - - String sourceFileUri = ""; //$NON-NLS-1$ - ZipFile zipFile = null; - - // there is only one key, pair - while (it.hasNext()) { - sourceFileUri = (String) it.next(); - zipFile = (ZipFile) fileURIMap.get(sourceFileUri); - } - ZipEntry entry = zipFile.getEntry(sourceFileUri); - InputStream in = zipFile.getInputStream(entry); - return in; - } - return new FileInputStream(diskFile); - } - - public List getFiles() { - return new ArrayList(urisToFiles.values()); - } - - public boolean contains(String uri) { - return urisToFiles.containsKey(uri); - } - - public void addEntry(ZipEntry entry, ZipFile zipFile, IPath runtimePath) { - String uri = runtimePath == null ? null : runtimePath.toString(); - String fileURI = ""; //$NON-NLS-1$ - if (uri != null) { - if (!uri.equals("/")) //$NON-NLS-1$ - fileURI = uri + entry.getName(); - else - fileURI = entry.getName(); - } else { - fileURI = entry.getName(); - } - - File file = createFile(fileURI); - - Map fileURIMap = new HashMap(); - fileURIMap.put(entry.getName(), zipFile); - - urisToZipEntry.put(file.getURI(), fileURIMap); - urisToFiles.put(file.getURI(), file); - } - } - - protected FilesHolder filesHolder; - - private Exception exception; //TEMP TODO REMOVE - - public ComponentLoadStrategyImpl(IVirtualComponent vComponent) { - this.vComponent = vComponent; - filesHolder = new FilesHolder(); - exception = new Exception(); - } - - public boolean contains(String uri) { - IVirtualFolder rootFolder = vComponent.getRootFolder(); - return rootFolder.getFile(new Path(uri)).exists(); - } - - protected void initializeResourceSet() { - resourceSet = WorkbenchResourceHelperBase.getResourceSet(vComponent.getProject()); - } - - protected boolean primContains(String uri) { - return false; - } - - public List getFiles() { - aggregateSourceFiles(); - aggregateClassFiles(); - addUtilities(); - return filesHolder.getFiles(); - } - - protected void addUtilities() { - IVirtualReference[] components = vComponent.getReferences(); - for (int i = 0; i < components.length; i++) { - IVirtualReference reference = components[i]; - IVirtualComponent referencedComponent = reference.getReferencedComponent(); - - if (referencedComponent.isBinary() && reference.getDependencyType() == DependencyType.CONSUMES) { - java.io.File diskFile = ((VirtualArchiveComponent) referencedComponent).getUnderlyingDiskFile(); - ZipFile zipFile; - IPath path = reference.getRuntimePath(); - try { - zipFile = new ZipFile(diskFile); - zipFiles.add(zipFile); - Enumeration enumeration = zipFile.entries(); - while (enumeration.hasMoreElements()) { - ZipEntry entry = (ZipEntry) enumeration.nextElement(); - filesHolder.addEntry(entry, zipFile, path); - } - } catch (ZipException e) { - Logger.getLogger().logError(e); - } catch (IOException e) { - Logger.getLogger().logError(e); - } - } - } - } - - /** - * This is a cache of the IResource roots for all java source folders and is used by - * {@link #inJavaSrc(IVirtualResource)}. - */ - private IResource[] sourceRoots = null; - - protected void aggregateSourceFiles() { - try { - IVirtualFolder rootFolder = vComponent.getRootFolder(); - IVirtualResource[] members = rootFolder.members(); - IPackageFragmentRoot[] srcPkgs = J2EEProjectUtilities.getSourceContainers(vComponent.getProject()); - sourceRoots = new IResource[srcPkgs.length]; - for (int i = 0; i < srcPkgs.length; i++) { - sourceRoots[i] = srcPkgs[i].getCorrespondingResource(); - } - inJavaSrc = false; - aggregateFiles(members); - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - - protected void aggregateClassFiles() { - StructureEdit se = null; - try { - IPackageFragmentRoot[] sourceRoots = J2EEProjectUtilities.getSourceContainers(vComponent.getProject()); - se = StructureEdit.getStructureEditForRead(vComponent.getProject()); - for (int i = 0; i < sourceRoots.length; i++) { - IPath outputPath = sourceRoots[i].getRawClasspathEntry().getOutputLocation(); - if (outputPath == null) { - IProject project = vComponent.getProject(); - if (project.hasNature(JavaCore.NATURE_ID)) { - IJavaProject javaProject = JavaCore.create(project); - outputPath = javaProject.getOutputLocation(); - } - } - - if (outputPath != null) { - IContainer javaOutputContainer = outputPath.segmentCount() > 1 ? (IContainer) ResourcesPlugin.getWorkspace().getRoot().getFolder(outputPath) : (IContainer) ResourcesPlugin.getWorkspace().getRoot().getProject(outputPath.lastSegment()); - IPath runtimePath = null; - try { - ComponentResource[] componentResources = se.findResourcesBySourcePath(sourceRoots[i].getResource().getProjectRelativePath()); - if (componentResources.length > 0) { - IPath tmpRuntimePath = componentResources[0].getRuntimePath(); - IPath tmpSourcePath = componentResources[0].getSourcePath(); - if (!tmpRuntimePath.equals(tmpSourcePath)) { - while (tmpSourcePath.segmentCount() > 0 && tmpRuntimePath.segmentCount() > 0 && tmpRuntimePath.lastSegment().equals(tmpSourcePath.lastSegment())) { - tmpRuntimePath = tmpRuntimePath.removeLastSegments(1); - tmpSourcePath = tmpSourcePath.removeLastSegments(1); - } - if (tmpRuntimePath.segmentCount() != 0) { - runtimePath = tmpRuntimePath.makeRelative(); - } - } - } - } catch (UnresolveableURIException e) { - Logger.getLogger().logError(e); - } - if (null == runtimePath) { - runtimePath = new Path(""); //$NON-NLS-1$ - } - - aggregateOutputFiles(new IResource[]{javaOutputContainer}, runtimePath, javaOutputContainer.getProjectRelativePath().segmentCount()); - } - } - } catch (CoreException e) { - Logger.getLogger().logError(e); - } finally { - if (se != null) { - se.dispose(); - } - } - } - - protected boolean aggregateOutputFiles(IResource[] resources, final IPath runtimePathPrefix, int outputFolderSegmentCount) throws CoreException { - boolean fileAdded = false; - for (int i = 0; i < resources.length; i++) { - File cFile = null; - if (!resources[i].exists()) { - continue; - } - // We have to avoid duplicates between the source and output folders (non-java - // resources) - IPath runtimePath = runtimePathPrefix.append(resources[i].getProjectRelativePath().removeFirstSegments(outputFolderSegmentCount)); - String uri = runtimePath == null ? null : runtimePath.toString(); - if (uri == null) - continue; - if (resources[i].getType() == IResource.FILE) { - if (!shouldInclude(uri)) - continue; - cFile = createFile(uri); - cFile.setLastModified(getLastModified(resources[i])); - filesHolder.addFile(cFile, resources[i]); - fileAdded = true; - } else if (shouldInclude((IContainer) resources[i])) { - IResource[] nestedResources = ((IContainer) resources[i]).members(); - aggregateOutputFiles(nestedResources, runtimePathPrefix, outputFolderSegmentCount); - if(!filesHolder.contains(uri)){ - if (!shouldInclude(uri)) - continue; - cFile = createDirectory(uri); - cFile.setLastModified(getLastModified(resources[i])); - filesHolder.addDirectory(cFile); - fileAdded = true; - } - } - } - return fileAdded; - } - - /** - * This is used to track whether {@link #aggregateFiles(IVirtualResource[])} is currently within a Java Source folder. - */ - private boolean inJavaSrc = false; - - protected boolean aggregateFiles(IVirtualResource[] virtualResources) throws CoreException { - boolean fileAdded = false; - for (int i = 0; i < virtualResources.length; i++) { - File cFile = null; - if (!virtualResources[i].exists()) { - continue; - } - // We have to avoid duplicates between the source and output folders (non-java - // resources) - IPath runtimePath = virtualResources[i].getRuntimePath(); - String uri = runtimePath == null ? null : runtimePath.toString(); - if (uri == null) - continue; - if (uri.charAt(0) == IPath.SEPARATOR) { - uri = uri.substring(1); - } - if (filesHolder.contains(uri)) - continue; - - if (virtualResources[i].getType() == IVirtualResource.FILE) { - if (!shouldInclude(uri)) - continue; - IResource resource = virtualResources[i].getUnderlyingResource(); - // want to ignore derived resources nested within Java src directories; this covers the case where - // a user has nested a Java output directory within a Java src directory (note: should ideally be - // respecting Java src path exclusion filters) - if (inJavaSrc && resource.isDerived()) { - continue; - } - cFile = createFile(uri); - cFile.setLastModified(getLastModified(resource)); - filesHolder.addFile(cFile, resource); - fileAdded = true; - } else if (shouldInclude((IVirtualContainer) virtualResources[i])) { - boolean inJavaSrcAtThisLevel = inJavaSrc; - try { - if (!inJavaSrc) { - // if not already inside a Java src dir, check again - inJavaSrc = inJavaSrc(virtualResources[i]); - } - IVirtualResource[] nestedVirtualResources = ((IVirtualContainer) virtualResources[i]).members(); - aggregateFiles(nestedVirtualResources); - if(!filesHolder.contains(uri)){ - if (!shouldInclude(uri)) - continue; - IResource resource = virtualResources[i].getUnderlyingResource(); - if (inJavaSrc && resource.isDerived()) { - continue; - } - cFile = createDirectory(uri); - cFile.setLastModified(getLastModified(resource)); - filesHolder.addDirectory(cFile); - fileAdded = true; - } - } finally { - inJavaSrc = inJavaSrcAtThisLevel; - } - } - } - return fileAdded; - } - - /** - * Determines if the specified IVirtualResource maps to a IResource that is contained within a Java src root. - * @param virtualResource IVirtualResource to check. - * @param sourceRoots Current Java src roots. - * @return True if contained in a Java src root, false otherwise. - */ - private boolean inJavaSrc(final IVirtualResource virtualResource) { - if (sourceRoots.length == 0) { - return false; - } - // all mapped resources must be associated with Java src for the resource to be considered in Java src - final IResource[] resources = virtualResource.getUnderlyingResources(); - boolean inJavaSrc = false; - for (int i = 0; i < resources.length; i++) { - inJavaSrc = false; - for (int j = 0; j < sourceRoots.length; j++) { - if (sourceRoots[j].getFullPath().isPrefixOf(resources[i].getFullPath())) { - inJavaSrc = true; - break; - } - } - // if this one was not in Java src, can break - if (!inJavaSrc) { - break; - } - } - - return inJavaSrc; - } - - protected long getLastModified(IResource aResource) { - return aResource.getLocation().toFile().lastModified(); - } - - public void setExportSource(boolean newExportSource) { - exportSource = newExportSource; - } - - public boolean isExportSource() { - return exportSource; - } - - protected boolean shouldInclude(IContainer aContainer) { - return true; - } - - protected boolean shouldInclude(IVirtualContainer vContainer) { - IContainer iContainer = (IContainer) vContainer.getUnderlyingResource(); - return shouldInclude(iContainer); - } - - protected boolean shouldInclude(String uri) { - if (uri.length() == 0 || DOT_PROJECT.equals(uri) || DOT_CLASSPATH.equals(uri) || uri.endsWith(DOT_CVS_IGORE) || uri.startsWith(DOT_SETTINGS)){ - return false; - } - return isExportSource() || !isSource(uri); - } - - protected boolean isSource(String uri) { - if (uri == null) - return false; - return uri.endsWith(ArchiveUtil.DOT_JAVA) || uri.endsWith(ArchiveUtil.DOT_SQLJ); - } - - protected void addExternalFile(String uri, java.io.File externalDiskFile) { - File aFile = createFile(uri); - filesHolder.addFile(aFile, externalDiskFile); - } - - public InputStream getInputStream(String uri) throws IOException, FileNotFoundException { - if (filesHolder.contains(uri)) { - return filesHolder.getInputStream(uri); - } - IVirtualFolder rootFolder = vComponent.getRootFolder(); - IVirtualResource vResource = rootFolder.findMember(uri); - String filePath = null; - if (null != vResource && vResource.exists()) { - filePath = vResource.getUnderlyingResource().getLocation().toOSString(); - java.io.File file = new java.io.File(filePath); - return new FileInputStream(file); - } - String eString = EARArchiveOpsResourceHandler.ARCHIVE_OPERATION_FileNotFound; - throw new FileNotFoundException(eString); - } - - public Collection getLoadedMofResources() { - Collection resources = super.getLoadedMofResources(); - Collection resourcesToRemove = new ArrayList(); - Iterator iterator = resources.iterator(); - while (iterator.hasNext()) { - Resource res = (Resource) iterator.next(); - //only remove component files that are in the settings directory - if (res.getURI().toString().endsWith(IModuleConstants.COMPONENT_FILE_NAME) && res.getURI().segmentsList().contains(IModuleConstants.DOT_SETTINGS)) - resourcesToRemove.add(res); - } - if (null != resourcesToRemove) { - resources.removeAll(resourcesToRemove); - } - - return resources; - } - - protected synchronized ArtifactEdit getArtifactEditForRead() { - if(artifactEdit == null){ - artifactEdit = ArtifactEdit.getArtifactEditForRead(vComponent); - } - return artifactEdit; - } - - public Resource getMofResource(String uri) throws FileNotFoundException, ResourceLoadException { - return getArtifactEditForRead().getResource(URI.createURI(uri)); - } - - public boolean isClassLoaderNeeded() { - return false; - } - - public IVirtualComponent getComponent() { - return vComponent; - } - - protected IProgressMonitor monitor = null; - - public void setProgressMonitor(IProgressMonitor monitor){ - this.monitor = monitor; - } - - protected final int FILE_SAVE_WORK = 100; - - public FileIterator getFileIterator() throws IOException { - return new FileIteratorImpl(getContainer().getFiles()){ - protected SubProgressMonitor lastSubMon = null; - boolean firstVisit = true; - - public File next() { - if(firstVisit){ - firstVisit = false; - if(monitor != null){ - monitor.beginTask(ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Exporting_archive, new Object [] { getContainer().getURI() }), files.size() * FILE_SAVE_WORK); - } - } - if(lastSubMon != null){ - lastSubMon.done(); - lastSubMon = null; - } else if(monitor != null){ - monitor.worked(FILE_SAVE_WORK); - } - File file = super.next(); - if(monitor != null){ - if(file.isContainer() && ComponentLoadStrategyImpl.class.isInstance(((ContainerImpl)file).getLoadStrategy())){ - ComponentLoadStrategyImpl ls = (ComponentLoadStrategyImpl)((ContainerImpl)file).getLoadStrategy(); - lastSubMon = new SubProgressMonitor(monitor, FILE_SAVE_WORK, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); - ls.setProgressMonitor(lastSubMon); - } else { - monitor.subTask(file.getURI()); - } - } - return file; - } - }; - - } - - public void close() { - if(Thread.currentThread().toString().toLowerCase().indexOf("finalizer") != -1){ - System.err.println("Opener of Archive didn't close! "+this); - exception.printStackTrace(System.err); - } - - try{ - Iterator it = zipFiles.iterator(); - while (it.hasNext()) { - ZipFile file = (ZipFile) it.next(); - try { - file.close(); - } catch (IOException e) { - Logger.getLogger().logError(e); - } - } - } finally{ - try{ - synchronized(this) { - if(artifactEdit != null){ - ArtifactEditModel editModel = (ArtifactEditModel)artifactEdit.getAdapter(ArtifactEditModel.class); - if(editModel != null && !editModel.isDisposed()){ - artifactEdit.dispose(); - } - artifactEdit = null; - } - } - } finally { - super.close(); - } - } - - } -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentSaveStrategyImpl.java deleted file mode 100644 index 7f8bfaf8e..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentSaveStrategyImpl.java +++ /dev/null @@ -1,283 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategy; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategyImpl; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -public abstract class ComponentSaveStrategyImpl extends SaveStrategyImpl { - - protected IDataModel dataModel; - protected IVirtualComponent vComponent; - protected IOverwriteHandler overwriteHandler; - protected IProgressMonitor progressMonitor; - - private String archiveComponentsDeployPath; - private List archiveComponents; - private Map archiveComponentURIMap; - private Map archiveComponentDeployPathMap; - - public ComponentSaveStrategyImpl(IVirtualComponent vComponent) { - super(); - if (null == vComponent) { - throw new NullPointerException(); - } - this.vComponent = vComponent; - } - - public void setDataModel(IDataModel dataModel) { - this.dataModel = dataModel; - } - - public void setOverwriteHandler(IOverwriteHandler newOverwriteHandler) { - overwriteHandler = newOverwriteHandler; - } - - public void setProgressMonitor(IProgressMonitor newProgressMonitor) { - progressMonitor = newProgressMonitor; - } - - protected void validateEdit(IFile aFile) { - if (overwriteHandler == null) - return; - if (!(aFile.exists() && aFile.isReadOnly())) - return; - - overwriteHandler.validateEdit(aFile); - } - - protected boolean shouldOverwrite(String uri) { - if (overwriteHandler.isOverwriteNone()) - return false; - return (overwriteHandler.isOverwriteResources() || overwriteHandler.isOverwriteAll() || overwriteHandler.shouldOverwrite(uri)); - } - - protected SaveStrategy createNestedSaveStrategy(Archive anArchive) throws IOException { - return null; - } - - protected OutputStream getOutputStreamForResource(Resource aResource) throws IOException { - // this method has no references in the hirarchy - return null; - } - - protected void saveFiles() throws SaveFailureException { - super.saveFiles(); - linkArchiveComponents(); - } - - public void save(File aFile, InputStream in) throws SaveFailureException { - try { - progressMonitor.subTask(aFile.getURI()); - - IPath projectRelativePath = getOutputPathForFile(aFile); - if (aFile.isArchive()) { - saveAsArchiveComponent((Archive) aFile, projectRelativePath, in); - } else if (!aFile.isDirectoryEntry()) { - saveToOutputPath(projectRelativePath, in); - } else { - createDirectory(projectRelativePath); - } - } catch (OverwriteHandlerException ohe) { - throw ohe; - } catch (Exception e) { - String errorString = EJBArchiveOpsResourceHandler.ARCHIVE_OPERATION_SaveFile + aFile.getName(); - throw new SaveFailureException(errorString, e); - } finally { - progressMonitor.worked(1); - } - } - - //TODO this should be renamed to getProjectRelativePath - /** - * Returns the project relative path for where the specified file should be - * saved. - * - * @param aFile - * @return - */ - protected IPath getOutputPathForFile(File aFile) { - String uri = aFile.getURI(); - IFile iFile = null; - if(uri.startsWith(IModuleConstants.DOT_SETTINGS)){ - iFile = vComponent.getProject().getFile(new Path(uri)); - }else { - IVirtualFolder rootFolder = vComponent.getRootFolder(); - IVirtualFile vFile = rootFolder.getFile(aFile.getURI()); - iFile = vFile.getUnderlyingFile(); - } - return iFile.getProjectRelativePath(); - } - - //TODO This isn't referenced in WTP it should be deleted. - /** - * @deprecated - */ - protected void saveToWorkbenchPath(IPath workbenchPath, InputStream in) throws Exception { - IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(workbenchPath); - saveToIFile(iFile, in); - } - - /** - * Creates the IFolder specified by the project relative path. - * - * @param projectRelativePath - * @throws CoreException - */ - protected void createDirectory(IPath projectRelativePath) throws CoreException { - IFolder iFolder = vComponent.getProject().getFolder(projectRelativePath); - if (!iFolder.exists()) { - mkdirs(iFolder); - } - } - - /** - * Creates the specified IFolder - * - * @param folder - * @throws CoreException - */ - protected void mkdirs(IFolder folder) throws CoreException { - IContainer container = folder.getParent(); - if (!container.exists()) { - mkdirs((IFolder) container); - } - folder.create(true, true, null); - } - - /** - * Save the specified Archive to the specified project relative path - * using the passed input stream. - * - * @param archive - * @param projectRelativePath - * @param in - * @throws Exception - */ - protected void saveAsArchiveComponent(Archive archive, IPath projectRelativePath, InputStream in) throws Exception { - IFile iFile = saveToOutputPathIFile(projectRelativePath, in); - //TODO investigate removing this block and related variables and linkArchiveComponents(); see bugzilla 159160 - if (shouldLinkAsComponentRef(archive)) { - IVirtualComponent archiveComponent = ComponentCore.createArchiveComponent(vComponent.getProject(), VirtualArchiveComponent.LIBARCHIVETYPE + iFile.getFullPath().toString()); - if (archiveComponents == null) { - archiveComponents = new ArrayList(); - archiveComponentURIMap = new HashMap(); - archiveComponentDeployPathMap = new HashMap(); - archiveComponentsDeployPath = IPath.SEPARATOR + (new Path(archive.getURI())).removeLastSegments(1).toString(); - } - archiveComponents.add(archiveComponent); - archiveComponentURIMap.put(archiveComponent, iFile.getName()); - archiveComponentDeployPathMap.put(archiveComponent, IPath.SEPARATOR + (new Path(archive.getURI())).removeLastSegments(1).toString()); - } - } - - protected boolean shouldLinkAsComponentRef(Archive archive) { - return false; - } - - protected void linkArchiveComponents() { - if (archiveComponents != null && archiveComponents.size() > 0) { - IDataModel createReferencesDataModel = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider()); - createReferencesDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, vComponent); - createReferencesDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, archiveComponentsDeployPath); - createReferencesDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH_MAP, archiveComponentDeployPathMap); - createReferencesDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, archiveComponents); - createReferencesDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, archiveComponentURIMap); - try { - createReferencesDataModel.getDefaultOperation().execute(null, null); - } catch (ExecutionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - /** - * Saves to the specified project relative output path. Warning this method - * will be changed post 1.5 to return an IFile - * - * @param projectRelativePath - * @param in - * @throws Exception - */ - protected void saveToOutputPath(IPath projectRelativePath, InputStream in) throws Exception { - saveToOutputPathIFile(projectRelativePath, in); - } - - /** - * TODO refactor change the method above to return IFile - * {@link DoNotUseMeThisWillBeDeletedPost15} - */ - protected IFile saveToOutputPathIFile(IPath projectRelativePath, InputStream in) throws Exception { - IFile iFile = vComponent.getProject().getFile(projectRelativePath); - saveToIFile(iFile, in); - return iFile; - } - - - protected void saveToIFile(IFile iFile, InputStream in) throws Exception { - validateEdit(iFile); - if (iFile.exists()) - iFile.setContents(in, true, true, null); - else { - mkdirs(iFile.getFullPath().removeLastSegments(1), ResourcesPlugin.getWorkspace().getRoot()); - iFile.create(in, true, null); - } - } - - - protected void mkdirs(IPath path, IWorkspaceRoot root) throws CoreException { - if (path.segmentCount() <= 1) - return; - IFolder folder = root.getFolder(path); - if (!folder.exists()) { - mkdirs(path.removeLastSegments(1), root); - folder.create(true, true, null); - } - } - - public void save(ArchiveManifest aManifest) throws SaveFailureException { - } -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ConnectorComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ConnectorComponentSaveStrategyImpl.java deleted file mode 100644 index f0c4e7ae0..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ConnectorComponentSaveStrategyImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class ConnectorComponentSaveStrategyImpl extends J2EEComponentSaveStrategyImpl { - - public ConnectorComponentSaveStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/DependentJarExportMerger.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/DependentJarExportMerger.java deleted file mode 100644 index 6c5e888eb..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/DependentJarExportMerger.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.util.ArrayList; -import java.util.List; -import java.util.jar.Attributes; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory; -import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest; - -public class DependentJarExportMerger { - protected Archive outgoingArchive; - protected IProject project; - protected List dependentArchives; - protected boolean includeSource; - - /** - * DependentJarExportMerger constructor comment. - */ - public DependentJarExportMerger(Archive archive, IProject aProject, boolean includeSourceFiles) { - super(); - outgoingArchive = archive; - project = aProject; - includeSource = includeSourceFiles; - } - - protected void finalize() throws Throwable { - release(); - } - - public CommonarchiveFactory getArchiveFactory() { - return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory(); - } - - 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 mergeFiles(Archive dependentJar) { - List files = dependentJar.getFiles(); - List filesToAdd = new java.util.ArrayList(); - for (int i = 0; i < files.size(); i++) { - File aFile = (File) files.get(i); - if (shouldMerge(aFile)) - filesToAdd.add(aFile); - } - try { - outgoingArchive.addCopyFiles(filesToAdd); - } catch (DuplicateObjectException ignore) { - // Shouldn't happen because we just checked for dups - } - } - - /** - * Clients must call this when done to close the archives - */ - public void release() { - if (dependentArchives == null) - return; - for (int i = 0; i < dependentArchives.size(); i++) { - Archive anArchive = (Archive) dependentArchives.get(i); - if (anArchive.isOpen()) - anArchive.close(); - } - } - - 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)); - } - } - } - - protected boolean shouldMerge(File aFile) { - - String uri = aFile.getURI(); - if (!(uri.endsWith(".java") || uri.endsWith(".class")))//$NON-NLS-2$//$NON-NLS-1$ - return false; - if (!includeSource && uri.endsWith(".java"))//$NON-NLS-1$ - return false; - return !outgoingArchive.containsFile(uri) && !ArchiveConstants.MANIFEST_URI.equals(uri); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARArchiveOpsResourceHandler.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARArchiveOpsResourceHandler.java deleted file mode 100644 index 8dc663bc1..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARArchiveOpsResourceHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.osgi.util.NLS; - -public final class EARArchiveOpsResourceHandler extends NLS { - - private static final String BUNDLE_NAME = "eararchiveops";//$NON-NLS-1$ - - private EARArchiveOpsResourceHandler() { - // Do not instantiate - } - - public static String ARCHIVE_OPERATION_SaveMofResources; - public static String ARCHIVE_OPERATION_SaveFile; - public static String ARCHIVE_OPERATION_ProjectNature; - public static String ARCHIVE_OPERATION_SaveManifest; - public static String ARCHIVE_OPERATION_FileNotFound; - public static String ARCHIVE_OPERATION_FileContents; - public static String ARCHIVE_OPERATION_ErroOccured; - public static String ARCHIVE_OPERATION_FilesFromProject; - public static String ARCHIVE_OPERATION_OpeningArchive; - public static String ARCHIVE_OPERATION_ImportOperation; - public static String IMPORT_MOFRESOURCE_STRING; - public static String EAR_IMPORT_FILE_STRING; - public static String ERROR_IMPORTING_EAR_FILE; - public static String ERROR_EXPORTING_EAR_FILE; - public static String IMPORTING_EAR_FILE_UI_; - public static String Updating_project_classpath_UI_; - public static String UNABLE_TO_LOAD_MODULE_ERROR_; - public static String _jar_UI_; - public static String Updating_manifest_Class_Path__attributes_UI_; - public static String _preDeploy_ERROR_; - - static { - NLS.initializeMessages(BUNDLE_NAME, EARArchiveOpsResourceHandler.class); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentExportOperation.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentExportOperation.java deleted file mode 100644 index 4754514ae..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentExportOperation.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class EARComponentExportOperation extends J2EEArtifactExportOperation { - - public EARComponentExportOperation(IDataModel model) { - super(model); - } - - protected void export() throws SaveFailureException, CoreException, InvocationTargetException, InterruptedException { - IProgressMonitor subMonitor = new SubProgressMonitor(progressMonitor, EXPORT_WORK); - EARArtifactEdit artifactEdit = null; - try { - artifactEdit = (EARArtifactEdit) ComponentUtilities.getArtifactEditForRead(getComponent()); - EARFile archive = (EARFile) artifactEdit.asArchive(isExportSource()); - String destination = getDestinationPath().toOSString(); - archive.setURI(destination); - setModuleFile(archive); - ComponentLoadStrategyImpl ls = (ComponentLoadStrategyImpl)archive.getLoadStrategy(); - ls.setProgressMonitor(subMonitor); - archive.saveAsNoReopen(destination); - } catch (SaveFailureException ex) { - throw ex; - } catch (Exception e) { - throw new SaveFailureException(AppClientArchiveOpsResourceHandler.ARCHIVE_OPERATION_OpeningArchive, e); - } finally { - if (null != artifactEdit) { - artifactEdit.dispose(); - } - subMonitor.done(); - } - } - - protected void runNecessaryBuilders(IVirtualComponent component, IProgressMonitor monitor) throws CoreException { - try { - IVirtualReference[] refs = component.getReferences(); - int work = (JAVA_BUILDER_WORK + LIB_BUILDER_WORK) / (refs.length + 1); - super.runNecessaryBuilders(component, new SubProgressMonitor(monitor, work)); - for (int i = 0; i < refs.length; i++) { - IVirtualComponent refComp = refs[i].getReferencedComponent(); - super.runNecessaryBuilders(refComp, new SubProgressMonitor(monitor, work)); - } - } finally { - monitor.done(); - } - } - - - protected String archiveString() { - return "EAR"; - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentImportOperation.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentImportOperation.java deleted file mode 100644 index ba22c31f7..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentImportOperation.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider; -import org.eclipse.jst.j2ee.application.internal.operations.IAddComponentToEnterpriseApplicationDataModelProperties; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategy; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.datamodel.properties.IEARComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class EARComponentImportOperation extends J2EEArtifactImportOperation { - - protected EARArtifactEdit artifactEdit = null; - - protected final int LINK_COMPONENTS_WORK = 10; - protected final int WEB_LIB_WORK = 10; - protected final int DISPOSE_WORK = 10; - - public EARComponentImportOperation(IDataModel model) { - super(model); - } - - protected int computeTotalWork() { - int baseWork = super.computeTotalWork() + WEB_LIB_WORK + DISPOSE_WORK; - List modelsToImport = (List) model.getProperty(IEARComponentImportDataModelProperties.HANDLED_PROJECT_MODELS_LIST); - IDataModel importModel = null; - for (int i = 0; i < modelsToImport.size(); i++) { - importModel = (IDataModel) modelsToImport.get(i); - Archive nestedArchive = (Archive) importModel.getProperty(IEARComponentImportDataModelProperties.FILE); - baseWork += LINK_COMPONENTS_WORK + PROJECT_CREATION_WORK + nestedArchive.getFiles().size(); - } - return baseWork; - } - - /** - * Subclasses must override to performs the workbench modification steps that are to be - * contained within a single logical workbench change. - * - * @param monitor - * the progress monitor to use to display progress - */ - protected void doExecute(IProgressMonitor monitor) throws ExecutionException { - super.doExecute(monitor); - List modelsToImport = (List) model.getProperty(IEARComponentImportDataModelProperties.HANDLED_PROJECT_MODELS_LIST); - try { - IDataModel importModel = null; - // make sure the wars handle importing their own web libs - for (int i = modelsToImport.size() - 1; i > 0; i--) { - importModel = (IDataModel) modelsToImport.get(i); - Archive nestedArchive = (Archive) importModel.getProperty(IEARComponentImportDataModelProperties.FILE); - if (nestedArchive.getURI().startsWith(ArchiveConstants.WEBAPP_LIB_URI)) { - WARFile owningWar = (WARFile) nestedArchive.eContainer(); - modelsToImport.remove(importModel); - for (int j = 0; j < modelsToImport.size(); j++) { - IDataModel warModel = (IDataModel) modelsToImport.get(j); - if (warModel.getProperty(IEARComponentImportDataModelProperties.FILE) == owningWar) { - // TODO this is bad, but don't have access to the plugin where these - // constants are defined. - String archivesSelected = "WARImportDataModel.WEB_LIB_ARCHIVES_SELECTED"; //$NON-NLS-1$ - String libModels = "WARImportDataModel.WEB_LIB_MODELS"; //$NON-NLS-1$ - List warHandledArchives = (List) warModel.getProperty(archivesSelected); - if (warHandledArchives == Collections.EMPTY_LIST) { - warHandledArchives = new ArrayList(); - warModel.setProperty(archivesSelected, warHandledArchives); - } - warHandledArchives.add(nestedArchive); - List warLibModels = (List) warModel.getProperty(libModels); - for (int k = 0; k < warLibModels.size(); k++) { - IDataModel libModel = (IDataModel) warLibModels.get(k); - if (libModel.getProperty(IJ2EEComponentImportDataModelProperties.FILE) == nestedArchive) { - libModel.setProperty(IJ2EEComponentImportDataModelProperties.PROJECT_NAME, importModel.getProperty(IJ2EEComponentImportDataModelProperties.PROJECT_NAME)); - libModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, importModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)); - } - } - } - } - } - } - monitor.worked(WEB_LIB_WORK); - - List componentToAdd = new ArrayList(); - Map componentToURIMap = new HashMap(); - for (int i = 0; i < modelsToImport.size(); i++) { - importModel = (IDataModel) modelsToImport.get(i); - Archive nestedArchive = (Archive) importModel.getProperty(IEARComponentImportDataModelProperties.FILE); - importModel.setProperty(IJ2EEComponentImportDataModelProperties.CLOSE_ARCHIVE_ON_DISPOSE, Boolean.FALSE); - IDataModel compCreationModel = importModel.getNestedModel(IJ2EEComponentImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION); - if (compCreationModel.isProperty(IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI)){ - compCreationModel.setProperty(IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI, nestedArchive.getURI()); - } - compCreationModel.setBooleanProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false); - try { - importModel.getDefaultOperation().execute(new SubProgressMonitor(monitor, PROJECT_CREATION_WORK + nestedArchive.getFiles().size()), info); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - IVirtualComponent component = (IVirtualComponent) importModel.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT); - componentToAdd.add(component); - componentToURIMap.put(component, nestedArchive.getURI()); - } - if (componentToAdd.size() > 0) { - IDataModel addComponentsDM = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider()); - addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, virtualComponent); - addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, componentToAdd); - addComponentsDM.setProperty(IAddComponentToEnterpriseApplicationDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, componentToURIMap); - addComponentsDM.getDefaultOperation().execute(new SubProgressMonitor(monitor, LINK_COMPONENTS_WORK), info); - } - } finally { - if (null != artifactEdit) { - artifactEdit.dispose(); - artifactEdit = null; - } - resetDisposeImportModels(); - monitor.worked(DISPOSE_WORK); - } - } - - /** - * @param modelsToImport - */ - private void resetDisposeImportModels() { - resetDisposeImportModels((List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST)); - } - - private void resetDisposeImportModels(List models) { - IDataModel model; - for (int i = 0; i < models.size(); i++) { - model = (IDataModel) models.get(i); - model.setProperty(IJ2EEComponentImportDataModelProperties.CLOSE_ARCHIVE_ON_DISPOSE, Boolean.TRUE); - } - } - - protected SaveStrategy createSaveStrategy(IProject project) { // NOOP - return null; - } - - protected SaveStrategy createSaveStrategy(IVirtualComponent virtualComponent) { - return new EARComponentSaveStrategyImpl(virtualComponent); - } - - protected EARFile getEarFile() { - return (EARFile) model.getProperty(IEARComponentImportDataModelProperties.FILE); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentLoadStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentLoadStrategyImpl.java deleted file mode 100644 index 5391ab2a9..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentLoadStrategyImpl.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.applicationclient.componentcore.util.AppClientArtifactEdit; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonArchiveResourceHandler; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.ZipFileLoadStrategyImpl; -import org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.internal.util.ArtifactEditRegistryReader; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - -public class EARComponentLoadStrategyImpl extends ComponentLoadStrategyImpl { - - private List artifactEditsToDispose = new ArrayList(); - private Map binaryComponentURIsToDiskFileMap = new HashMap(); - - public EARComponentLoadStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - - public List getFiles() { - aggregateSourceFiles(); - addModulesAndUtilities(); - return filesHolder.getFiles(); - } - - public InputStream getInputStream(String uri) throws IOException, FileNotFoundException { - if (binaryComponentURIsToDiskFileMap.containsKey(uri)) { - java.io.File diskFile = (java.io.File) binaryComponentURIsToDiskFileMap.get(uri); - return new FileInputStream(diskFile); - } - return super.getInputStream(uri); - } - - public void addModulesAndUtilities() { - EARArtifactEdit earArtifactEdit = null; - try { - earArtifactEdit = EARArtifactEdit.getEARArtifactEditForRead(vComponent); - IVirtualReference[] components = earArtifactEdit.getComponentReferences(); - for (int i = 0; i < components.length; i++) { - IVirtualReference reference = components[i]; - IVirtualComponent referencedComponent = reference.getReferencedComponent(); - - java.io.File diskFile = null; - if (referencedComponent.isBinary()) { - diskFile = ((VirtualArchiveComponent) referencedComponent).getUnderlyingDiskFile(); - if (!diskFile.exists()) { - IFile wbFile = ((VirtualArchiveComponent) referencedComponent).getUnderlyingWorkbenchFile(); - if (wbFile != null && wbFile.exists()) { - diskFile = new File(wbFile.getLocation().toOSString()); - } - } - } - - boolean isModule = false; - ArtifactEdit componentArtifactEdit = null; - try { - if (J2EEProjectUtilities.isApplicationClientComponent(referencedComponent)) { - componentArtifactEdit = AppClientArtifactEdit.getAppClientArtifactEditForRead(referencedComponent); - } else if (J2EEProjectUtilities.isEJBComponent(referencedComponent)) { - componentArtifactEdit = ArtifactEditRegistryReader.instance().getArtifactEdit(J2EEProjectUtilities.EJB).createArtifactEditForRead(referencedComponent); - } else if (J2EEProjectUtilities.isDynamicWebComponent(referencedComponent)) { - componentArtifactEdit = ArtifactEditRegistryReader.instance().getArtifactEdit(J2EEProjectUtilities.DYNAMIC_WEB).createArtifactEditForRead(referencedComponent); - } else if (J2EEProjectUtilities.isJCAComponent(referencedComponent)) { - componentArtifactEdit = ArtifactEditRegistryReader.instance().getArtifactEdit(J2EEProjectUtilities.JCA).createArtifactEditForRead(referencedComponent); - } - if (null != componentArtifactEdit) { - Archive archive = ((EnterpriseArtifactEdit) componentArtifactEdit).asArchive(exportSource); - if (referencedComponent.isBinary()) { - artifactEditsToDispose.add(componentArtifactEdit); - archive.setLoadingContainer(getContainer()); - binaryComponentURIsToDiskFileMap.put(archive.getOriginalURI(), diskFile); - } - archive.setURI(earArtifactEdit.getModuleURI(referencedComponent)); - filesHolder.addFile(archive); - isModule = true; - } - } catch (OpenFailureException oe) { - Logger.getLogger().logError(oe); - } finally { - if (!referencedComponent.isBinary() && componentArtifactEdit != null) { - componentArtifactEdit.dispose(); - } - } - if (!isModule) { - if (referencedComponent.isBinary()) { - String uri = reference.getArchiveName(); - addExternalFile(uri, diskFile); - } else if (J2EEProjectUtilities.isUtilityProject(referencedComponent.getProject())) { - try { - if (!referencedComponent.isBinary()) { - String uri = earArtifactEdit.getModuleURI(referencedComponent); - Archive archive = J2EEProjectUtilities.asArchive(uri, referencedComponent.getProject(), exportSource); - archive.setURI(uri); - filesHolder.addFile(archive); - } else { - - - } - } catch (OpenFailureException e) { - Logger.getLogger().logError(e); - } - } - } - } - - } finally { - if (null != earArtifactEdit) { - earArtifactEdit.dispose(); - } - } - } - - public void close() { - super.close(); - Iterator it = artifactEditsToDispose.iterator(); - while (it.hasNext()) { - ArtifactEdit edit = (ArtifactEdit) it.next(); - edit.dispose(); - } - artifactEditsToDispose.clear(); - } - - public ZipFileLoadStrategyImpl createLoadStrategy(String uri) throws FileNotFoundException, IOException { - String filename = uri.replace('/', java.io.File.separatorChar); - java.io.File file = new java.io.File(filename); - if (!file.exists()) { - throw new FileNotFoundException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.file_not_found_EXC_, (new Object[]{uri, file.getAbsolutePath()}))); // = - } - if (file.isDirectory()) { - throw new FileNotFoundException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.file_not_found_EXC_, (new Object[]{uri, file.getAbsolutePath()}))); // = - } - return new org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.ZipFileLoadStrategyImpl(file); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentSaveStrategyImpl.java deleted file mode 100644 index ac44bd87c..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EARComponentSaveStrategyImpl.java +++ /dev/null @@ -1,274 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.WorkbenchByteArrayOutputStream; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.datamodel.properties.IEARComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; - -public class EARComponentSaveStrategyImpl extends ComponentSaveStrategyImpl { - - protected Map createdComponentsMap; - - public EARComponentSaveStrategyImpl(IVirtualComponent component) { - super(component); - } - - public void setDataModel(IDataModel dataModel) { - super.setDataModel(dataModel); - - setArchive((Archive) dataModel.getProperty(IEARComponentImportDataModelProperties.FILE)); - overwriteHandler = (IOverwriteHandler) dataModel.getProperty(IEARComponentImportDataModelProperties.OVERWRITE_HANDLER); - if (null != overwriteHandler) { - overwriteHandler.setEarSaveStrategy(this); - } - buildProjectsMap(); - } - - - - /** - * Creates a Map mapping archive uris to projects for all archives in the ear that imported as - * projects. - */ - private void buildProjectsMap() { - createdComponentsMap = new HashMap(); - List createdProjectsList = (List) dataModel.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST); - IDataModel importDM = null; - Archive anArchive = null; - for (int i = 0; i < createdProjectsList.size(); i++) { - importDM = (IDataModel) createdProjectsList.get(i); - anArchive = (Archive) importDM.getProperty(IJ2EEComponentImportDataModelProperties.FILE); - createdComponentsMap.put(anArchive.getURI(), importDM.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT)); - } - } - - protected void addFileToClasspath(IProject p, IFile file, List cp) { - if (!file.exists()) - return; - - // Assume the file also contains the source - IPath path = file.getFullPath(); - IClasspathEntry entry = JavaCore.newLibraryEntry(path, path, null, true); - if (!cp.contains(entry)) - cp.add(entry); - } - - protected void addProjectToClasspath(IProject dependent, IProject prereq, List cp) { - IClasspathEntry entry = JavaCore.newProjectEntry(prereq.getFullPath(), true); - if (!cp.contains(entry)) - cp.add(entry); - } - - protected EARFile getEARFile() { - return (EARFile) getArchive(); - } - - - protected java.io.OutputStream getOutputStreamForResource(org.eclipse.emf.ecore.resource.Resource aResource) throws java.io.IOException { - return null; - } - - public void save() throws SaveFailureException { - - saveFiles(); - saveManifest(); - saveMofResources(); - progressMonitor.subTask(EARArchiveOpsResourceHandler.Updating_project_classpath_UI_); - updateComponentClasspaths(); - - } - - public void save(Archive anArchive) throws SaveFailureException { - progressMonitor.subTask(anArchive.getURI()); - saveArchiveAsJARInEAR(anArchive); - } - - protected void saveArchiveAsJARInEAR(Archive anArchive) throws SaveFailureException { - try { - anArchive.save(createNestedSaveStrategy(anArchive)); - progressMonitor.worked(1); - } catch (IOException e) { - throw new SaveFailureException(anArchive.getURI(), e); - } - } - - protected SubProgressMonitor subMonitor() { - return new SubProgressMonitor(progressMonitor, 10); - } - - public void setMonitor(org.eclipse.core.runtime.IProgressMonitor newMonitor) { - progressMonitor = newMonitor; - } - - protected boolean shouldSave(File aFile) { - if (aFile.isArchive()) { - return getFilter().shouldSave(aFile.getURI(), getArchive()); - } - return super.shouldSave(aFile); - } - - /** - * {@link DoNotUseMeThisWillBeDeletedPost15} - * - * @deprecated - * @param archive - * @return - */ - protected boolean operationHandlesNested(Archive archive) { - return !shouldLinkAsComponentRef(archive); - } - - protected boolean shouldLinkAsComponentRef(Archive archive) { - if (null != dataModel) { - List list = (List) dataModel.getProperty(IEARComponentImportDataModelProperties.HANDLED_PROJECT_MODELS_LIST); - for (int i = 0; i < list.size(); i++) { - if (archive == ((IDataModel) list.get(i)).getProperty(IEARComponentImportDataModelProperties.FILE)) { - return false; - } - } - } - return true; - } - - protected boolean shouldSave(String uri) { - if (overwriteHandler != null) { - if (overwriteHandler.isOverwriteNone()) - return false; - return ((super.shouldSave(uri)) && (overwriteHandler.isOverwriteAll() || overwriteHandler.isOverwriteResources() || overwriteHandler.shouldOverwrite(uri))); - } - return true; - } - - - /* - * Parse the manifest of the module file; for each cp entry 1) cananonicalize to a uri that - * looks like the entry in the ear 2) If the ear contains a file with that uri (the entry is - * valid) a) If the file is another was blown out to a project, add a cp entry for a referenced - * project b) otherwise, add a cp entry that points to the file in the ear project, and cp - * entries for all prereqs - */ - protected void updateProjectClasspath(Archive anArchive, IVirtualComponent component) { - - String message = EARArchiveOpsResourceHandler.Updating_project_classpath_UI_ + component.getName(); - progressMonitor.subTask(message); - List projectCpEntries = new ArrayList(); - Set visited = new HashSet(); - traverseClasspaths(component.getProject(), anArchive, projectCpEntries, visited); - - try { - if (!projectCpEntries.isEmpty()) - JemProjectUtilities.appendJavaClassPath(component.getProject(), projectCpEntries); - JemProjectUtilities.forceClasspathReload(component.getProject()); - } catch (JavaModelException ex) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ex); - } - - } - - /* - * If you have a dependency to a JAR in the EAR project, and the JAR depends on another JAR in - * the EAR; you want to compile cleanly after import, so you need both those JARs on your build - * path - */ - protected void traverseClasspaths(IProject p, Archive anArchive, List projectCpEntries, Set visitedArchives) { - visitedArchives.add(anArchive); - String[] manifestCpEntries = anArchive.getManifest().getClassPathTokenized(); - EARFile earFile = (EARFile) dataModel.getProperty(IJ2EEComponentImportDataModelProperties.FILE); - for (int i = 0; i < manifestCpEntries.length; i++) { - String uri = ArchiveUtil.deriveEARRelativeURI(manifestCpEntries[i], anArchive); - // ensure the entry is valid or skip to the next - if (uri == null) - continue; - File aFile = null; - try { - aFile = earFile.getFile(uri); - } catch (FileNotFoundException notThere) { - } - if (aFile == null || !aFile.isArchive() || visitedArchives.contains(aFile)) - continue; - Archive depArchive = (Archive) aFile; - IProject prereq = null; - IVirtualComponent depComponent = (IVirtualComponent) createdComponentsMap.get(uri); - if (depComponent != null) - prereq = depComponent.getProject(); - - if (prereq != null) { - addProjectToClasspath(p, prereq, projectCpEntries); - } else { - addFileToClasspath(p, vComponent.getRootFolder().getFile(uri).getUnderlyingFile(), projectCpEntries); - traverseClasspaths(p, depArchive, projectCpEntries, visitedArchives); - } - } - } - - protected void updateComponentClasspaths() { - List jarFiles = getEARFile().getArchiveFiles(); - for (int i = 0; i < jarFiles.size(); i++) { - Archive anArchive = (Archive) jarFiles.get(i); - IVirtualComponent component = (IVirtualComponent) createdComponentsMap.get(anArchive.getURI()); - if (component != null) - updateProjectClasspath(anArchive, component); - } - } - - public void save(ArchiveManifest aManifest) throws SaveFailureException { - IVirtualFolder rootFolder = vComponent.getRootFolder(); - IVirtualFile vFile = rootFolder.getFile(new Path(J2EEConstants.MANIFEST_URI)); - IFile iFile = vFile.getUnderlyingFile(); - validateEdit(iFile); - OutputStream out = new WorkbenchByteArrayOutputStream(iFile); - try { - aManifest.write(out); - } catch (IOException e) { - Logger.getLogger().logError(e); - } finally { - try { - out.close(); - } catch (IOException e) { - Logger.getLogger().logError(e); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EJBArchiveOpsResourceHandler.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EJBArchiveOpsResourceHandler.java deleted file mode 100644 index 8f0f800a0..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EJBArchiveOpsResourceHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.osgi.util.NLS; - -public final class EJBArchiveOpsResourceHandler extends NLS { - - private static final String BUNDLE_NAME = "ejbarchiveops";//$NON-NLS-1$ - - private EJBArchiveOpsResourceHandler() { - // Do not instantiate - } - - public static String ARCHIVE_OPERATION_SaveMofResources; - public static String ARCHIVE_OPERATION_SaveFile; - public static String ARCHIVE_OPERATION_ProjectNature; - public static String ARCHIVE_OPERATION_SaveManifest; - public static String ARCHIVE_OPERATION_FileNotFound; - public static String ARCHIVE_OPERATION_FileContents; - public static String ARCHIVE_OPERATION_ErroOccured; - public static String ARCHIVE_OPERATION_FilesFromProject; - public static String ARCHIVE_OPERATION_OpeningArchive; - public static String ARCHIVE_OPERATION_InvalidEJBJar; - public static String ARCHIVE_OPERATION_InvalidImportEJBJar; - public static String ARCHIVE_OPERATION_ImportOperation; - public static String EJB_IMPORT_OPERATION_STRING; - public static String EJB_IMPORT_FILE_STRING; - public static String IMPORT_MOFRESOURCE_STRING; - public static String IMPORT_OPERATION_STRING; - public static String ERROR_COPYING_FILES_FROM_ORIGINAL_JAR; - public static String ERROR_IMPORTING_MODULE_FILE; - public static String Yes_UI; - public static String No_UI; - public static String Yes_To_All_UI; - public static String Cancel_UI_; - public static String Error_exporting__UI_; - public static String EJB_Jar_File_UI_; - public static String Copy_Dep_JARS_UI; - - static { - NLS.initializeMessages(BUNDLE_NAME, EJBArchiveOpsResourceHandler.class); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EJBComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EJBComponentSaveStrategyImpl.java deleted file mode 100644 index 0b1b3a1fa..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/EJBComponentSaveStrategyImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class EJBComponentSaveStrategyImpl extends J2EEComponentSaveStrategyImpl { - - public EJBComponentSaveStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/IOverwriteHandler.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/IOverwriteHandler.java deleted file mode 100644 index b47b26e16..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/IOverwriteHandler.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - - - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidator; - - -/** - * Insert the type's description here. Creation date: (4/16/2001 3:12:41 PM) - * - * @author: Administrator - */ -public interface IOverwriteHandler { - public static final String NO = EJBArchiveOpsResourceHandler.No_UI; - public static final String YES = EJBArchiveOpsResourceHandler.Yes_UI; - public static final String ALL = EJBArchiveOpsResourceHandler.Yes_To_All_UI; - public static final String NONE = EJBArchiveOpsResourceHandler.Cancel_UI_; - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - org.eclipse.core.resources.IProject getProject(); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - boolean isOverwriteAll(); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - boolean isOverwriteNone(); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - boolean isOverwriteResources(); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - String queryOverwrite(String resourcePath); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - void setEarSaveStrategy(EARComponentSaveStrategyImpl newEarSaveStrategy); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - void setEjbSaveStrategy(J2EEComponentSaveStrategyImpl newEjbSaveStrategy); - - /** - * Sets the RAR SaveStrategy. - * - * @param RARProjectSaveStrategyImpl - * rarSaveStrategy - The rar save strategy to set. - */ - void setRARSaveStrategy(J2EEComponentSaveStrategyImpl newRARSaveStrategy); - - void setOverwriteAll(boolean newAllTrue); - - void setOverwriteNone(boolean newNoneTrue); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - void setOverwriteResources(boolean newOverwriteResources); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - void setProject(org.eclipse.core.resources.IProject newProject); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - void setWarSaveStrategy(J2EEComponentSaveStrategyImpl newWarSaveStrategy); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - boolean shouldOverwrite(String uri); - - /** - * Check to see if the file can be checked out. - * - * @throws OverwriteHandlerException - * if the validate fails - */ - void validateEdit(IFile aFile) throws OverwriteHandlerException; - - /** - * Check to see if the files can be checked out. - * - * @throws OverwriteHandlerException - * if the validate fails - */ - void validateState(ResourceStateValidator resourceStateValidator); - - /** - * Insert the method's description here. Creation date: (4/16/2001 3:13:38 PM) - * - * @return boolean - */ - boolean shouldOverwriteWLProject(IProject fProject, java.lang.String uri); -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ImportOption.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ImportOption.java deleted file mode 100644 index dcc5728ba..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ImportOption.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - - -import org.eclipse.jst.j2ee.internal.project.IJ2EEProjectTypes; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - -/** - * This class defines the rules for importing an individual nested JAR in an EAR project - */ -public class ImportOption implements IJ2EEProjectTypes { - /** - * Project info for the individual module/JAR, or null if the file should be placed in the - * application - */ - protected IDataModel model; - - /** - * Valid only if the project info is not null - * - * @see IJ2EEProjectTypes - */ - protected int projectType = IJ2EEProjectTypes.DEFAULT; - - /** - * @see IJ2EEProjectTypes#MODULE - * @see IJ2EEProjectTypes#UTIL - */ - protected int archiveType = IJ2EEProjectTypes.MODULE; - - /** - * Constructor for ImportOption. - */ - public ImportOption(IDataModel model) { - super(); - this.model = model; - } - - public ImportOption(IDataModel model, int type) { - this(model); - projectType = type; - } - - public IDataModel getModel() { - return model; - } - - public int getProjectType() { - return projectType; - } - - public String getProjectName() { - return model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME); - } - - /** - * @return Returns the archiveType. - */ - public int getArchiveType() { - return archiveType; - } - - /** - * @param archiveType - * The archiveType to set. - */ - public void setArchiveType(int archiveType) { - this.archiveType = archiveType; - } - - /** - * @param projectType - * The projectType to set. - */ - public void setProjectType(int projectType) { - this.projectType = projectType; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEArtifactExportOperation.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEArtifactExportOperation.java deleted file mode 100644 index f85b8cd8c..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEArtifactExportOperation.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.ICommand; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceRuleFactory; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.MultiRule; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties; -import org.eclipse.jst.j2ee.internal.plugin.LibCopyBuilder; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public abstract class J2EEArtifactExportOperation extends AbstractDataModelOperation { - - protected IProgressMonitor progressMonitor; - private IVirtualComponent component; - private IPath destinationPath; - private ModuleFile moduleFile; - private boolean exportSource = false; - - public J2EEArtifactExportOperation() { - super(); - } - - public J2EEArtifactExportOperation(IDataModel model) { - super(model); - } - - protected final int REFRESH_WORK = 100; - protected final int JAVA_BUILDER_WORK = 100; - protected final int LIB_BUILDER_WORK = 100; - protected final int EXPORT_WORK = 1000; - protected final int CLOSE_WORK = 10; - - protected int computeTotalWork() { - int totalWork = REFRESH_WORK; - if (model.getBooleanProperty(IJ2EEComponentExportDataModelProperties.RUN_BUILD)) { - totalWork += JAVA_BUILDER_WORK + LIB_BUILDER_WORK; - } - totalWork += EXPORT_WORK + CLOSE_WORK; - return totalWork; - } - - 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 abstract void export() throws SaveFailureException, CoreException, InvocationTargetException, InterruptedException; - - protected abstract String archiveString(); - - protected void setProgressMonitor(IProgressMonitor newProgressMonitor) { - progressMonitor = newProgressMonitor; - } - - protected IProgressMonitor getProgressMonitor() { - return progressMonitor; - } - - private void setComponent(IVirtualComponent newComponent) { - component = newComponent; - } - - protected IVirtualComponent getComponent() { - if (component == null) - component = (IVirtualComponent) model.getProperty(IJ2EEComponentExportDataModelProperties.COMPONENT); - return component; - } - - protected IPath getDestinationPath() { - return destinationPath; - } - - protected void setDestinationPath(IPath newDestinationPath) { - destinationPath = newDestinationPath; - } - - protected boolean isExportSource() { - return exportSource; - } - - protected void setExportSource(boolean newExportSource) { - exportSource = newExportSource; - } - - protected ModuleFile getModuleFile() { - return moduleFile; - } - - protected void setModuleFile(ModuleFile newModuleFile) { - moduleFile = newModuleFile; - } - - protected void runNecessaryBuilders(IVirtualComponent component, IProgressMonitor monitor) throws CoreException { - try{ - monitor.beginTask(null, JAVA_BUILDER_WORK + LIB_BUILDER_WORK); - if(!component.isBinary()){ - IProject project = component.getProject(); - IProjectDescription description = project.getDescription(); - ICommand javaBuilder = getJavaCommand(description); - if (javaBuilder != null) { - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, javaBuilder.getArguments(), new SubProgressMonitor(monitor, JAVA_BUILDER_WORK)); - } - ICommand libCopyBuilder = getLibCopyBuilder(description); - if (null != libCopyBuilder) { - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, LibCopyBuilder.BUILDER_ID, libCopyBuilder.getArguments(), new SubProgressMonitor(monitor, LIB_BUILDER_WORK)); - } - } - } finally { - monitor.done(); - } - } - - /** - * Find the specific Java command amongst the build spec of a given description - */ - protected ICommand getJavaCommand(IProjectDescription description) throws CoreException { - if (description == null) { - return null; - } - - ICommand[] commands = description.getBuildSpec(); - for (int i = 0; i < commands.length; ++i) { - if (commands[i].getBuilderName().equals(JavaCore.BUILDER_ID)) { - return commands[i]; - } - } - return null; - } - - protected ICommand getLibCopyBuilder(IProjectDescription description) throws CoreException { - if (description == null) { - return null; - } - - ICommand[] commands = description.getBuildSpec(); - for (int i = 0; i < commands.length; ++i) { - if (commands[i].getBuilderName().equals(LibCopyBuilder.BUILDER_ID)) { - return commands[i]; - } - } - return null; - - } - - public ISchedulingRule getSchedulingRule() { - Set projs = gatherDependentProjects(getComponent(), new HashSet()); - ISchedulingRule combinedRule = null; - IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); - for (Iterator iter = projs.iterator(); iter.hasNext();) { - IProject proj = (IProject) iter.next(); - ISchedulingRule rule = ruleFactory.createRule(proj); - combinedRule = MultiRule.combine(rule, combinedRule); - } - combinedRule = MultiRule.combine(ruleFactory.buildRule(), combinedRule); - - return combinedRule; - } - - private Set gatherDependentProjects(IVirtualComponent comp, Set projs) { - if (!projs.contains(comp.getProject())) { - projs.add(comp.getProject()); - IVirtualReference[] refs = comp.getReferences(); - for (int i = 0; i < refs.length; i++) { - IVirtualReference refComp = refs[i]; - projs.addAll(gatherDependentProjects(refComp.getReferencedComponent(), projs)); - } - } - return projs; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEArtifactImportOperation.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEArtifactImportOperation.java deleted file mode 100644 index bb03d4517..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEArtifactImportOperation.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.SaveStrategy; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsOp; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException; - -public abstract class J2EEArtifactImportOperation extends AbstractDataModelOperation { - - protected Archive moduleFile; - protected IVirtualComponent virtualComponent; - protected IAdaptable info; - protected final int PROJECT_CREATION_WORK = 30; - - public J2EEArtifactImportOperation(IDataModel model) { - super(model); - } - - public IStatus execute(IProgressMonitor monitor, IAdaptable anInfo) throws ExecutionException { - try { - J2EEComponentClasspathUpdater.getInstance().pauseUpdates(); - this.info = anInfo; - moduleFile = (Archive) model.getProperty(IJ2EEComponentImportDataModelProperties.FILE); - monitor.beginTask(ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Importing_archive, new Object [] { moduleFile.getURI() }), computeTotalWork()); - doExecute(monitor); - return OK_STATUS; - } finally { - try { - if (virtualComponent != null) { - J2EEComponentClasspathUpdater.getInstance().queueUpdate(virtualComponent.getProject()); - } - } finally { - J2EEComponentClasspathUpdater.getInstance().resumeUpdates(); - model.dispose(); - monitor.done(); - } - } - } - - protected int computeTotalWork() { - return PROJECT_CREATION_WORK + moduleFile.getFiles().size(); - } - - /** - * Subclasses overriding this method should also override {@link #computeTotalWork()} - * @param monitor - * @throws ExecutionException - */ - protected void doExecute(IProgressMonitor monitor) throws ExecutionException { - virtualComponent = createVirtualComponent(model.getNestedModel(IJ2EEComponentImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION), new SubProgressMonitor(monitor, PROJECT_CREATION_WORK)); - - try { - importModuleFile(new SubProgressMonitor(monitor, moduleFile.getFiles().size())); - } catch (InvocationTargetException e) { - throw new ExecutionException(e.getMessage(), e); - } catch (InterruptedException e) { - throw new ExecutionException(e.getMessage(), e); - } - } - - /** - * {@link DoNotUseMeThisWillBeDeletedPost15} - * - */ - protected void fixupManifestRefs() { - } - - protected IVirtualComponent createVirtualComponent(IDataModel aModel, IProgressMonitor monitor) throws ExecutionException { - try { - aModel.getDefaultOperation().execute(monitor, info); - String projectName = aModel.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - IProject project = ProjectUtilities.getProject(projectName); - return ComponentCore.createComponent(project); - } finally { - monitor.done(); - } - } - - /** - * Creates the appropriate save strategy. Subclases should overwrite this method to create the - * appropriate save startegy for the kind of J2EE module project to import the archive - */ - protected abstract SaveStrategy createSaveStrategy(IVirtualComponent vc); - - protected void modifyStrategy(SaveStrategy saveStrat) { - } - - /** - * perform the archive import operation - * - * @throws java.lang.reflect.InvocationTargetException - * @throws java.lang.InterruptedException - */ - protected void importModuleFile(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask(null, moduleFile.getFiles().size()); - ComponentSaveStrategyImpl aStrategy = (ComponentSaveStrategyImpl) createSaveStrategy(virtualComponent); - aStrategy.setProgressMonitor(monitor); - aStrategy.setOverwriteHandler((IOverwriteHandler) model.getProperty(IJ2EEComponentImportDataModelProperties.OVERWRITE_HANDLER)); - aStrategy.setDataModel(model); - modifyStrategy(aStrategy); - moduleFile.save(aStrategy); - } catch (OverwriteHandlerException oe) { - throw new InterruptedException(); - } catch (Exception ex) { - throw new WFTWrappedException(ex, EJBArchiveOpsResourceHandler.ERROR_IMPORTING_MODULE_FILE); - } finally { - monitor.done(); - } - } - - /** - * {@link DoNotUseMeThisWillBeDeletedPost15} - * - * @deprecated this will be deleted do not use this method - */ - protected static void addToClasspath(IDataModel importModel, List extraEntries) throws JavaModelException { - if (extraEntries.size() > 0) { - IJavaProject javaProject = JavaCore.create(((IVirtualComponent) importModel.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT)).getProject()); - IClasspathEntry[] javaClasspath = javaProject.getRawClasspath(); - List nonDuplicateList = new ArrayList(); - for (int i = 0; i < extraEntries.size(); i++) { - IClasspathEntry extraEntry = (IClasspathEntry) extraEntries.get(i); - boolean include = true; - for (int j = 0; include && j < javaClasspath.length; j++) { - if (extraEntry.equals(javaClasspath[j])) { - include = false; - } - } - if (include) { - nonDuplicateList.add(extraEntry); - } - } - if (nonDuplicateList.size() > 0) { - IClasspathEntry[] newJavaClasspath = new IClasspathEntry[javaClasspath.length + nonDuplicateList.size()]; - System.arraycopy(javaClasspath, 0, newJavaClasspath, 0, javaClasspath.length); - for (int j = 0; j < nonDuplicateList.size(); j++) { - newJavaClasspath[javaClasspath.length + j] = (IClasspathEntry) nonDuplicateList.get(j); - } - javaProject.setRawClasspath(newJavaClasspath, new NullProgressMonitor()); - } - } - } - - // Assumes that the project exists with the same name as the - // entry in the manifest. - - /** - * {@link DoNotUseMeThisWillBeDeletedPost15} - * - * @deprecated this will be deleted do not use this method - */ - protected void fixModuleReference(IDataModel importModel, String[] manifestEntries) { - IVirtualComponent comp = (IVirtualComponent) importModel.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT); - - if (J2EEProjectUtilities.isEJBProject(comp.getProject()) && manifestEntries.length > 0) { - for (int j = 0; j < manifestEntries.length; j++) { - String name = manifestEntries[j]; - int endIndex = name.length() - 4; // lop off .jar - if (endIndex < 1) { - continue; - } - name = name.substring(0, endIndex); - IProject project = null; - try { - project = ProjectUtilities.getProject(name); - } catch (IllegalArgumentException e) { - continue; - } - if (project != null && project.isAccessible() && project.exists()) { - IVirtualComponent refcomp = ComponentCore.createComponent(project); - if (refcomp.exists()) { - ArrayList list = new ArrayList(); - list.add(refcomp); - CreateReferenceComponentsOp op = ComponentUtilities.createReferenceComponentOperation(comp, list); - try { - op.execute(null, null); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - } - } - } - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEComponentLoadStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEComponentLoadStrategyImpl.java deleted file mode 100644 index 085563c49..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEComponentLoadStrategyImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class J2EEComponentLoadStrategyImpl extends ComponentLoadStrategyImpl{ - - public J2EEComponentLoadStrategyImpl(IVirtualComponent component) { - super(component); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEComponentSaveStrategyImpl.java deleted file mode 100644 index 02a31596d..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEComponentSaveStrategyImpl.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.io.IOException; -import java.io.OutputStream; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.emf.workbench.WorkbenchByteArrayOutputStream; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; - -public abstract class J2EEComponentSaveStrategyImpl extends ComponentSaveStrategyImpl { - - protected final String DOT_CLASS = ".class"; //$NON-NLS-1$ - protected final String IMPORTED_CLASSES = "ImportedClasses"; //$NON-NLS-1$ - - public J2EEComponentSaveStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - - protected void saveFiles() throws SaveFailureException { - super.saveFiles(); - linkImportedClassesFolderIfNecessary(); - try { - vComponent.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (CoreException ex) { - Logger.getLogger().logError(ex); - } - } - - public boolean endsWithClassType(String aFileName) { - if (aFileName.endsWith(DOT_CLASS)) - return true; - return false; - } - - protected boolean shouldSave(File aFile) { - if (endsWithClassType(aFile.getURI())){ - boolean shouldSave = isClassWithoutSource(aFile); - if(shouldSave && !importedClassesFolderCreated){ - createImportedClassesFolder(); - } - return shouldSave; - } - return super.shouldSave(aFile); - } - - public void save(ArchiveManifest aManifest) throws SaveFailureException { - IVirtualFolder rootFolder = vComponent.getRootFolder(); - IVirtualFile vFile = rootFolder.getFile(new Path(J2EEConstants.MANIFEST_URI)); - IFile iFile = vFile.getUnderlyingFile(); - validateEdit(iFile); - OutputStream out = new WorkbenchByteArrayOutputStream(iFile); - try { - aManifest.write(out); - } catch (IOException e) { - Logger.getLogger().logError(e); - } finally { - try { - out.close(); - } catch (IOException e) { - Logger.getLogger().logError(e); - } - } - } - - protected boolean importedClassesFolderCreated = false; - protected IFolder importedClassesFolder; - - protected void createImportedClassesFolder() { - importedClassesFolderCreated = true; - IContainer jarParent = vComponent.getRootFolder().getUnderlyingFolder().getParent(); - importedClassesFolder = jarParent.getFolder(new Path(IMPORTED_CLASSES)); - try { - importedClassesFolder.create(true, true, null); - } catch (CoreException e1) { - Logger.getLogger().logError(e1); - } - } - - protected void linkImportedClassesFolderIfNecessary() { - if (importedClassesFolder != null) { - try { - vComponent.getRootFolder().getFolder(getImportedClassesRuntimePath()).createLink(importedClassesFolder.getProjectRelativePath(), 0, null); - if (shouldAddImportedClassesToClasspath()) { - if (JemProjectUtilities.getJavaProject(vComponent.getProject()) != null) { - IJavaProject javaProject = JavaCore.create(vComponent.getProject()); - IClasspathEntry[] javaClasspath = javaProject.getRawClasspath(); - IClasspathEntry[] newJavaClasspath = new IClasspathEntry[javaClasspath.length + 1]; - System.arraycopy(javaClasspath, 0, newJavaClasspath, 0, javaClasspath.length); - newJavaClasspath[newJavaClasspath.length - 1] = JavaCore.newLibraryEntry(importedClassesFolder.getFullPath(), null, null, true); - javaProject.setRawClasspath(newJavaClasspath, new NullProgressMonitor()); - } - } - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - } - - protected boolean shouldAddImportedClassesToClasspath() { - return true; - } - - protected IPath getImportedClassesRuntimePath() { - return new Path("/"); - } - - protected IPath getOutputPathForFile(File aFile) { - if(endsWithClassType(aFile.getURI())){ - return importedClassesFolder.getFile(getImportedClassesURI(aFile)).getProjectRelativePath(); - } - return super.getOutputPathForFile(aFile); - } - - protected String getImportedClassesURI(File aFile) { - return aFile.getURI(); - } - - protected boolean isClassWithoutSource(File aFile) { - String javaUri = ArchiveUtil.classUriToJavaUri(aFile.getURI()); - if (javaUri == null) - return false; - return !archive.containsFile(javaUri); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEImportConstants.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEImportConstants.java deleted file mode 100644 index 9bf8af510..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEImportConstants.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 18, 2003 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.archive.operations; - -/** - * @author jsholl - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class J2EEImportConstants { - public static final String IMPORTED_JAR_SUFFIX = ".imported_classes.jar"; //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEJavaComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEJavaComponentSaveStrategyImpl.java deleted file mode 100644 index 0e2b74b52..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/J2EEJavaComponentSaveStrategyImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class J2EEJavaComponentSaveStrategyImpl extends J2EEComponentSaveStrategyImpl { - - public J2EEJavaComponentSaveStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentCreationDataModelProvider.java deleted file mode 100644 index 4fbe599c5..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentCreationDataModelProvider.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.jst.common.project.facet.JavaProjectFacetCreationDataModelProvider; -import org.eclipse.jst.j2ee.application.internal.operations.FlexibleJavaProjectCreationDataModelProvider; -import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage; -import org.eclipse.jst.j2ee.datamodel.properties.IJavaComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.project.datamodel.properties.IFlexibleJavaProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFlexibleProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.ComponentCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonMessages; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * This has been slated for removal post WTP 1.5. Do not use this class/interface - * - * @deprecated - * - * @see JavaProjectFacetCreationDataModelProvider - */ -public class JavaComponentCreationDataModelProvider extends ComponentCreationDataModelProvider implements IJavaComponentCreationDataModelProperties, DoNotUseMeThisWillBeDeletedPost15 { - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(JAVASOURCE_FOLDER); - propertyNames.add(MANIFEST_FOLDER); - propertyNames.add(RUNTIME_TARGET_ID); - return propertyNames; - } - - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(JAVASOURCE_FOLDER)) { - return getComponentName(); - } else if (propertyName.equals(MANIFEST_FOLDER)) { - return "/" + J2EEConstants.META_INF; //$NON-NLS-1$ - } - return super.getDefaultProperty(propertyName); - } - - public void init() { - super.init(); - } - - public boolean propertySet(String propertyName, Object propertyValue) { - boolean status = super.propertySet(propertyName, propertyValue); - if (PROJECT_NAME.equals(propertyName)) { - // model.notifyPropertyChange(PROJECT_NAME, IDataModel.VALUE_CHG); - // IDataModel dm = (IDataModel)model.getNestedModel(NESTED_PROJECT_CREATION_DM); - // dm.setProperty(IFlexibleProjectCreationDataModelProperties.PROJECT_NAME, - // propertyValue); - } else if (LOCATION.equals(propertyName)) { - IDataModel dm = model.getNestedModel(NESTED_PROJECT_CREATION_DM); - dm.setProperty(IFlexibleProjectCreationDataModelProperties.PROJECT_LOCATION, propertyValue); - } else if (RUNTIME_TARGET_ID.equals(propertyName)) { - IDataModel dm = model.getNestedModel(NESTED_PROJECT_CREATION_DM); - dm.setProperty(IFlexibleJavaProjectCreationDataModelProperties.RUNTIME_TARGET_ID, propertyValue); - } -// else if (propertyName.equals(JAVASOURCE_FOLDER)){ -// //unless MANIFEST folder is opened up, it is set as same as Java source folder -// setProperty(MANIFEST_FOLDER, getProperty(JAVASOURCE_FOLDER)+ "/" + J2EEConstants.META_INF); -// } - return status; - } - - public IStatus validate(String propertyName) { - if (propertyName.equals(JAVASOURCE_FOLDER)) { - IStatus status = OK_STATUS; - String srcFolderName = model.getStringProperty(JAVASOURCE_FOLDER); - if (srcFolderName == null || srcFolderName.length() == 0) { - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.SOURCEFOLDER_EMPTY); - status = WTPCommonPlugin.createErrorStatus(errorMessage); - } - return status; - - } else if (propertyName.equals(MANIFEST_FOLDER)) { - IStatus status = OK_STATUS; - String srcFolderName = model.getStringProperty(MANIFEST_FOLDER); - if (srcFolderName == null || srcFolderName.length() == 0) { - String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.PROJECT_NAME_EMPTY); - status = WTPCommonPlugin.createErrorStatus(errorMessage); - } - return status; - } else if (propertyName.equals(RUNTIME_TARGET_ID)) { - - IDataModel dm = model.getNestedModel(NESTED_PROJECT_CREATION_DM); - IStatus nestedValiation = dm.validate(); - if (!nestedValiation.isOK()) - return nestedValiation; - } - // else if(propertyName.equals(PROJECT_NAME)){ - // IDataModel projectdm = (IDataModel)model.getNestedModel(NESTED_PROJECT_CREATION_DM); - // return - // projectdm.validateProperty(IFlexibleProjectCreationDataModelProperties.PROJECT_NAME); - // } - - return super.validate(propertyName); - } - - public JavaComponentCreationDataModelProvider() { - super(); - } - - protected EClass getComponentType() { - return CommonarchivePackage.eINSTANCE.getModuleFile(); - } - - protected Integer getDefaultComponentVersion() { - Integer version = new Integer("10"); - return version; - } - - protected String getComponentExtension() { - return ".jar"; //$NON-NLS-1$ - } - - protected List getProperties() { - return null; - } - - protected void initProjectCreationModel() { - IDataModel dm = DataModelFactory.createDataModel(new FlexibleJavaProjectCreationDataModelProvider()); - model.addNestedModel(NESTED_PROJECT_CREATION_DM, dm); - model.setProperty(LOCATION, dm.getProperty(IFlexibleProjectCreationDataModelProperties.PROJECT_LOCATION)); - - } - - public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { - if (propertyName.equals(RUNTIME_TARGET_ID)) { - // IDataModel projectdm = (IDataModel)model.getNestedModel(NESTED_PROJECT_CREATION_DM); - // return - // projectdm.getValidPropertyDescriptors(IFlexibleJavaProjectCreationDataModelProperties.SERVER_TARGET_ID); - } - return null; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentLoadStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentLoadStrategyImpl.java deleted file mode 100644 index 3ffab1e65..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentLoadStrategyImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class JavaComponentLoadStrategyImpl extends ComponentLoadStrategyImpl { - - public JavaComponentLoadStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentSaveStrategyImpl.java deleted file mode 100644 index 2269718c4..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaComponentSaveStrategyImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class JavaComponentSaveStrategyImpl extends ComponentSaveStrategyImpl { - - public JavaComponentSaveStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/OverwriteHandlerException.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/OverwriteHandlerException.java deleted file mode 100644 index 9ab5d9210..000000000 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/OverwriteHandlerException.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.archive.operations; - - - -/** - * Insert the type's description here. Creation date: (8/16/2001 6:07:35 PM) - * - * @author: Administrator - */ -public class OverwriteHandlerException extends RuntimeException { - /** - * Warning clean-up 12/05/2005 - */ - private static final long serialVersionUID = 1651836694391641930L; - - /** - * OverwriteHandlerException constructor comment. - */ - public OverwriteHandlerException() { - super(); - } - - /** - * OverwriteHandlerException constructor comment. - * - * @param s - * java.lang.String - */ - public OverwriteHandlerException(String s) { - super(s); - } -}
\ No newline at end of file |