diff options
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee.web/webproject')
39 files changed, 0 insertions, 5148 deletions
diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WTProjectStrategyUtils.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WTProjectStrategyUtils.java deleted file mode 100644 index 34c047791..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WTProjectStrategyUtils.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.web.archive.operations; - - - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.internal.J2EEConstants; - - -public class WTProjectStrategyUtils { - public static File findSourceFile(Archive archive, String file) { - if (isClassFile(file)) - return findSourceFileForClass(archive, file); - - // Look in the CLASSES directory - try { - if (!isOutputFile(file)) - return archive.getFile(file); - } catch (java.io.FileNotFoundException ex) { - //Do nothing - } - return null; - } - - public static File findSourceFileForClass(Archive archive, String classFile) { - // Look in the CLASSES directory - IPath classFilePath = new Path(classFile); - IPath sourceFilePath = classFilePath.removeFileExtension().addFileExtension("java");//$NON-NLS-1$ - try { - File file = archive.getFile(sourceFilePath.toString()); - if (file != null) - return file; - } catch (java.io.FileNotFoundException ex) { - //Do nothing - } - - // Look in the LIB directory - sourceFilePath = new Path(ArchiveConstants.WEBAPP_LIB_URI).append(sourceFilePath); - try { - File file = archive.getFile(sourceFilePath.toString()); - if (file != null) - return file; - } catch (java.io.FileNotFoundException ex) { - //Do nothing - } - return null; - - } - - public static boolean isClassFile(String uri) { - return uri.startsWith(ArchiveConstants.WEBAPP_CLASSES_URI) && uri.endsWith(".class");//$NON-NLS-1$ - } - - public static boolean isOutputFile(String uri) { - return uri.startsWith(ArchiveConstants.WEBAPP_CLASSES_URI); - } - - public static boolean isSourceFile(String uri) { - // A file is considered a java source file if it is in the - // WEB_INF directory and it does not end with .class. - if (uri.startsWith(J2EEConstants.WEB_INF + "/") && //$NON-NLS-1$ - uri.endsWith(".java"))//$NON-NLS-1$ - return true; - return false; - - } - - public static String makeRelative(String pathString, String relToPathString) { - IPath relToPath = new Path(relToPathString); - IPath path = new Path(pathString); - - if (path.matchingFirstSegments(relToPath) == relToPath.segmentCount()) - path = path.removeFirstSegments(relToPath.segmentCount()); - - return path.toString(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentExportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentExportDataModelProvider.java deleted file mode 100644 index c3d064819..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentExportDataModelProvider.java +++ /dev/null @@ -1,93 +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.web.archive.operations; - -import java.util.Set; - -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentExportDataModelProvider; -import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; -import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.web.datamodel.properties.IWebComponentExportDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class WebComponentExportDataModelProvider extends J2EEComponentExportDataModelProvider implements IWebComponentExportDataModelProperties { - - public WebComponentExportDataModelProvider() { - super(); - } - - @Override - public IDataModelOperation getDefaultOperation() { - return new WebComponentExportOperation(model); - } - - @Override - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(EXCLUDE_COMPILE_JSP); - return propertyNames; - } - - @Override - public Object getDefaultProperty(String propertyName) { - if (EXCLUDE_COMPILE_JSP.equals(propertyName)) { - return Boolean.FALSE; - } - return super.getDefaultProperty(propertyName); - } - - @Override - protected String getProjectType() { - return J2EEProjectUtilities.DYNAMIC_WEB; - } - - @Override - protected String getWrongComponentTypeString(String projectName) { - return EARCreationResourceHandler.getString(EARCreationResourceHandler.NOT_A_WAR, new Object[]{projectName}); - } - - @Override - protected String getModuleExtension() { - return IJ2EEModuleConstants.WAR_EXT; - } - /** - * Exports the specified Web Module project to the specified WAR file. - * - * @param webProjectName - * The name of the Web Module project to export. - * @param warFileName - * The fully qualified WAR file location to export the specified Web Module project. - * @param overwriteExisting - * If this is <code>true</code> then an existing file at the location specified by - * <code>earFileName</code> will be overwritten. - * @param exportSource - * If this is <code>true</code> then all source files in the specified Web Module - * will be included in the resulting WAR file. - * @plannedfor WTP 1.0 - */ - // TODO: determine plan for new DM Provider - // public static void exportProject(String webProjectName, String warFileName, boolean - // overwriteExisting, boolean exportSource) { - // WebModuleExportDataModel dataModel = new WebModuleExportDataModel(); - // dataModel.setProperty(PROJECT_NAME, webProjectName); - // dataModel.setBooleanProperty(OVERWRITE_EXISTING, overwriteExisting); - // dataModel.setProperty(ARCHIVE_DESTINATION, warFileName); - // dataModel.setBooleanProperty(EXPORT_SOURCE_FILES, exportSource); - // try { - // dataModel.getDefaultOperation().run(null); - // } catch (InvocationTargetException e) { - // Logger.getLogger().logError(e); - // } catch (InterruptedException e) { - // Logger.getLogger().logError(e); - // } - // } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentExportOperation.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentExportOperation.java deleted file mode 100644 index 66b0bc85b..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentExportOperation.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.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.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities; -import org.eclipse.jst.j2ee.internal.archive.operations.AppClientArchiveOpsResourceHandler; -import org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactExportOperation; -import org.eclipse.jst.jee.archive.IArchive; -import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class WebComponentExportOperation extends J2EEArtifactExportOperation { - - public WebComponentExportOperation() { - super(); - } - - public WebComponentExportOperation(IDataModel model) { - super(model); - } - - /** - * @deprecated this will be removed post 3.1 with bug 268201 - */ - @Override - protected void export() throws SaveFailureException, CoreException, InvocationTargetException, InterruptedException { - IProgressMonitor subMonitor = new SubProgressMonitor(progressMonitor, EXPORT_WORK); - IArchive archiveFromComponent = null; - try { - archiveFromComponent = JavaEEArchiveUtilities.INSTANCE.openArchive(getComponent()); - JavaEEQuickPeek quickPeek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(archiveFromComponent); - if (quickPeek.getJavaEEVersion() == J2EEConstants.JEE_5_0_ID) { - saveArchive(archiveFromComponent, getDestinationPath().toOSString(), subMonitor); - } else { - CommonarchiveFactory caf = ((CommonarchivePackage) EPackage.Registry.INSTANCE.getEPackage(CommonarchivePackage.eNS_URI)).getCommonarchiveFactory(); - WebComponentLoadStrategyImpl ls = new WebComponentLoadStrategyImpl(getComponent()); - ls.setExportSource(isExportSource()); - ls.setReadOnly(true); - setModuleFile(caf.openWARFile(ls, getDestinationPath().toOSString())); - getModuleFile().getOptions().setIsReadOnly(true); - ls.setProgressMonitor(subMonitor); - getModuleFile().saveAsNoReopen(getDestinationPath().toOSString()); - } - } catch (SaveFailureException ex) { - throw ex; - } catch (Exception e) { - throw new SaveFailureException(AppClientArchiveOpsResourceHandler.ARCHIVE_OPERATION_OpeningArchive, e); - } finally { - if (archiveFromComponent != null) - JavaEEArchiveUtilities.INSTANCE.closeArchive(archiveFromComponent); - - subMonitor.done(); - } - } - - /** - * @deprecated this will be removed post 3.1 with bug 268201 - */ - @Override - protected String archiveString() { - //TODO delete this method - return "War File"; //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentImportDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentImportDataModelProvider.java deleted file mode 100644 index a2bf33564..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentImportDataModelProvider.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.archive.operations; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentImportDataModelProvider; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEUtilityJarImportDataModelProvider; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties; -import org.eclipse.jst.j2ee.web.datamodel.properties.IWebComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties; -import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * This dataModel is used for to import Web Modules (from WAR files) into the workspace. - * - * This class (and all its fields and methods) is likely to change during the WTP 1.0 milestones as - * the new project structures are adopted. Use at your own risk. - * - * @plannedfor WTP 1.0 - */ -public final class WebComponentImportDataModelProvider extends J2EEComponentImportDataModelProvider implements IWebComponentImportDataModelProperties { - - @Override - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(WEB_LIB_MODELS); - propertyNames.add(WEB_LIB_ARCHIVES_SELECTED); - propertyNames.add(CONTEXT_ROOT); - return propertyNames; - } - - @Override - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(WEB_LIB_MODELS) || propertyName.equals(WEB_LIB_ARCHIVES_SELECTED)) { - return Collections.EMPTY_LIST; - } - return super.getDefaultProperty(propertyName); - } - - @Override - protected int getType() { - return XMLResource.WEB_APP_TYPE; - } - - @Override - protected void handleUnknownType(JavaEEQuickPeek jqp) { - jqp.setType(J2EEVersionConstants.WEB_TYPE); - jqp.setVersion(J2EEVersionConstants.WEB_2_5_ID); - jqp.setJavaEEVersion(J2EEVersionConstants.JEE_5_0_ID); - } - - - protected IStatus validateModuleType() { - if (getArchiveWrapper().getJavaEEQuickPeek().getType() == J2EEConstants.WEB_TYPE) - return OK_STATUS; - - // TODO: STRING MOVE - return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString("Temp String for none WARFile")); //$NON-NLS-1$); - } - - @Override - public boolean propertySet(String propertyName, Object propertyValue) { - super.propertySet(propertyName, propertyValue); - if (propertyName.equals(ARCHIVE_WRAPPER)) { - - IDataModel moduleDM = model.getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION); - if (getArchiveWrapper() != null) { - - FacetDataModelMap map = (FacetDataModelMap) moduleDM.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - IDataModel webFacetDataModel = map.getFacetDataModel( J2EEProjectUtilities.DYNAMIC_WEB ); - - int version = getModuleSpecVersion(); - String versionText = J2EEVersionUtil.getServletTextVersion( version ); - webFacetDataModel.setStringProperty(IFacetDataModelProperties.FACET_VERSION_STR, versionText); - updateJavaFacetVersion(); - model.notifyPropertyChange(PROJECT_NAME, IDataModel.VALID_VALUES_CHG); - } - - ArchiveWrapper archiveWrapper = (ArchiveWrapper) propertyValue; - if (null != archiveWrapper) { - List <ArchiveWrapper> libs = archiveWrapper.getWebLibs(); - List nestedModels = new ArrayList(); - for (int i = 0; i < libs.size(); i++) { - IDataModel localModel = DataModelFactory.createDataModel(new J2EEUtilityJarImportDataModelProvider()); - localModel.setProperty(ARCHIVE_WRAPPER, libs.get(i)); - localModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)); - IDataModel facetDataModel = localModel.getNestedModel(IJ2EEComponentImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION); - facetDataModel.setBooleanProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false); - nestedModels.add(localModel); - } - setProperty(WEB_LIB_MODELS, nestedModels); - } - }else if(propertyName.equals(CONTEXT_ROOT)){ - IDataModel creationModel = model.getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION); - FacetDataModelMap map = (FacetDataModelMap) creationModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - IDataModel webFacetDataModel = map.getFacetDataModel( J2EEProjectUtilities.DYNAMIC_WEB ); - webFacetDataModel.setStringProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT, (String)propertyValue); - }else if(propertyName.equals(WEB_LIB_ARCHIVES_SELECTED)) { - validateLibModelRuntimes(); - } - return true; - } - - @Override - public IStatus validate(String propertyName) { - if(FACET_RUNTIME.equals(propertyName)){ - super.validate(propertyName); - return validateLibModelRuntimes(); - } - return super.validate(propertyName); - } - - private IStatus validateLibModelRuntimes() { - List libArchives = (List)getProperty(WEB_LIB_ARCHIVES_SELECTED); - List libModels = (List)getProperty(WEB_LIB_MODELS); - IStatus status = OK_STATUS; - for (int i=0; i < libModels.size(); i++) { - IDataModel libModel = (IDataModel)libModels.get(i); - if (libArchives.contains(libModel.getProperty(ARCHIVE_WRAPPER))){ - status = libModel.validateProperty(FACET_RUNTIME); - } - if(!status.isOK()){ - return status; - } - } - return status; - } - - @Override - protected Archive openArchive(String uri) throws OpenFailureException { - Archive archive = CommonarchiveFactory.eINSTANCE.openWARFile(getArchiveOptions(), uri); - return archive; - } - - @Override - protected IDataModel createJ2EEComponentCreationDataModel() { - return DataModelFactory.createDataModel(new WebFacetProjectCreationDataModelProvider()); - } - - @Override - public IDataModelOperation getDefaultOperation() { - return new WebComponentImportOperation(model); - } - - @Override - public void init() { - super.init(); - IDataModel componentCreationDM = model.getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION); - FacetDataModelMap map = (FacetDataModelMap) componentCreationDM.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - IDataModel webFacet = map.getFacetDataModel( IJ2EEFacetConstants.DYNAMIC_WEB ); - webFacet.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD, false); - } - - @Override - public void propertyChanged(DataModelEvent event) { - super.propertyChanged(event); - if (event.getPropertyName().equals(IFacetProjectCreationDataModelProperties.FACET_RUNTIME) && event.getDataModel() == model.getNestedModel(NESTED_MODEL_J2EE_COMPONENT_CREATION)) { - Object propertyValue = event.getProperty(); - IDataModel nestedModel = null; - List projectModels = (List) getProperty(WEB_LIB_MODELS); - for (int i = 0; i < projectModels.size(); i++) { - nestedModel = (IDataModel) projectModels.get(i); - nestedModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, propertyValue); - } - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentImportOperation.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentImportOperation.java deleted file mode 100644 index 4553d4b37..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentImportOperation.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.archive.operations; - -import java.lang.reflect.InvocationTargetException; -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.IResource; -import org.eclipse.core.runtime.CoreException; -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.commonarchivecore.internal.strategy.SaveStrategy; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper; -import org.eclipse.jst.j2ee.internal.archive.ComponentArchiveSaveAdapter; -import org.eclipse.jst.j2ee.internal.archive.WebComponentArchiveSaveAdapter; -import org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactImportOperation; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.j2ee.web.datamodel.properties.IWebComponentImportDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class WebComponentImportOperation extends J2EEArtifactImportOperation { - /** - * @param model - */ - public WebComponentImportOperation(IDataModel model) { - super(model); - } - - protected final int LINK_COMPONENTS_WORK = 10; - protected final int LIB_FOLDER_WORK = 2; - - @Override - protected int computeTotalWork() { - int baseWork = super.computeTotalWork() + LIB_FOLDER_WORK; - List selectedLibs = (List) model.getProperty(IWebComponentImportDataModelProperties.WEB_LIB_ARCHIVES_SELECTED); - List libProjects = (List) model.getProperty(IWebComponentImportDataModelProperties.WEB_LIB_MODELS); - IDataModel importModel = null; - ArchiveWrapper libArchive = null; - for (int i = 0; null != libProjects && i < libProjects.size(); i++) { - importModel = (IDataModel) libProjects.get(i); - libArchive = (ArchiveWrapper) importModel.getProperty(IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER); - if (selectedLibs.contains(libArchive)) { - baseWork += LINK_COMPONENTS_WORK + PROJECT_CREATION_WORK + libArchive.getSize(); - } - } - - return baseWork; - } - - @Override - protected void doExecute(IProgressMonitor monitor) throws ExecutionException { - super.doExecute(monitor); - IVirtualFolder libFolder = virtualComponent.getRootFolder().getFolder(WebArtifactEdit.WEBLIB); - if (!libFolder.exists()) { - try { - libFolder.create(IResource.FORCE, new SubProgressMonitor(monitor, LIB_FOLDER_WORK)); - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } else { - monitor.worked(LIB_FOLDER_WORK); - } - try { - importWebLibraryProjects(monitor); - } catch (InvocationTargetException e) { - Logger.getLogger().logError(e); - } catch (InterruptedException e) { - Logger.getLogger().logError(e); - } - } - - private void importWebLibraryProjects(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, ExecutionException { - List <ArchiveWrapper> selectedLibs = (List<ArchiveWrapper>) model.getProperty(IWebComponentImportDataModelProperties.WEB_LIB_ARCHIVES_SELECTED); - List <Object> selectedLibsUnderlyingArchives = new ArrayList(); - for(ArchiveWrapper lib: selectedLibs){ - selectedLibsUnderlyingArchives.add(lib.getUnderLyingArchive()); - } - List <IDataModel> libProjects = (List <IDataModel>) model.getProperty(IWebComponentImportDataModelProperties.WEB_LIB_MODELS); - IDataModel importModel = null; - IVirtualComponent nestedComponent = null; - ArchiveWrapper libArchive = null; - List targetComponents = new ArrayList(); - Map compToURIMap = new HashMap(); - for (int i = 0; null != libProjects && i < libProjects.size(); i++) { - importModel = libProjects.get(i); - libArchive = (ArchiveWrapper) importModel.getProperty(IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER); - if (selectedLibsUnderlyingArchives.contains(libArchive.getUnderLyingArchive())) { - importModel.getDefaultOperation().execute(new SubProgressMonitor(monitor, PROJECT_CREATION_WORK + libArchive.getSize()) , info); - nestedComponent = (IVirtualComponent) importModel.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT); - targetComponents.add(nestedComponent); - String archiveURI = libArchive.getPath().lastSegment(); - compToURIMap.put(nestedComponent, archiveURI); - } - } - /** - * The J2EEComponentClasspathContainr will handle adding these to the classpath, so they - * don't need to be added here. - */ - if (targetComponents.size() > 0) { - IDataModel createRefComponentsModel = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider()); - createRefComponentsModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, virtualComponent); - createRefComponentsModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, "/WEB-INF/lib/"); //$NON-NLS-1$ - createRefComponentsModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, targetComponents); - createRefComponentsModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, compToURIMap); - createRefComponentsModel.getDefaultOperation().execute(new SubProgressMonitor(monitor, LINK_COMPONENTS_WORK * targetComponents.size()), info); - } - } - - @Override - protected SaveStrategy createSaveStrategy(IVirtualComponent aVirtualComponent) { - return new WebComponentSaveStrategyImpl(aVirtualComponent); - } - - @Override - protected ComponentArchiveSaveAdapter getArchiveSaveAdapter( - IVirtualComponent virtualComponent) { - return new WebComponentArchiveSaveAdapter(virtualComponent); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentLoadStrategyImpl.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentLoadStrategyImpl.java deleted file mode 100644 index c4c8cff4c..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentLoadStrategyImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.archive.operations; - -import java.io.File; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; -import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent; -import org.eclipse.jst.j2ee.internal.archive.operations.ComponentLoadStrategyImpl; -import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.eclipse.jst.j2ee.project.WebUtilities; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - -public class WebComponentLoadStrategyImpl extends ComponentLoadStrategyImpl { - - public WebComponentLoadStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - - public WebComponentLoadStrategyImpl(IVirtualComponent vComponent, boolean includeClasspathComponents) { - super(vComponent, includeClasspathComponents); - } - - @Override - public List getFiles() { - super.getFiles(); - addLooseLibJARsToFiles(); - if (includeClasspathComponents) { - addMappedClassFolders(IClasspathDependencyConstants.WEB_INF_CLASSES_PATH); - } - return filesHolder.getFiles(); - } - - public IVirtualReference[] getLibModules() { - return WebUtilities.getLibModules(getComponent()); - } - - public void addLooseLibJARsToFiles() { - IVirtualReference[] libModules = getLibModules(); - for (int i = 0; i < libModules.length; i++) { - IVirtualReference iLibModule = libModules[i]; - IVirtualComponent looseComponent = iLibModule.getReferencedComponent(); - if (looseComponent.isBinary()) { - VirtualArchiveComponent archiveComp = (VirtualArchiveComponent) looseComponent; - java.io.File diskFile = archiveComp.getUnderlyingDiskFile(); - if (!diskFile.exists()) { - IFile wbFile = archiveComp.getUnderlyingWorkbenchFile(); - diskFile = new File(wbFile.getLocation().toOSString()); - } - String uri = iLibModule.getRuntimePath().makeRelative().toString() + "/" + diskFile.getName(); //$NON-NLS-1$ - addExternalFile(uri, diskFile); - } else { - String name = null; - String archiveName = iLibModule.getArchiveName(); - if (archiveName != null && archiveName.length() > 0) { - name = archiveName; - } else { - name = looseComponent.getName() + IJ2EEModuleConstants.JAR_EXT; - } - String prefix = iLibModule.getRuntimePath().makeRelative().toString(); - if (prefix.length() > 0 && prefix.charAt(prefix.length() - 1)!= '/') { - prefix += "/"; //$NON-NLS-1$ - } - - addClasspathComponentDependencies(looseComponent); - - String uri = prefix + name; - try { - Archive utilJAR = J2EEProjectUtilities.asArchive(uri, looseComponent.getProject(), isExportSource()); - if (utilJAR == null) - continue; - filesHolder.addFile(utilJAR); - } catch (OpenFailureException oe) { - String message = ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.UNABLE_TO_LOAD_MODULE_ERROR_, new Object[]{uri, getComponent().getProject().getName(), oe.getConcatenatedMessages()}); - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logTrace(message); - } - } - } - } - @Override - protected synchronized ArtifactEdit getArtifactEditForRead() { - if(artifactEdit == null){ - artifactEdit = WebArtifactEdit.getWebArtifactEditForRead(vComponent); - } - return artifactEdit; - } - - private void addClasspathComponentDependencies(final IVirtualComponent referencedComponent) { - // retrieve all Java classpath component dependencies - if (includeClasspathComponents && referencedComponent instanceof J2EEModuleVirtualComponent) { - final IVirtualReference[] cpRefs = ((J2EEModuleVirtualComponent) referencedComponent).getJavaClasspathReferences(); - for (int j = 0; j < cpRefs.length; j++) { - final IVirtualReference ref = cpRefs[j]; - final IPath runtimePath = ref.getRuntimePath(); - - // only process ../ mappings - if (ref.getReferencedComponent() instanceof VirtualArchiveComponent - && runtimePath.equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH)) { - final VirtualArchiveComponent comp = (VirtualArchiveComponent) ref.getReferencedComponent(); - File cpEntryFile = comp.getUnderlyingDiskFile(); - if (!cpEntryFile.exists()) { - final IFile wbFile = comp.getUnderlyingWorkbenchFile(); - cpEntryFile = new File(wbFile.getLocation().toOSString()); - } - addExternalFile("WEB-INF/lib/" + ref.getArchiveName(), cpEntryFile); //$NON-NLS-1$ - } - } - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentSaveStrategyImpl.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentSaveStrategyImpl.java deleted file mode 100644 index bd76aaf5e..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebComponentSaveStrategyImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.web.archive.operations; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.File; -import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.internal.archive.operations.J2EEComponentSaveStrategyImpl; -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 class WebComponentSaveStrategyImpl extends J2EEComponentSaveStrategyImpl { - - public WebComponentSaveStrategyImpl(IVirtualComponent vComponent) { - super(vComponent); - } - - /** - * DoNotUseMeThisWillBeDeletedPost15 - * - * @deprecated - * @param archive - * @return - */ - protected boolean operationHandlesNested(Archive archive) { - return !shouldLinkAsComponentRef(archive); - } - - @Override - protected boolean shouldAddImportedClassesToClasspath() { - return false; // never add to classpath because the web app container will pick this up. - } - - @Override - protected String getImportedClassesURI(File aFile) { - String uri = aFile.getURI(); - return WTProjectStrategyUtils.makeRelative(uri, ArchiveConstants.WEBAPP_CLASSES_URI); - } - - @Override - protected IPath getImportedClassesRuntimePath() { - return new Path("/" + ArchiveConstants.WEBAPP_CLASSES_URI); //$NON-NLS-1$ - } - - @Override - protected IPath getOutputPathForFile(File aFile) { - if (null != nonStandardSourceFiles && nonStandardSourceFiles.containsKey(aFile)) { - IVirtualFolder rootFolder = vComponent.getRootFolder(); - IVirtualFile vFile = rootFolder.getFile((String) nonStandardSourceFiles.get(aFile)); - IFile iFile = vFile.getUnderlyingFile(); - return iFile.getProjectRelativePath(); - } - return super.getOutputPathForFile(aFile); - } - - /** - * This map handles the case when a java source file is not in the same place as the .class - * file. For example if all the source files were contained in WEB-INF/source - */ - protected Map nonStandardSourceFiles; - - @Override - protected boolean isClassWithoutSource(File aFile) { - String javaUri = ArchiveUtil.classUriToJavaUri(aFile.getURI()); - if (javaUri == null) - return false; - if (archive.containsFile(javaUri)) { - return false; - } - // see if it is a JSP - String jspUri = javaUri.substring(0, javaUri.indexOf(ArchiveUtil.DOT_JAVA)); - int lastSlash = jspUri.lastIndexOf('/'); - int _index = lastSlash == -1 ? ArchiveConstants.WEBAPP_CLASSES_URI.length() : lastSlash + 1; - if (jspUri.charAt(_index) == '_') { - jspUri = jspUri.substring(ArchiveConstants.WEBAPP_CLASSES_URI.length(), _index) + jspUri.substring(_index + 1) + ArchiveUtil.DOT_JSP; - if (archive.containsFile(jspUri)) { - return false; - } - } - - // see if the source is in another directory - File sourceFile = ((WARFile) archive).getSourceFile(aFile); - if (null == sourceFile) { - return true; - } - if (nonStandardSourceFiles == null) { - nonStandardSourceFiles = new HashMap(); - } - if (!nonStandardSourceFiles.containsKey(sourceFile)) { - nonStandardSourceFiles.put(sourceFile, javaUri); - } - return false; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebFacetProjectCreationDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebFacetProjectCreationDataModelProvider.java deleted file mode 100644 index 6d83beb72..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/archive/operations/WebFacetProjectCreationDataModelProvider.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.archive.operations; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties; -import org.eclipse.jst.common.project.facet.JavaFacetUtils; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.J2EEFacetProjectCreationDataModelProvider; -import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.project.facet.ProductManager; - -public class WebFacetProjectCreationDataModelProvider extends J2EEFacetProjectCreationDataModelProvider { - - public WebFacetProjectCreationDataModelProvider() { - super(); - } - - @Override - public void init() { - super.init(); - - Collection<IProjectFacet> requiredFacets = new ArrayList<IProjectFacet>(); - requiredFacets.add(JavaFacetUtils.JAVA_FACET); - requiredFacets.add(IJ2EEFacetConstants.DYNAMIC_WEB_FACET); - setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets); - - FacetDataModelMap map = (FacetDataModelMap) getProperty(FACET_DM_MAP); - IDataModel javaFacet = map.getFacetDataModel( JavaFacetUtils.JAVA_FACET.getId() ); - IDataModel webFacet = map.getFacetDataModel( IJ2EEFacetConstants.DYNAMIC_WEB_FACET.getId() ); - String webRoot = webFacet.getStringProperty(IWebFacetInstallDataModelProperties.CONFIG_FOLDER); - String webSrc = webFacet.getStringProperty(IWebFacetInstallDataModelProperties.SOURCE_FOLDER); - javaFacet.setProperty(IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME, webSrc); - // If using optimized single root structure, set the output folder to "<content folder>/WEB-INF/classes" - if (ProductManager.shouldUseSingleRootStructure()) - javaFacet.setProperty(IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME, webRoot+"/"+J2EEConstants.WEB_INF_CLASSES); //$NON-NLS-1$ - webFacet.addListener(new IDataModelListener() { - public void propertyChanged(DataModelEvent event) { - if (IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME.equals(event.getPropertyName())) { - if (isPropertySet(EAR_PROJECT_NAME)) - setProperty(EAR_PROJECT_NAME, event.getProperty()); - else - model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.DEFAULT_CHG); - }else if (IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR.equals(event.getPropertyName())) { - setProperty(ADD_TO_EAR, event.getProperty()); - } - } - }); - } - - @Override - public boolean propertySet(String propertyName, Object propertyValue) { - if( propertyName.equals( MODULE_URI )){ - FacetDataModelMap map = (FacetDataModelMap) getProperty(FACET_DM_MAP); - IDataModel webFacet = map.getFacetDataModel( J2EEProjectUtilities.DYNAMIC_WEB ); - webFacet.setProperty( IJ2EEModuleFacetInstallDataModelProperties.MODULE_URI, propertyValue ); - } - return super.propertySet(propertyName, propertyValue); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainer.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainer.java deleted file mode 100644 index cdc8e3f25..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainer.java +++ /dev/null @@ -1,107 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005-2006 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.web.classpath; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.osgi.util.NLS; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class WebAppLibrariesContainer - - extends FlexibleProjectContainer - -{ - private static final IPath[] paths - = new IPath[] { new Path( "WEB-INF/lib" ), //$NON-NLS-1$ - new Path( "WEB-INF/classes" ) }; //$NON-NLS-1$ - - private static final PathType[] types - = new PathType[] { PathType.LIB_DIRECTORY, PathType.CLASSES_DIRECTORY }; - - public static final String CONTAINER_ID - = "org.eclipse.jst.j2ee.internal.web.container"; //$NON-NLS-1$ - - public WebAppLibrariesContainer( final IPath path, - final IJavaProject jproject ) - { - super( path, jproject, getProject( path, jproject), paths, types ); - } - - public String getDescription() - { - if( this.owner.getProject() != this.project ) - { - return NLS.bind( Resources.labelWithProject, this.project.getName() ); - } - return Resources.label; - } - - public void install() - { - final IJavaProject[] projects = new IJavaProject[] { this.owner }; - final IClasspathContainer[] conts = new IClasspathContainer[] { this }; - - try - { - JavaCore.setClasspathContainer( path, projects, conts, null ); - } - catch( JavaModelException e ) - { - WebPlugin.log( e ); - } - } - - @Override - public void refresh() - { - ( new WebAppLibrariesContainer( this.path, this.owner ) ).install(); - } - - private static final IProject getProject( final IPath path, - final IJavaProject jproject ) - { - if( path.segmentCount() == 1 ) - { - return jproject.getProject(); - } - final String name = path.segment( 1 ); - return ResourcesPlugin.getWorkspace().getRoot().getProject( name ); - } - - private static final class Resources - - extends NLS - - { - public static String label; - public static String labelWithProject; - - static - { - initializeMessages( WebAppLibrariesContainer.class.getName(), - Resources.class ); - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainer.properties b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainer.properties deleted file mode 100644 index cbdcc18fc..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainer.properties +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# Copyright (c) 2005, 2006 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 -############################################################################### -label = Web App Libraries -labelWithProject = Web App Libraries [{0}]
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainerInitializer.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainerInitializer.java deleted file mode 100644 index 7b0f04a6c..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/classpath/WebAppLibrariesContainerInitializer.java +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005-2006 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.web.classpath; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainerInitializer; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class WebAppLibrariesContainerInitializer - - extends FlexibleProjectContainerInitializer - -{ - @Override - public void initialize( final IPath path, - final IJavaProject jproj ) - - throws CoreException - - { - ( new WebAppLibrariesContainer( path, jproj ) ).install(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ClasspathUtilities.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ClasspathUtilities.java deleted file mode 100644 index aaae1b770..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ClasspathUtilities.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.web.operations; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.jdt.core.IClasspathEntry; - -public class ClasspathUtilities { - - static public IClasspathEntry[] addClasspathEntries(IClasspathEntry[] entries1, IClasspathEntry[] entries2) { - List list = new ArrayList(entries1.length + entries2.length); - list.addAll(Arrays.asList(entries1)); - - for (int i = 0; i < entries2.length; i++) { - IClasspathEntry iClasspathEntry = entries2[i]; - if (!list.contains(iClasspathEntry)) - list.add(iClasspathEntry); - } - - IClasspathEntry[] ret = new IClasspathEntry[list.size()]; - return (IClasspathEntry[]) list.toArray(ret); - } - - static protected boolean entryExists(IClasspathEntry entry, IClasspathEntry[] col) { - for (int i = 0; i < col.length; i++) { - IClasspathEntry otherEntry = col[i]; - if (entry.getContentKind() != otherEntry.getContentKind()) - continue; - - if (entry.getEntryKind() != otherEntry.getEntryKind()) - continue; - - if (entry.isExported() != otherEntry.isExported()) - continue; - - if (!entry.getPath().equals(otherEntry.getPath())) - continue; - return true; - } - return false; - } - - static public IClasspathEntry[] removeClasspathEntries(IClasspathEntry[] removeFromCol, IClasspathEntry[] removeCol) { - List list = new ArrayList(removeFromCol.length); - // list.addAll(Arrays.asList(removeFromCol)); - - for (int i = 0; i < removeFromCol.length; i++) { - IClasspathEntry iClasspathEntry = removeFromCol[i]; - if (!entryExists(iClasspathEntry, removeCol)) - list.add(iClasspathEntry); - } - - IClasspathEntry[] ret = new IClasspathEntry[list.size()]; - return (IClasspathEntry[]) list.toArray(ret); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ConvertStaticWebToDyamnicDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ConvertStaticWebToDyamnicDataModelProvider.java deleted file mode 100644 index 7360e3ac3..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ConvertStaticWebToDyamnicDataModelProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.web.operations; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.jst.j2ee.web.datamodel.properties.IConvertStaticWebToDyamnicDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; - -public class ConvertStaticWebToDyamnicDataModelProvider extends AbstractDataModelProvider implements IConvertStaticWebToDyamnicDataModelProperties { - - - public ConvertStaticWebToDyamnicDataModelProvider() { - super(); - } - - @Override - public IDataModelOperation getDefaultOperation() { - return new ConvertStaticWebToDyamnicOperation(model); - } - - - @Override - public Set getPropertyNames() { - Set propertyNames = new HashSet(); - propertyNames.add(PROJECT); - propertyNames.add(CONVERT_TO_WEB_VERSION); - return propertyNames; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ConvertStaticWebToDyamnicOperation.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ConvertStaticWebToDyamnicOperation.java deleted file mode 100644 index 5b21b57c5..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ConvertStaticWebToDyamnicOperation.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.web.operations; - -import java.util.HashSet; -import java.util.Set; - -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.jst.common.project.facet.IJavaFacetInstallDataModelProperties; -import org.eclipse.jst.common.project.facet.JavaFacetInstallDataModelProvider; -import org.eclipse.jst.common.project.facet.JavaFacetUtils; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.web.datamodel.properties.IConvertStaticWebToDyamnicDataModelProperties; -import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.web.project.facet.WebFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.project.facet.ProductManager; - -public class ConvertStaticWebToDyamnicOperation extends AbstractDataModelOperation { - - public ConvertStaticWebToDyamnicOperation() { - super(); - } - - public ConvertStaticWebToDyamnicOperation(IDataModel dm) { - super(dm); - } - - @Override - public IStatus execute(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - try { - doConvert(); - } catch (Exception e) { - WebPlugin.log(e); - } - - - return OK_STATUS; - } - - protected void doConvert() throws Exception { - - - String selectedVersion = model.getStringProperty(IConvertStaticWebToDyamnicDataModelProperties.CONVERT_TO_WEB_VERSION); - IProject project = (IProject) model.getProperty(IConvertStaticWebToDyamnicDataModelProperties.PROJECT); - IFacetedProject facetedProject = ProjectFacetsManager.create(project); - Set fixedFacets = new HashSet(); - fixedFacets.addAll(facetedProject.getFixedProjectFacets()); - IProjectFacet webFacet = ProjectFacetsManager.getProjectFacet(IModuleConstants.WST_WEB_MODULE); - fixedFacets.remove(webFacet); - fixedFacets.add(WebFacetUtils.WEB_FACET); - fixedFacets.add(JavaFacetUtils.JAVA_FACET); - facetedProject.setFixedProjectFacets(fixedFacets); - IProjectFacetVersion webFv = WebFacetUtils.WEB_FACET.getVersion(selectedVersion); - IProjectFacetVersion javaFv = JavaFacetUtils.compilerLevelToFacet(JavaFacetUtils.getCompilerLevel(project)); - IFacetedProject.Action uninstall = new IFacetedProject.Action(IFacetedProject.Action.Type.UNINSTALL, facetedProject.getInstalledVersion(webFacet), null); - IDataModel webModelCfg = DataModelFactory.createDataModel(new WebFacetInstallDataModelProvider()); - webModelCfg.setBooleanProperty(IWebFacetInstallDataModelProperties.ADD_TO_EAR, false); - // Get the default web root folder name (just in case the .component file doesn't exist for some reason) - String webRoot = webModelCfg.getStringProperty(IWebFacetInstallDataModelProperties.CONFIG_FOLDER); - - IVirtualComponent c = ComponentCore.createComponent(project); - c.create(0, null); - if (c.exists()) { - // Get the web root folder from the .component file - IVirtualFolder root = c.getRootFolder(); - webRoot = root.getUnderlyingFolder().getName(); - // Store the name into the properties for use during facet instal - webModelCfg.setStringProperty(IWebFacetInstallDataModelProperties.CONFIG_FOLDER, webRoot); - } - - IDataModel javaModelCfg = null; - if (ProductManager.shouldUseSingleRootStructure()){ - javaModelCfg = DataModelFactory.createDataModel(new JavaFacetInstallDataModelProvider()); - javaModelCfg.setProperty(IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME, - webRoot+"/"+ J2EEConstants.WEB_INF_CLASSES); //$NON-NLS-1$ - } - - IFacetedProject.Action install = new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL,webFv,webModelCfg); - IFacetedProject.Action javaInstall = new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL, javaFv, javaModelCfg); - Set set = new HashSet(); - set.add(uninstall); - set.add(install); - set.add(javaInstall); - facetedProject.modify(set, new NullProgressMonitor()); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebProjectWizardInfo.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebProjectWizardInfo.java deleted file mode 100644 index e8de100ce..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebProjectWizardInfo.java +++ /dev/null @@ -1,63 +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.web.operations; - -import org.eclipse.jdt.core.IClasspathEntry; - -public interface IWebProjectWizardInfo { - /** - * Adds entries to the class path for this project - */ - public void addToClasspathEntries(IClasspathEntry[] entries); - - /** - * Get the name of the specified project Creation date: (11/09/00 10:05:24 AM) - * - * @return java.lang.String - */ - public String getProjectName(); - - /** - * Get the Enterprise Application Project - */ - public String getEARProjectName(); - - /** - * Get the name of the web content folder. If not set then return the current default. - */ - public String getWebContentName(); - - /** - * Set the name of the web content folder - */ - public void setWebContentName(String name); - - /** - * Get the name of the Java source folder If not set then return the current default. - */ - public String getJavaSourceName(); - - /** - * Set the name of the Java source folder - */ - public void setJavaSourceName(String name); - - /** - * Return an Object for the assocated properties or null - */ - public Object getProperty(String propertyName); - - /** - * Set an Object for the assocated properties or null - */ - public void setProperty(String propertyName, Object value); - - -} - diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebToolingConstants.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebToolingConstants.java deleted file mode 100644 index 9c5053087..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebToolingConstants.java +++ /dev/null @@ -1,34 +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.web.operations; - - - -/* - * The IConfigurationConstants are the list of tags that are usuable for specifying a web - * application parameters via XML - * - * @see WebApplicationSpecification for the full DTD - */ - -public interface IWebToolingConstants { - - public String TRUE = "true"; //$NON-NLS-1$ - public String FALSE = "false"; //$NON-NLS-1$ - - public String HTTP_PATH_PREFIX = "http://"; //$NON-NLS-1$ - public String INDEX_FILE = "index.html"; //$NON-NLS-1$ - public String HTTP_PARAMETER_SEPARATOR = "?"; //$NON-NLS-1$ - public String CONTENT_LENGTH_HEADER_KEY = "Content-Length"; //$NON-NLS-1$ - - public String SENTENCE_TERMINATOR = "."; //$NON-NLS-1$ - - public String POST_COMMAND = "POST"; //$NON-NLS-1$ - public String GET_COMMAND = "GET"; //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebToolingCoreConstants.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebToolingCoreConstants.java deleted file mode 100644 index 1d9eaaaec..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/IWebToolingCoreConstants.java +++ /dev/null @@ -1,29 +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.web.operations; - -/** - * The IWebToolingCoreConstants are the constants required by the ITP core - */ -public interface IWebToolingCoreConstants { - public String PLUG_IN_ID = "com.ibm.etools.webtools"; //$NON-NLS-1$ - public String PROP_SERVLET_JAR = "com.ibm.etools.webtools.servletjar"; //$NON-NLS-1$ - public String PROP_WEBAS_JAR = "com.ibm.etools.webtools.webasjar"; //$NON-NLS-1$ - public String PROP_CLIENT_NAME = "com.ibm.etools.webtools.clientname"; //$NON-NLS-1$ - public String PROP_LINK_STYLE = "com.ibm.etools.webtools.linkstyle"; //$NON-NLS-1$ - public String PROP_MODIFY_LINK_PROMPT = "com.ibm.etools.webtools.modifyprompt"; //$NON-NLS-1$ - public String PROP_AUTO_MODIFY_LINK = "com.ibm.etools.webtools.automodify"; //$NON-NLS-1$ - public String JDT_IDENTIFIER = "org.eclipse.jdt.ui"; //$NON-NLS-1$ - public String RUNTIME_IDENTIFIER = "WebNatureRuntime"; //$NON-NLS-1$ - public String DOC_RELATIVE = "DOC_RELATIVE"; //$NON-NLS-1$ - public String DOC_ROOT_RELATIVE = "DOC_ROOT_RELATIVE"; //$NON-NLS-1$ - public String ICON_PATH = "icons"; //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/MasterCSS.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/MasterCSS.java deleted file mode 100644 index f17c1b7ed..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/MasterCSS.java +++ /dev/null @@ -1,33 +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.web.operations; - - - -/** - * Code generation class compiled from template file MasterCSS.tpl - */ -public class MasterCSS implements WebToolingTemplate { - private static final String TEXT_1 = "BODY\r\n{\r\n BACKGROUND-COLOR: #FFE4B5;\r\n COLOR: black;\r\n FONT-FAMILY: 'Times New Roman'\r\n}\r\nH1\r\n{\r\n COLOR: navy;\r\n FONT-FAMILY: 'Times New Roman';\r\n FONT-SIZE: x-large;\r\n FONT-WEIGHT: bolder;\r\n TEXT-TRANSFORM: capitalize\r\n}\r\nH2\r\n{\r\n COLOR: navy;\r\n FONT-FAMILY: 'Times New Roman';\r\n FONT-SIZE: large;\r\n FONT-WEIGHT: bolder;\r\n TEXT-TRANSFORM: capitalize\r\n}\r\nH3\r\n{\r\n COLOR: navy;\r\n FONT-FAMILY: 'Times New Roman';\r\n FONT-SIZE: large;\r\n FONT-WEIGHT: lighter;\r\n TEXT-TRANSFORM: capitalize\r\n}";//$NON-NLS-1$ - private static final String TEXT_2 = "\r\n";//$NON-NLS-1$ - - /** - * Code generation method - * - * @return String - */ - public String generate(TemplateData data) { - StringBuffer sb = new StringBuffer(); - sb.append(TEXT_1); - sb.append(TEXT_2); - return sb.toString(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/RelationData.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/RelationData.java deleted file mode 100644 index e85421f8f..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/RelationData.java +++ /dev/null @@ -1,994 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.web.operations; - - - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import com.ibm.icu.util.StringTokenizer; -import java.util.Vector; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; - - -/** - * This class stores the relationship between two files. In particular, this is an inLink and the - * files which reference it. - */ -public class RelationData { - public class Link implements Cloneable { - - private String url; - private int occurrences = 0; - - public Link(String newUrl, int occ) { - url = newUrl; - occurrences = occ; - } - - /** - * Returns an exact copy of this object. - * - * @return Created clone object - */ - @Override - public Object clone() { - return new Link(url, occurrences); - } - - /** - * Returns the url of the file that references this inLink - * - * @return String - */ - public String getURL() { - return url; - } - - /** - * Returns the number of times this file references the inLink - * - * @return int - */ - public int getOccurrences() { - return occurrences; - } - - private int addOccurrence(int add) { - occurrences = occurrences + add; - return occurrences; - } - - @Override - public String toString() { - return url; - } - } - - // our relationship table. Key is a string which is the path of the inLink, - // value is a vector of files that reference the inLink. - protected Hashtable inLinksTable = null; - protected Hashtable anchorsTable = null; - private static final int INIT_HASH_TABLE_SIZE = 100; - private static final int INIT_ANCHORS_HASH_TABLE_SIZE = 10; - private boolean fileOk = false; - private static final String LINK_STATE_FILE_NAME = "link_table_states.txt";//$NON-NLS-1$ - private static final String LINK_SERVERCONTEXTROOT_FILE_NAME = "link_scr_states.txt";//$NON-NLS-1$ - public static final String LINK_MISSING_FILE = "-";//$NON-NLS-1$ - public static final String LINK_INDEX_SEPARATOR = "+";//$NON-NLS-1$ - public static final String ANCHOR_INDEX_SEPARATOR = "#";//$NON-NLS-1$ - public static final String LINK_OCCURENCE_SEPARATOR = "/";//$NON-NLS-1$ - public static final String ANCHOR_SEPARATOR = "#### ANCHORS ####";//$NON-NLS-1$ - - /** - * RelationData constructor comment. - */ - public RelationData() { - super(); - inLinksTable = new Hashtable(INIT_HASH_TABLE_SIZE); - anchorsTable = new Hashtable(INIT_ANCHORS_HASH_TABLE_SIZE); - } - - public Link addInLink(String file_path, String parent_path, int occurence) { - Vector in_links = (Vector) inLinksTable.get(file_path); - if (in_links == null) { - return null; - } - for (int i = 0; i < in_links.size(); i++) { - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - - // - // Increment the occurence and return - // - - if (url.compareTo(parent_path) == 0) { - inlnk.addOccurrence(occurence); - return inlnk; - } - } - - // - // The link does not exist, need to add an entry in the table for it - // - - Link inlnk = new Link(parent_path, occurence); - in_links.addElement(inlnk); - return inlnk; - } - - public void changeInLink(String filePath, boolean missing) { - - if (missing) { - Vector inlinks = (Vector) inLinksTable.remove(filePath); - inLinksTable.put(LINK_MISSING_FILE + filePath, inlinks); - } else { - Vector inlinks = (Vector) inLinksTable.remove(LINK_MISSING_FILE + filePath); - inLinksTable.put(filePath, inlinks); - } - } - - - /* - * returns which projects depend on this file i.e. any projects that are in this file's list of - * in_links - */ - public Collection getDependentProjects(String file_path) { - Hashtable outProjects = new Hashtable(); - Vector in_links = (Vector) inLinksTable.get(file_path); - - if (in_links != null) { - for (int i = 0; i < in_links.size(); i++) { - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - // should be in the form of: /ProjName/.... - if (url.length() > 0) { - // key could be the filename or the missing filename ("-" + filename) - // take this into account and offset the index accordingly - int index = 0; - int offset = 1; - if (url.charAt(0) == '-') { - index = url.indexOf(IPath.SEPARATOR, 2); - offset = 2; - } else { - index = url.indexOf(IPath.SEPARATOR, 1); - offset = 1; - } - if (index != -1) { - String projName = url.substring(offset, index); - outProjects.put(projName, projName); - } - } - } - } - return outProjects.values(); - } - - /* - * returns which cross-project files depend on this file i.e. any projects that are in this - * file's list of in_links - */ - public Collection getDependentProjectFiles(String projName) { - Hashtable outProjects = new Hashtable(); - - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String path = (String) aenum.nextElement(); - // should be in the form of: /ProjName/.... - if (path.length() > 0) { - // if path is a missing filename ("-" + filename) then it means that it had - // to come from this project (that is, the external nonexistent file could not have - // linked to this project). So, we will not add this path. Also, since it is marked - // broken, it probably won't exist to do anything with it anyway. - if (path.charAt(0) != '-') { - int index = path.indexOf(IPath.SEPARATOR, 1); - if (index != -1) { - String currentProjName = path.substring(1, index); - if (!currentProjName.equals(projName)) { - outProjects.put(path, path); - } - } - } - } - } - return outProjects.values(); - } - - - - public void createInLinkEntry(String file_path, String parent_path, int occurence) { - - Vector in_links = new Vector(); - Link inlnk = new Link(parent_path, occurence); - in_links.addElement(inlnk); - inLinksTable.put(file_path, in_links); - } - - - - public void dump() { -// if (false) { -// if (inLinksTable != null) { -// for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { -// StringBuffer St = new StringBuffer(); -// String key = (String) aenum.nextElement(); -// St.append("\nKey=" + key + "\n");//$NON-NLS-1$//$NON-NLS-2$ -// Vector in_links = (Vector) inLinksTable.get(key); -// int nb_of_links = in_links.size(); -// -// // Replace the string by index -// // Add a '+'separator only for more than one links to save space -// // -// -// -// for (int i = 0; i < nb_of_links; i++) { -// Link lnk = (Link) in_links.elementAt(i); -// St.append("\tValue=" + lnk.getURL() + "[" + lnk.getOccurrences() + "]");//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ -// } -// org.eclipse.jem.util.logger.proxy.Logger.getLogger().logInfo(St.toString()); -// } -// } -// } - } - - public void dump(boolean dump) { - if (dump) { - if (inLinksTable != null) { - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - StringBuffer St = new StringBuffer(); - String key = (String) aenum.nextElement(); - St.append("\nKey=" + key + "\n");//$NON-NLS-1$//$NON-NLS-2$ - Vector in_links = (Vector) inLinksTable.get(key); - int nb_of_links = in_links.size(); - - // Replace the string by index - // Add a '+'separator only for more than one links to save space - // - - - for (int i = 0; i < nb_of_links; i++) { - Link lnk = (Link) in_links.elementAt(i); - St.append("\tValue=" + lnk.getURL() + "[" + lnk.getOccurrences() + "]");//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ - } - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(St.toString()); - } - } - } - } - - /** - * used for LinksBuilder debugging - */ - public void dump2() { - if (inLinksTable != null) { - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - StringBuffer St = new StringBuffer(); - String key = (String) aenum.nextElement(); - - Vector in_links = (Vector) inLinksTable.get(key); - int nb_of_links = in_links.size(); - St.append("\nKey=" + key + " -- num:" + nb_of_links + "\n");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ - // Replace the string by index - // Add a '+'separator only for more than one links to save space - // - - - for (int i = 0; i < nb_of_links; i++) { - Link lnk = (Link) in_links.elementAt(i); - St.append("\tValue=" + lnk.getURL() + "[" + lnk.getOccurrences() + "]");//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ - } - System.out.println(St.toString()); - } - } - System.out.println("************************************************\n\n\n\n************************************\n"); //$NON-NLS-1$ - } - - - public Vector getInLinks(String filePath) { - return (Vector) inLinksTable.get(filePath); - } - - public void getInLinks(String filePath, Vector vectInLinks) { - - if (inLinksTable != null) { - dump(); - Vector in_links = (Vector) inLinksTable.get(filePath); - if (in_links != null) { - for (int i = 0; i < in_links.size(); i++) { - Link inlnk = (Link) ((Link) in_links.elementAt(i)).clone(); - vectInLinks.addElement(inlnk); - } - } - } - } - - public Hashtable getAnchorsTable() { - return anchorsTable; - } - - /** - * Returns the file used to store ServerContextRoot for the project. - */ - public static File getPreviousSCRFile(IProject project) { - return new Path(J2EEPlugin.getDefault().getStateLocation().toString() + File.separator + project.getName() + File.separator + LINK_SERVERCONTEXTROOT_FILE_NAME).toFile(); - } - - /** - * Returns the file used to store the state of the link relations for the project. - * - * @return java.io.File The state file - * @param project - * org.eclipse.core.resources.IProject The project to get the state file for. - */ - private File getStateFile(IProject project) { - return new Path(J2EEPlugin.getDefault().getStateLocation().toString() + File.separator + project.getName() + File.separator + LINK_STATE_FILE_NAME).toFile(); - } - - public boolean hasInLinkEntry(String path) { - return inLinksTable.containsKey(path); - } - - /** - * Run through all missing-file (-) RD entries to see if any of them closely match the path to - * this class. Return all of the matches. - */ - public Vector getPossibleMissingEndingMatches(IPath classPath) { - Vector v = new Vector(); - - String match = classPath.lastSegment(); - match = match.substring(0, match.length() - 6); // length minus ".class" - - String classPathStr = classPath.toString(); - String matchingClassPath = classPathStr.toString().substring(0, classPathStr.length() - 6); - - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String path = (String) aenum.nextElement(); - // check if path ends with the class name that has been added/removed - if (path.startsWith(LINK_MISSING_FILE) && path.endsWith(match)) { - // OK: simple match found; now let's match with finer granularity. - // Take path and put it into a form where we can check if it is a - // close match to the class that has changed: - // /Proj/Web Content/com.acme.Foo --> com/acme/Foo - String linkPath; - int index = path.lastIndexOf(IPath.SEPARATOR); - if (index != -1 && index < path.length() - 1) { - linkPath = path.substring(index + 1); - } else { - linkPath = path; - } - String closeMatch = linkPath.replace('.', IPath.SEPARATOR); - - if (matchingClassPath.endsWith(closeMatch)) { - Vector in_links = (Vector) inLinksTable.get(path); - String nonMissingPath = path.substring(1, path.length()); - changeInLink(nonMissingPath, false); - if (in_links != null) { - for (int i = 0; i < in_links.size(); i++) { - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - v.add(url); - } - } - } - } - } - return v; - } - - - /** - * Run through all existing RD entries to see if any of them closely match the path to this - * class. Return all of the matches. - */ - public Vector getPossibleExistingEndingMatches(IPath classPath) { - Vector v = new Vector(); - - String match = classPath.lastSegment(); - match = match.substring(0, match.length() - 6); // length minus ".class" - - String classPathStr = classPath.toString(); - String matchingClassPath = classPathStr.toString().substring(0, classPathStr.length() - 6); - - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String path = (String) aenum.nextElement(); - // check if path ends with the class name that has been added/removed - if (path.endsWith(match) && !path.startsWith(LINK_MISSING_FILE)) { - // OK: simple match found; now let's match with finer granularity. - // Take path and put it into a form where we can check if it is a - // close match to the class that has changed: - // /Proj/Web Content/com.acme.Foo --> com/acme/Foo - String linkPath; - int index = path.lastIndexOf(IPath.SEPARATOR); - if (index != -1 && index < path.length() - 1) { - linkPath = path.substring(index + 1); - } else { - linkPath = path; - } - String closeMatch = linkPath.replace('.', IPath.SEPARATOR); - - if (matchingClassPath.endsWith(closeMatch)) { - Vector in_links = (Vector) inLinksTable.get(path); - changeInLink(path, true); - if (in_links != null) { - for (int i = 0; i < in_links.size(); i++) { - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - v.add(url); - } - } - } - } - } - return v; - } - - /** - * Run through all existing RD entries to see if any of them closely match the path to this - * class. Remove the inlinks for all the matches. - */ - public void removeInLinksPossibleExistingEndingMatches(IPath classPath) { - String match = classPath.lastSegment(); - match = match.substring(0, match.length() - 6); // length minus ".class" - - String classPathStr = classPath.toString(); - String matchingClassPath = classPathStr.toString().substring(0, classPathStr.length() - 6); - - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String path = (String) aenum.nextElement(); - if (path.endsWith(match) && !path.startsWith(LINK_MISSING_FILE)) { - // OK: simple match found; now let's match with finer granularity. - // Take path and put it into a form where we can check if it is a - // close match to the class that has changed: - // /Proj/Web Content/com.acme.Foo --> com/acme/Foo - String linkPath; - int index = path.lastIndexOf(IPath.SEPARATOR); - if (index != -1 && index < path.length() - 1) { - linkPath = path.substring(index + 1); - } else { - linkPath = path; - } - String closeMatch = linkPath.replace('.', IPath.SEPARATOR); - - if (matchingClassPath.endsWith(closeMatch)) { - removeInLinks(path); - } - } - } - } - - /** - * Initialize links tables - */ - public void initialize() { - inLinksTable = new Hashtable(INIT_HASH_TABLE_SIZE); - anchorsTable = new Hashtable(INIT_ANCHORS_HASH_TABLE_SIZE); - - } - - /** - * Initialize links tables - */ - public void initializeAnchors() { - anchorsTable = new Hashtable(INIT_ANCHORS_HASH_TABLE_SIZE); - } - - /** - * Initialize links tables - */ - public void initializeInLinks() { - inLinksTable = new Hashtable(INIT_HASH_TABLE_SIZE); - } - - /** - * Return true if the file to restore data from existed and was successfully read. - * - * @return boolean - */ - public boolean isFileOk() { - return fileOk; - } - - public boolean isInitialized() { - return (inLinksTable != null); - } - - public void newInLinkEntry(String path) { - if (!inLinksTable.containsKey(path)) - inLinksTable.put(path, new Vector()); - } - - public void removeInLinks(String file_path) { - - // - // Iterate through the fLinksTable to remove all in-links references - // for file_path - // - - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String key = (String) aenum.nextElement(); - Vector in_links = (Vector) inLinksTable.get(key); - - for (int i = 0; i < in_links.size(); i++) { - - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - - if (url.compareTo(file_path) == 0) { - in_links.removeElementAt(i); - break; - } - - // - // Remove the entry in the fLinksTable if the in-link - // of the file is not in the workbench and an orphan link - // otherwise update the in-links fLinksTable - // - } - - if (in_links.isEmpty() && key.startsWith(LINK_MISSING_FILE)) { - inLinksTable.remove(key); - } - } - } - - /** - * Iterate through the fLinksTable to return all out-links references for file_path - * - * @param file_path - * @return - */ - public List getOutLinks(String file_path) { - ArrayList list = new ArrayList(); - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String key = (String) aenum.nextElement(); - Vector in_links = (Vector) inLinksTable.get(key); - - for (int i = 0; i < in_links.size(); i++) { - - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - - if (url.compareTo(file_path) == 0) { - list.add(key); - break; - } - } - } - - return list; - } - - - /** - * return whether other resources link to this file or not - */ - public boolean referencedByOtherLinks(String file_path) { - - // - // Iterate through the fLinksTable to remove all in-links references - // for file_path - // - boolean referenced = false; - for (Enumeration aenum = inLinksTable.keys(); !referenced && aenum.hasMoreElements();) { - String key = (String) aenum.nextElement(); - Vector in_links = (Vector) inLinksTable.get(key); - - for (int i = 0; i < in_links.size(); i++) { - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - - if (url.compareTo(file_path) == 0) { - referenced = true; - break; - } - } - } - return referenced; - } - - - /* - * performs as removeInLinks( String ) ... But for performance reasons, this also additionally - * returns a list of all the projects that this file is dependent upon. This is useful to get - * this information, and then go to all of those projects' relation data and tell them to - * removeInLinks for this file. - */ - public Collection removeInLinksForProjects(String file_path) { - - // - // Iterate through the fLinksTable to remove all in-links references - // for file_path - // - Hashtable projects = new Hashtable(); - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String key = (String) aenum.nextElement(); - Vector in_links = (Vector) inLinksTable.get(key); - - for (int i = 0; i < in_links.size(); i++) { - - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - - if (url.compareTo(file_path) == 0) { - // should be in the form of: /ProjName/.... - if (key.length() > 0) { - // key could be the filename or the missing filename ("-" + filename) - // take this into account and offset the index accordingly - int index = 0; - int offset = 1; - if (key.charAt(0) == '-') { - index = key.indexOf(IPath.SEPARATOR, 2); - offset = 2; - } else { - index = key.indexOf(IPath.SEPARATOR, 1); - offset = 1; - } - if (index != -1) { - String projName = key.substring(offset, index); - projects.put(projName, projName); - } - } - in_links.removeElementAt(i); - break; - } - - // - // Remove the entry in the fLinksTable if the in-link - // of the file is not in the workbench and an orphan link - // otherwise update the in-links fLinksTable - // - } - - if (in_links.isEmpty() && key.startsWith(LINK_MISSING_FILE)) - inLinksTable.remove(key); - } - - return projects.values(); - } - - - - /** - * performs as removeInLinks( String ) ... But for performance reasons, it additionally returns - * which projects depend on this file. i.e. any projects that are in this file's list of - * in_links - */ - public Collection removeInLinksAndGetDependentProjects(String file_path) { - // - // Iterate through the fLinksTable to remove all in-links references - // for file_path - // - Hashtable projects = new Hashtable(); - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String key = (String) aenum.nextElement(); - Vector in_links = (Vector) inLinksTable.get(key); - - if (key.equals(RelationData.LINK_MISSING_FILE + file_path)) { - int index = -1; - for (int i = 0; i < in_links.size(); i++) { - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - - if (url.compareTo(file_path) == 0) { - index = i; - } - if (url.length() > 1) { - int projindex = url.indexOf(IPath.SEPARATOR, 1); - if (projindex != -1) { - String projName = url.substring(1, projindex); - projects.put(projName, projName); - } - } - } - if (index != -1) { - in_links.removeElementAt(index); - } - - } else { - for (int i = 0; i < in_links.size(); i++) { - - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - - if (url.compareTo(file_path) == 0) { - - in_links.removeElementAt(i); - break; - } - - // - // Remove the entry in the fLinksTable if the in-link - // of the file is not in the workbench and an orphan link - // otherwise update the in-links fLinksTable - // - } - } - - if (in_links.isEmpty() && key.startsWith(LINK_MISSING_FILE)) { - inLinksTable.remove(key); - } - } - return projects.values(); - } - - - /** - * remove all references to a specific inLink. When removeOrphan is true the inLink entry is - * removed as well, when there are no more refereces to it - */ - public void removeInLinks(String inLinkEntry, String inLinkReference, boolean removeOrphan) { - - String key = inLinkEntry; - Vector in_links = (Vector) inLinksTable.get(key); - - for (int i = 0; i < in_links.size(); i++) { - - Link inlnk = (Link) in_links.elementAt(i); - String url = inlnk.getURL(); - - if (url.compareTo(inLinkReference) == 0) { - in_links.removeElementAt(i); - break; - } - } - - // If there are no more references to the inLinkEntry - // and the caller wants this orphan deleted then - // remove the key from the table - if (in_links.isEmpty() && removeOrphan) - inLinksTable.remove(key); - - } - - /** - * Restores this builder's saved state and returns whether it was successful in doing so. - */ - public boolean restore(IProject project) { - if (project != null) { - // get the state - File stateFile = getStateFile(project); - if (stateFile.exists()) { - inLinksTable = new Hashtable(INIT_HASH_TABLE_SIZE); - - // read inLinksTable from stateFile - Vector keys = new Vector(); - Vector indices = new Vector(); - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(stateFile)); - - String line = null; - // while( ((line = reader.readLine()) != null) && !line.startsWith( - // ANCHOR_SEPARATOR ) ) - while ((line = reader.readLine()) != null) { - String buffer = line; - - - // to take into account the possibility of links spanning multiple lines, - // keep reading until we find a line that starts with an idicator - // that the link is finished (a line beginning w/ LINK_INDEX_SEPARATOR) - line = reader.readLine(); - while (line != null && !line.startsWith(LINK_INDEX_SEPARATOR)) { - buffer = buffer + line; - line = reader.readLine(); - } - // add link string (/MyProj/file.html) - keys.addElement(buffer); - // add references line (+2/3...) - if (line != null) { - indices.addElement(line); - } else { - System.out.println(ProjectSupportResourceHandler.Syntax_Error_in_the_links_UI_); // = "Syntax Error in the links state file" - return false; - } - } - - // Use this to load anchor information - // // Now let's add all of the extra anchor information - // if ( line != null && line.startsWith( ANCHOR_SEPARATOR ) ) { - // while( (line = reader.readLine()) != null ) - // { - // String buffer = line; - // - // // to take into account the possibility of links spanning multiple lines, - // // keep reading until we find a line that starts with an idicator - // // that the link is finished (a line beginning w/ LINK_INDEX_SEPARATOR) - // line = reader.readLine(); - // while ( line != null && !line.startsWith( ANCHOR_INDEX_SEPARATOR ) ) { - // buffer = buffer + line; - // line = reader.readLine(); - // } - // - // // add file and all of its anchors - // if ( buffer != null && line != null) - // { - // anchorsTable.put( buffer, line ); - // } - // else - // { - // System.out.println(ResourceHandler.getString("Syntax_Error_in_the_links_UI_")); - // //$NON-NLS-1$ = "Syntax Error in the links state file" - // return false; - // } - // } - // - // } - } catch (FileNotFoundException fe) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(fe); - } catch (IOException ie) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ie); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException ie2) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ie2); - } - } - } - - - // - // Populate the hash inLinksTable with keys (file paths) and values (in links files - // paths) - // - fileOk = true; - for (int i = 0; i < keys.size(); i++) { - try { - String key = (String) keys.elementAt(i); - String compacted_indices = (String) indices.elementAt(i); - - // - // Parse the in-links indexes - // - - int size = keys.size(); - Vector in_links = new Vector(); - if (compacted_indices != LINK_INDEX_SEPARATOR) { - - // Extract indexes and occurences - - StringTokenizer st_idx_occ = new StringTokenizer(new String(compacted_indices), LINK_INDEX_SEPARATOR); - while (st_idx_occ.hasMoreTokens()) { - String idx_occ = new String(st_idx_occ.nextToken()); - int pos_occ = idx_occ.indexOf(LINK_OCCURENCE_SEPARATOR); - int index; - int occurence = 1; - if (pos_occ == -1) { - index = Integer.valueOf(idx_occ).intValue(); - } else { - index = Integer.valueOf(idx_occ.substring(0, pos_occ)).intValue(); - occurence = Integer.valueOf(idx_occ.substring(pos_occ + 1)).intValue(); - } - if (index >= 0 && index < size) { - Link inlnk = new Link((String) keys.elementAt(index), occurence); - in_links.addElement(inlnk); - } - } - } - inLinksTable.put(key, in_links); - } catch (Exception e) { - fileOk = false; - } - } - - return fileOk; - } - return false; - - } - - return false; - } - - /** - * Saves this builder's state to disk so that it can be restarted in the same state later. - */ - public void save(IProject project) { - - File stateFile = getStateFile(project); - if (inLinksTable == null) { - stateFile.delete(); - } else { - - // Prepare the index vector - - Vector index_vector = new Vector(inLinksTable.size()); - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - index_vector.addElement(aenum.nextElement()); - } - - // write inLinksTable to stateFile - - try { - File parentFolder = stateFile.getParentFile(); - if (!parentFolder.exists()) { - parentFolder.mkdirs(); - } - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(stateFile))); - for (Enumeration aenum = inLinksTable.keys(); aenum.hasMoreElements();) { - String key = (String) aenum.nextElement(); - out.print(key); - out.println(); - out.print(LINK_INDEX_SEPARATOR); - Vector in_links = (Vector) inLinksTable.get(key); - int nb_of_links = in_links.size(); - - // Replace the string by index - // Add a '+'separator only for more than one links to save space - // Add '/<occurence>' only if occurence > 1 to save space - // - - Link lnk = null; - int nb_lnks = 0; - if (nb_of_links > 0) { - lnk = (Link) in_links.elementAt(0); - out.print(index_vector.indexOf(lnk.getURL())); - nb_lnks = lnk.getOccurrences(); - if (nb_lnks > 1) { - out.print(LINK_OCCURENCE_SEPARATOR); - out.print(nb_lnks); - } - for (int i = 1; i < nb_of_links; i++) { - out.print(LINK_INDEX_SEPARATOR); - lnk = (Link) in_links.elementAt(i); - out.print(index_vector.indexOf(lnk.getURL())); - nb_lnks = lnk.getOccurrences(); - if (nb_lnks > 1) { - out.print(LINK_OCCURENCE_SEPARATOR); - out.print(nb_lnks); - } - } - } - out.println(); - } - /* - * use this to save out anchor information // - * ############################################ if ( !anchorsTable.isEmpty() ) { - * out.println( ANCHOR_SEPARATOR ); } for (Enumeration enum = anchorsTable.keys(); - * enum.hasMoreElements();) { String key = (String) enum.nextElement(); - * out.print(key); out.println(); //out.print(ANCHOR_INDEX_SEPARATOR); out.println( - * anchorsTable.get(key) ); } - */ - - out.flush(); - out.close(); - } catch (IOException e) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ProjectSupportResourceHandler.Error_while_saving_links_s_EXC_); // = "Error while saving links state file" - } - } - } - - /** - * Insert the method's description here. Creation date: (3/21/2001 1:45:58 PM) - * - * @param newFileOk - * boolean - */ - void setFileOk(boolean newFileOk) { - fileOk = newFileOk; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ServerTargetUtil.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ServerTargetUtil.java deleted file mode 100644 index 5003dc621..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/ServerTargetUtil.java +++ /dev/null @@ -1,133 +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 Sep 12, 2003 - */ -package org.eclipse.jst.j2ee.internal.web.operations; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.servertarget.IServerTargetConstants; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerCore; - -/** - * A class with some useful methods that support server targetting for Web projects. - * - * @author Pratik Shah - */ -public class ServerTargetUtil { - - private static final String defaultId = "com.ibm.etools.websphere.serverTarget.base.v51"; //$NON-NLS-1$ - private static final String defaultExpressId = "com.ibm.etools.websphere.serverTarget.express.v51"; //$NON-NLS-1$ - - /** - * @param targets - * A list of IServerTargets - * @return The index of the target server with the - * {@link #getDefaultServerTargetId() default Id}; or 0, if it could not be found. - */ - public static int findDefaultServerTargetIndex(List targets) { - int index = 0; - for (int i = 0; i < targets.size(); i++) { - IRuntime target = (IRuntime) targets.get(i); - if (target.getId().equals(getDefaultServerTargetId())) { - index = i; - break; - } - } - return index; - } - - /** - * @param target - * The IServerTarget that has to be found in the given list; it can be - * <code>null</code> - * @param list - * The List from which the IServerTarget has to be found - * - * @return The index of the given target in the given list; or 0, if the given target could not - * be found in the given list. Two IServerTargets are considered to be equal if they - * have the same ID. - */ - public static int findIndexOf(IRuntime target, List list) { - int index = 0; - if (target != null) { - for (int i = 0; i < list.size(); i++) { - IRuntime element = (IRuntime) list.get(i); - if (element.equals(target)) { - index = i; - break; - } - } - } - return index; - } - - /** - * @return the Id of the target server that should be selected by default - */ - public static String getDefaultServerTargetId() { - String id = defaultExpressId; - if (J2EEPlugin.isEJBSupportAvailable()) { - id = defaultId; - } - return id; - } - - /** - * @param isJ2EE13 - * <code>true</code> if the constant for J2EE version 1.3 is desired - * @return IServerTargetConstants.J2EE_12 or IServerTargetConstants.J2EE_13 - */ - public static String getJ2EEVersion(boolean isJ2EE13) { - return isJ2EE13 ? IServerTargetConstants.J2EE_13 : IServerTargetConstants.J2EE_12; - } - - /** - * A convenient method that takes in a list of IServerTargets and returns an array of labels of - * the IServerTargets in the given list. - * - * @param serverTargets - * The list of IServerTargets - * @return An array lof labels of the IServerTargets in the given list - */ - public static String[] getServerNames(List serverTargets) { - String[] result = new String[serverTargets.size()]; - for (int i = 0; i < result.length; i++) { - IRuntime runtime = (IRuntime) serverTargets.get(i); - result[i] = runtime.getName() + " (" + runtime.getRuntimeType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - return result; - } - - /** - * @param prjName - * name of the project whose ServerTarget has to be retrieved; it can be - * <code>null</code> - * - * @return the ServerTarget of the given project; <code>null</code> if the project does not - * exist or its ServerTarget is not specified. - */ - public static IRuntime getServerTarget(String prjName) { - if (prjName != null && !prjName.trim().equals("")) { //$NON-NLS-1$ - IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(prjName); - if (prj != null && prj.exists()) { - return ServerCore.getProjectProperties(prj).getRuntimeTarget(); - } - } - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/TemplateData.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/TemplateData.java deleted file mode 100644 index 092e80054..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/TemplateData.java +++ /dev/null @@ -1,94 +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.web.operations; - - - -public class TemplateData { - protected java.lang.String wtFileName = "";//$NON-NLS-1$ - protected java.lang.String wtCSSName = "";//$NON-NLS-1$ - protected java.lang.String wtContainerLocatoin = "";//$NON-NLS-1$ - protected java.lang.String taglibs; - - /** - * TemplateData constructor comment. - */ - public TemplateData() { - super(); - } - - /** - */ - public String getContainerLocatoin() { - return wtContainerLocatoin; - } - - /** - * Insert the method's description here. Creation date: (6/4/2001 5:24:30 PM) - * - * @return java.lang.String - */ - public java.lang.String getCSSName() { - return wtCSSName; - } - - /** - * Insert the method's description here. Creation date: (6/4/2001 5:22:56 PM) - * - * @return java.lang.String - */ - public String getFileName() { - return wtFileName; - } - - /** - * Insert the method's description here. Creation date: (11/15/2001 4:16:10 PM) - * - * @return java.lang.String - */ - public java.lang.String getTaglibs() { - return taglibs; - } - - /** - */ - public void setContainerLocatoin(String newFileName) { - wtContainerLocatoin = newFileName; - } - - /** - * Insert the method's description here. Creation date: (6/4/2001 5:24:30 PM) - * - * @param newCSSName - * java.lang.String - */ - public void setCSSName(java.lang.String newCSSName) { - wtCSSName = newCSSName; - } - - /** - * Insert the method's description here. Creation date: (6/4/2001 5:22:56 PM) - * - * @param newWtFileName - * java.lang.String - */ - public void setFileName(String newFileName) { - wtFileName = newFileName; - } - - /** - * Insert the method's description here. Creation date: (11/15/2001 4:16:10 PM) - * - * @param newTaglibs - * java.lang.String - */ - public void setTaglibs(java.lang.String newTaglibs) { - taglibs = newTaglibs; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebPropertiesUtil.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebPropertiesUtil.java deleted file mode 100644 index ea10b0aaa..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebPropertiesUtil.java +++ /dev/null @@ -1,573 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.operations; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; - -import com.ibm.icu.util.StringTokenizer; - -public class WebPropertiesUtil { - // private static final char[] BAD_CHARS = {'/', '\\', ':'}; - private static final char[] BAD_CHARS = {':'}; - public static final String DEFAULT_JAVA_SOURCE_NAME = "Java Source"; //$NON-NLS-1$ - //TODO Port to flexible structure - /** - * Update the Web Content folder to a new value if it is different. This applies to both Static - * and J2EE Web Projects. In the case of a J2EE Project, the library classpath entries will be - * modifies to reflect the new location. - * - * @param project - * The Web Project to update - * @param webContentName - * The new name given to the Web Project's Web Content folder - * @param progressMonitor - * Indicates progress of the update operation - * @return True if the web content rename was actually renamed, false if unneeded. - * @throws CoreException - * The exception that occured during renaming of the the project's web content - * folder - */ - public static boolean updateWebContentNameAndProperties(IProject project, String webContentName, IProgressMonitor progressMonitor) throws CoreException { - boolean success = false; - if (project.exists() && project.isOpen()) { - - /* - * IBaseWebNature webNature = J2EEWebNatureRuntimeUtilities.getRuntime(project); if - * (webContentName == null) { if (webNature.isStatic()) { webContentName = - * J2EEWebNatureRuntimeUtilities.getDefaultStaticWebContentName(); } else { - * webContentName = J2EEWebNatureRuntimeUtilities.getDefaultJ2EEWebContentName(); } } - */ - - IPath newPath = new Path(webContentName); - if (getModuleServerRoot(project).getProjectRelativePath().equals(newPath)) - return false; - if (project.exists(newPath)) { - IStatus status = new Status(IStatus.ERROR, "org.eclipse.jst.j2ee", IStatus.OK, ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Could_not_rename_____2, new Object[]{webContentName}), null); //$NON-NLS-1$ - throw new CoreException(status); - } - - moveWebContentFolder(project, webContentName, progressMonitor); - updateWebContentNamePropertiesOnly(project, webContentName, progressMonitor); - success = true; - } - return success; - } - - /** - * Update the classpath entries and Server Root Name for this web project only. - * - * @param project - * @param webContentName - * @return - */ - public static void updateWebContentNamePropertiesOnly(IProject project, String webContentName, IProgressMonitor progressMonitor) throws CoreException { - IPath newPath = new Path(webContentName); - if (getModuleServerRoot(project).equals(newPath)) - return; - - if (!getModuleServerRoot(project).equals(webContentName)) { - - // if (webModuleArtifact.isJ2EE) { - // Update the library references - IJavaProject javaProject = JemProjectUtilities.getJavaProject(project); - - IClasspathEntry[] classpath = javaProject.getRawClasspath(); - IClasspathEntry[] newClasspath = new IClasspathEntry[classpath.length]; - - for (int i = 0; i < classpath.length; i++) { - if (classpath[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { - IClasspathEntry library = classpath[i]; - IPath libpath = library.getPath(); - IPath modServerRootPath = getModuleServerRoot(project).getFullPath(); - if (modServerRootPath.isPrefixOf(libpath)) { - IPath prunedPath = libpath.removeFirstSegments(modServerRootPath.segmentCount()); - IPath relWebContentPath = new Path(webContentName + "/" + prunedPath.toString()); //$NON-NLS-1$ - IResource absWebContentPath = project.getFile(relWebContentPath); - - IPath srcAttachmentPath = library.getSourceAttachmentPath(); - if (null != srcAttachmentPath) { - prunedPath = srcAttachmentPath.removeFirstSegments(modServerRootPath.segmentCount()); - } - IResource absWebContentSrcAttachmentPath = project.getFile(relWebContentPath); - - newClasspath[i] = JavaCore.newLibraryEntry(absWebContentPath.getFullPath(), absWebContentSrcAttachmentPath.getFullPath(), library.getSourceAttachmentRootPath(), library.isExported()); - - } else { - newClasspath[i] = classpath[i]; - } - - } else { - newClasspath[i] = classpath[i]; - } - // } - - // Set the java output folder - IFolder outputFolder = project.getFolder(getModuleServerRoot(project).getFullPath()); - javaProject.setRawClasspath(newClasspath, outputFolder.getFullPath(), new SubProgressMonitor(progressMonitor, 1)); - } - // update websettings - // TODO add to WebArtifactEdit - // webNature.setModuleServerRootName(webContentName); - } - } - - /** - * Moves the web content folder to the name indicated only if that path doesn't already exist in - * the project. - * - * @param project - * The web project to be updated. - * @param webContentName - * The new web content name - * @param progressMonitor - * Indicates progress - * @throws CoreException - * The exception that occured during move operation - */ - public static void moveWebContentFolder(IProject project, String webContentName, IProgressMonitor progressMonitor) throws CoreException { - IPath newPath = new Path(webContentName); - if (!project.exists(newPath)) { - if (newPath.segmentCount() > 1) { - for (int i = newPath.segmentCount() - 1; i > 0; i--) { - IPath tempPath = newPath.removeLastSegments(i); - IFolder tempFolder = project.getFolder(tempPath); - if (!tempFolder.exists()) { - tempFolder.create(true, true, null); - } - } - } - newPath = project.getFullPath().append(newPath); - IContainer webContentRoot = getModuleServerRoot(project); - IPath oldPath = webContentRoot.getProjectRelativePath(); - webContentRoot.move(newPath, IResource.FORCE | IResource.KEEP_HISTORY, new SubProgressMonitor(progressMonitor, 1)); - for (int i = 0; i < oldPath.segmentCount(); i++) { - IPath tempPath = oldPath.removeLastSegments(i); - IFolder tempFolder = project.getFolder(tempPath); - if (tempFolder.exists() && tempFolder.members().length == 0) { - tempFolder.delete(true, true, null); - } - } - } - } - - /** - * Synchonizies the class path and the lib directories to catch any changes from the last use - * Creation date: (4/17/01 11:48:12 AM) - */ - protected static void synch(IProject project, IProgressMonitor monitor) { - IProgressMonitor localMonitor = monitor; - try { - if (localMonitor == null) { - localMonitor = new NullProgressMonitor(); - } - localMonitor.beginTask(ProjectSupportResourceHandler.Sychronize_Class_Path_UI_, 4); - //$NON-NLS-1$ = "Sychronize Class Path" - - IContainer lib_folder = getWebLibFolder(project); - // Nothing to do if the lib folder does not exist. - if (lib_folder == null || !lib_folder.isAccessible()) - return; - IJavaProject javaProject = JemProjectUtilities.getJavaProject(project); - IPath lib_path = lib_folder.getProjectRelativePath(); - IPath lib_full_path = lib_folder.getFullPath(); - - IClasspathEntry[] cp = javaProject.getRawClasspath(); - - boolean needsToBeModified = false; - // Create a map of the lib projects in the current project - Hashtable lib_jars = new Hashtable(); - IResource[] children = lib_folder.members(); - localMonitor.subTask(ProjectSupportResourceHandler.Catalog_Lib_Directory__UI_); - //$NON-NLS-1$ = "Catalog Lib Directory:" - for (int j = 0; j < children.length; j++) { - IResource child = children[j]; - // monitor.setTaskName(ResourceHandler.getString("Catalog_Lib_Directory__UI_") + - // child); //$NON-NLS-1$ = "Catalog Lib Directory:" - // Make sure it is a zip or a jar file - if (child.getType() == IResource.FILE && (child.getFullPath().toString().toLowerCase().endsWith(IJ2EEModuleConstants.JAR_EXT) - || child.getFullPath().toString().toLowerCase().endsWith(".zip"))) { //$NON-NLS-1$ - lib_jars.put(child.getFullPath(), child); - } - - } - - localMonitor.worked(1); - localMonitor.subTask(ProjectSupportResourceHandler.Update_ClassPath__UI_); - //$NON-NLS-1$ = "Update ClassPath:" - // Loop through all the classpath dirs looking for ones that may have - // been deleted - Vector newClassPathVector = new Vector(); - for (int j = 0; j < cp.length; j++) { - - // If it is a lib_path - if (cp[j].getPath().toString().startsWith(lib_path.toString()) || cp[j].getPath().toString().startsWith(lib_full_path.toString())) { - // It was already in the class path - if (lib_jars.get(cp[j].getPath()) != null) { - newClassPathVector.add(cp[j]); - // Remove it from the hash table of paths to add back - // monitor.setTaskName(ResourceHandler.getString("Catalog_Lib_Directory__UI_") - // + cp[j].getPath()); //$NON-NLS-1$ = "Catalog Lib Directory:" - lib_jars.remove(cp[j].getPath()); - - } else { - // You have removed something form the class path you - // will need to re-build - // monitor.setTaskName(ResourceHandler.getString("Catalog_Lib_Directory_Remo_UI_") - // + cp[j].getPath()); //$NON-NLS-1$ = "Catalog Lib Directory:Remove " - needsToBeModified = true; - } - } else { - localMonitor.subTask(ProjectSupportResourceHandler.Catalog_Lib_Directory__UI_ + cp[j].getPath()); - //$NON-NLS-1$ = "Catalog Lib Directory:" - newClassPathVector.add(cp[j]); - } - } - localMonitor.worked(1); - localMonitor.subTask(ProjectSupportResourceHandler.Update_ClassPath__UI_); - //$NON-NLS-1$ = "Update ClassPath:" - - // Add any entries not already found - Enumeration aenum = lib_jars.keys(); - while (aenum.hasMoreElements()) { - IPath path = (IPath) aenum.nextElement(); - newClassPathVector.add(JavaCore.newLibraryEntry(path, null, null)); - // You have added something form the class path you - // will need to re-build - // monitor.setTaskName(ResourceHandler.getString("23concat_UI_", (new Object[] { - // path }))); //$NON-NLS-1$ = "Catalog Lib Directory:Add {0}" - needsToBeModified = true; - } - - localMonitor.worked(1); - localMonitor.subTask(ProjectSupportResourceHandler.Set_ClassPath__UI_); - //$NON-NLS-1$ = "Set ClassPath:" - - // Tansfer the vector to an array - IClasspathEntry[] newClassPathArray = new IClasspathEntry[newClassPathVector.size()]; - - for (int j = 0; j < newClassPathArray.length; j++) { - newClassPathArray[j] = (IClasspathEntry) newClassPathVector.get(j); - } - - // Only change the class path if there has been a modification - if (needsToBeModified) { - - try { - javaProject.setRawClasspath(newClassPathArray, localMonitor); - } catch (Exception e) { - Logger.getLogger().log(e); - } - } - - } catch (ClassCastException ex) { - Logger.getLogger().log(ex); - } catch (CoreException ex) { - Logger.getLogger().log(ex); - } finally { - localMonitor.done(); - } - } - - public static void updateContextRoot(IProject project, String contextRoot) { - - } - - - /** - * @param project - * org.eclipse.core.resources.IProject - */ - /** - * Returns a error message that states whether a context root is valid or not returns null if - * context root is fine - * - * @return java.lang.String - * @param contextRoot - * java.lang.String - */ - public static String validateContextRoot(String contextRoot) { - - if (contextRoot == null) - return null; - - String errorMessage = null; - - String name = contextRoot; - if (name.equals("")) { //$NON-NLS-1$ - // this was added because the error message shouldnt be shown initially. It should be - // shown only if context root field is edited to - errorMessage = ProjectSupportResourceHandler.Context_Root_cannot_be_empty_2; - return errorMessage; - } - - /******************************************************************************************* - * // JZ - fix to defect 204264, "/" is valid in context root if (name.indexOf("//") != -1) { - * //$NON-NLS-1$ errorMessage = "// are invalid characters in a resource name"; return - * errorMessage; } - ******************************************************************************************/ - - if (name.trim().equals(name)) { - StringTokenizer stok = new StringTokenizer(name, "."); //$NON-NLS-1$ - outer : while (stok.hasMoreTokens()) { - String token = stok.nextToken(); - for (int i = 0; i < token.length(); i++) { - if (!(token.charAt(i) == '_') && !(token.charAt(i) == '-') && !(token.charAt(i) == '/') && Character.isLetterOrDigit(token.charAt(i)) == false) { - if (Character.isWhitespace(token.charAt(i))) { - // Removed because context roots can contain white space - // errorMessage = - // ResourceHandler.getString("_Context_root_cannot_conta_UI_");//$NON-NLS-1$ - // = " Context root cannot contain whitespaces." - } else { - errorMessage = ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.The_character_is_invalid_in_a_context_root, new Object[]{(new Character(token.charAt(i))).toString()}); - break outer; - } - } - } - } - } // en/ end of if(name.trim - else - errorMessage = ProjectSupportResourceHandler.Names_cannot_begin_or_end_with_whitespace_5; - - return errorMessage; - } - - - /** - * Return true if the string contains any of the characters in the array. - */ - private static boolean contains(String str, char[] chars) { - for (int i = 0; i < chars.length; i++) { - if (str.indexOf(chars[i]) != -1) - return true; - } - return false; - } - - - public static String validateFolderName(String folderName) { - if (folderName.length() == 0) - return ProjectSupportResourceHandler.Folder_name_cannot_be_empty_2; - - if (contains(folderName, BAD_CHARS)) - return ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Folder_name_is_not_valid, new Object[]{folderName}); - - return null; - } - - - public static String validateWebContentName(String webContentName, IProject project, String javaSourceName) { - - String msg = validateFolderName(webContentName); - if (msg != null) - return msg; - - if (javaSourceName != null && webContentName.equals(javaSourceName)) - return ProjectSupportResourceHandler.Folder_names_cannot_be_equal_4; - - // If given a java project, check to make sure current package fragment - // root folders do not overlap with new web content name - if (project != null) { - IJavaProject javaProject = JemProjectUtilities.getJavaProject(project); - if (javaProject != null) { - try { - IPackageFragmentRoot roots[] = javaProject.getPackageFragmentRoots(); - for (int i = 0; i < roots.length; i++) { - IPackageFragmentRoot root = roots[i]; - if (!root.isArchive()) { - IResource resource = root.getCorrespondingResource(); - if (resource.getType() == IResource.FOLDER) { - IPath path = resource.getFullPath(); - String rootFolder = path.segment(1); - if (webContentName.equals(rootFolder)) { - if (root.getKind() == IPackageFragmentRoot.K_SOURCE) - return ProjectSupportResourceHandler.Folder_name_cannot_be_the_same_as_Java_source_folder_5; - - return ProjectSupportResourceHandler.Folder_name_cannot_be_the_same_as_Java_class_folder_6; - } - } - } - } - } catch (JavaModelException e) { - return null; - } - } - } - - return null; - } - - - /** - * Update given web nature to the current version if necessary. - * - * @param webNature - * The web Nature that should be examined. - * @return True if successful, false if unnecessary. - * @throws CoreException - * The exception that occured during the version change operation. - */ - /* - * static public boolean updateNatureToCurrentVersion(J2EEWebNatureRuntime webNature) throws - * CoreException { - * - * boolean success = false; - * - * if (webNature.getVersion() != WEB.CURRENT_VERSION) { - * webNature.setVersion(J2EESettings.CURRENT_VERSION); success = true; } - * ((J2EEModuleWorkbenchURIConverterImpl) - * webNature.getResourceSet().getURIConverter()).recomputeContainersIfNecessary(); - * - * return success; } - */ - - /** - * Move the old source folder to the new default folder. - * - * @param project - * The Web Project we are working with. - * @param oldSourceFolder - * The old "Java Source" folder that will be moved. - * @param javaSourceName - * The new name of the "Java Source" folder, or null for default. - * @return The location of the new folder, or null if no move was necessary. - * @throws CoreException - * The exception that occured during the move operation. - */ - static public IContainer updateJavaSourceName(IProject project, IContainer oldSourceFolder, String javaSourceName, IProgressMonitor progressMonitor) throws CoreException { - IContainer newSourceFolder = null; - if (oldSourceFolder != null) { - IPath newPath; - if (javaSourceName == null) - newPath = new Path(DEFAULT_JAVA_SOURCE_NAME); - else - newPath = new Path(javaSourceName); - - // Make sure new path is different form old path - if (!project.getFolder(newPath).getFullPath().equals(oldSourceFolder.getFullPath())) { - oldSourceFolder.move(newPath, IResource.FORCE | IResource.KEEP_HISTORY, new SubProgressMonitor(progressMonitor, 1)); - JemProjectUtilities.removeFromJavaClassPath(project, oldSourceFolder); - newSourceFolder = project.getFolder(newPath); - JemProjectUtilities.appendJavaClassPath(project, JavaCore.newSourceEntry(project.getFolder(newPath).getFullPath())); - } - } - return newSourceFolder; - } - - - /** - * Get the source folder that should be used for migration. - * - * @param project - * The Web Project to examine. - * @return The source folder to use in migration, or null if it should be skipped. - */ - static public IContainer getJavaSourceFolder(IProject project) { - List sourceRoots = JemProjectUtilities.getSourceContainers(project); - IContainer oldSourceFolder = null; - - if (sourceRoots != null) { - if (sourceRoots.size() == 1) { - IContainer sourceFolder = (IContainer) sourceRoots.get(0); - if (sourceFolder instanceof IFolder) { - oldSourceFolder = sourceFolder; - } - } - } - return oldSourceFolder; - } - - public static IFolder getModuleServerRoot(IProject project) { - // TODO need to implement module server root properly - IPath compRootPath = ComponentCore.createComponent(project).getRootFolder().getUnderlyingFolder().getProjectRelativePath(); - return project.getFolder(compRootPath); - //return project.getFolder("WebContent"); - - } - - public static IVirtualFolder getWebLibFolder(IVirtualComponent webComponent) { - IPath path = new Path(J2EEConstants.WEB_INF + "/" + "lib"); //$NON-NLS-1$//$NON-NLS-2$ - IVirtualFolder libFolder = webComponent.getRootFolder().getFolder(path); - return libFolder; - } - - //TODO delete jsholl - /** - * @deprecated use getWebLibFolder(IVirtualComponent webComponent) - * @param project - * @return - */ - public static IContainer getWebLibFolder(IProject project) { - return getWebLibFolder(ComponentCore.createComponent(project)).getUnderlyingFolder(); - } - - // - // static public boolean isImportedClassesJARFileInLibDir(IResource resource) { - // if (resource == null || !resource.exists()) - // return false; - // return resource.getType() == resource.FILE && - // resource.getName().endsWith(IWebNatureConstants.IMPORTED_CLASSES_SUFFIX) && isZip(resource); - // } - // - // static public boolean isLibDirJARFile(IResource resource) { - // if (resource == null || !resource.exists()) - // return false; - // return resource.getType() == resource.FILE && isZip(resource); - // } - // - // static public boolean isZip(IResource resource) { - // String path = resource.getLocation().toOSString(); - // ZipFile zip = null; - // - // try { - // zip = new ZipFile(path); - // } catch (IOException notAZip) { - // return false; - // } finally { - // if (zip != null) { - // try { - // zip.close(); - // } catch (IOException ex) {} - // } - // } - // return zip != null; - // } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebToolingException.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebToolingException.java deleted file mode 100644 index a073e6514..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebToolingException.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.web.operations; - - - -import java.io.IOException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.xml.sax.SAXException; - - -/** - * The WebToolingException class is the generic class for exceptions generated by the web tooling. - */ -public class WebToolingException extends Exception { - /** - * - */ - private static final long serialVersionUID = 5721765673799055122L; - public static final String SAX_ERROR_MESSAGE = ProjectSupportResourceHandler.Operation_failed_due_to_SA_ERROR_; // = "Operation failed due to SAX error: " - public static final String IO_ERROR_MESSAGE = ProjectSupportResourceHandler.Operation_failed_due_to_IO_ERROR_; // = "Operation failed due to IO error: " - public static final String CORE_ERROR_MESSAGE = ProjectSupportResourceHandler.Operation_failed_due_to_Co_ERROR_; // = "Operation failed due to Core error: " - public static final String JAVA_MODEL_ERROR_MESSAGE = ProjectSupportResourceHandler.Operation_failed_due_to_Ja_ERROR_; // = "Operation failed due to Java Model error: " - - /** - * Create a new WebToolingException with no message. - */ - public WebToolingException() { - super(); - } - - /** - * Create a new instance of the receiver for a supplied IO Exception - * - * @param message - * java.lang.String - */ - public WebToolingException(IOException exception) { - this(IO_ERROR_MESSAGE, exception); - } - - /** - * Create a new WebToolingException with error message of s. - * - * @param s - * java.lang.String - */ - public WebToolingException(String s) { - super(s); - } - - /** - * Create a new instance of the receiver with the supplied preamble and the message of the - * example appended to the end. - * - * @param message - * java.lang.String - */ - public WebToolingException(String preamble, Throwable exception) { - this(preamble + exception.getMessage()); - } - - /** - * Create a new instance of the receiver for a supplied CoreException - * - * @param exception - * CoreException - */ - public WebToolingException(CoreException exception) { - this(CORE_ERROR_MESSAGE, exception); - } - - /** - * Create a new instance of the receiver for a supplied JavaModelException. - * - * @param exception - * JavaModelException - */ - public WebToolingException(JavaModelException exception) { - this(JAVA_MODEL_ERROR_MESSAGE, exception); - } - - /** - * Create a new instance of the receiver for a supplied SAX Exception - * - * @param exception - * SAXException - */ - public WebToolingException(SAXException exception) { - this(SAX_ERROR_MESSAGE, exception); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebToolingTemplate.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebToolingTemplate.java deleted file mode 100644 index 7c9f60725..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/operations/WebToolingTemplate.java +++ /dev/null @@ -1,19 +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.web.operations; - -public interface WebToolingTemplate { - /** - * Insert the method's description here. Creation date: (12/6/2000 7:35:38 PM) - * - * @param data - * TemplateData - */ - public String generate(TemplateData data); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/util/WebArtifactEditUtilities.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/util/WebArtifactEditUtilities.java deleted file mode 100644 index be022f87c..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/util/WebArtifactEditUtilities.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.web.util; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class WebArtifactEditUtilities { - - public static IVirtualComponent getWebComponent(Servlet servlet) { - IProject project = ProjectUtilities.getProject(servlet); - IVirtualComponent component = ComponentCore.createComponent(project); - WebArtifactEdit edit = null; - try { - if (J2EEProjectUtilities.isDynamicWebProject(project)) { - edit = WebArtifactEdit.getWebArtifactEditForRead(component); - WebApp webapp = edit.getWebApp(); - if (webapp.getServletNamed(servlet.getServletName()) != null) - return component; - } - } finally { - if (edit != null) - edit.dispose(); - } - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/util/WebEditAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/util/WebEditAdapterFactory.java deleted file mode 100644 index d954a9ce8..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/internal/web/util/WebEditAdapterFactory.java +++ /dev/null @@ -1,51 +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.web.util; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; - - -/** - * <p> - * Adapts {@see org.eclipse.wst.common.modulecore.ArtifactEditModel}s to - * {@see org.eclipse.jst.j2ee.internal.web.util.WebArtifactEdit} facades. - * </p> - */ -public class WebEditAdapterFactory implements IAdapterFactory { - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adapterType == WebArtifactEdit.ADAPTER_TYPE || adapterType == ArtifactEdit.ADAPTER_TYPE) { - ArtifactEditModel editModel = (ArtifactEditModel) adaptableObject; - if (J2EEProjectUtilities.isDynamicWebProject(editModel.getProject())) - return new WebArtifactEdit((ArtifactEditModel) adaptableObject); - } - return null; - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - return new Class[]{ArtifactEdit.class, WebArtifactEdit.class}; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/componentcore/util/WebArtifactEdit.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/componentcore/util/WebArtifactEdit.java deleted file mode 100644 index 15aeaef17..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/componentcore/util/WebArtifactEdit.java +++ /dev/null @@ -1,707 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.componentcore.util; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory; -import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions; -import org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.common.XMLResource; -import org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentLoadStrategyImpl; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.project.WebUtilities; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webapplication.WebAppResource; -import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory; -import org.eclipse.jst.j2ee.webapplication.WelcomeFile; -import org.eclipse.jst.j2ee.webapplication.WelcomeFileList; -import org.eclipse.wst.common.componentcore.ArtifactEdit; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.componentcore.internal.BinaryComponentHelper; -import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.util.IArtifactEditFactory; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; - - - -/** - * <p> - * WebArtifactEdit obtains a Web Deployment Descriptor metamodel specifec data from a - * {@see org.eclipse.jst.j2ee.webapplication.WebAppResource} which stores the metamodel. The - * {@see org.eclipse.jst.j2ee.webapplication.WebAppResource} is retrieved from the - * {@see org.eclipse.wst.common.modulecore.ArtifactEditModel} using a constant {@see - * J2EEConstants#WEBAPP_DD_URI_OBJ}. The defined methods extract data or manipulate the contents of - * the underlying resource. - * </p> - * - */ -public class WebArtifactEdit extends EnterpriseArtifactEdit implements IArtifactEditFactory { - - private static final String WEB_CONTENT_TYPE = "org.eclipse.jst.j2ee.webDD"; //$NON-NLS-1$ - /** - * <p> - * Identifier used to link WebArtifactEdit to a WebEditAdapterFactory {@see - * WebEditAdapterFactory} stored in an AdapterManger (@see AdapterManager) - * </p> - */ - public static final Class ADAPTER_TYPE = WebArtifactEdit.class; - public static final String WEB_CONTENT = "WebContent"; //$NON-NLS-1$ - public static final String WEB_INF = "WEB-INF"; //$NON-NLS-1$ - public static final String META_INF = "META-INF"; //$NON-NLS-1$ - - public static IPath WEBLIB = new Path("/WEB-INF/lib"); //$NON-NLS-1$ - - /** - * - */ - public WebArtifactEdit() { - super(); - } - - public WebArtifactEdit(IVirtualComponent aModule) { - super(aModule); - } - - @Override - protected BinaryComponentHelper initBinaryComponentHelper(IVirtualComponent binaryModule) { - return new JavaEEBinaryComponentHelper(binaryModule); - } - - /** - * @param aHandle - * @param toAccessAsReadOnly - * @throws IllegalArgumentException - */ - public WebArtifactEdit(IProject aProject, boolean toAccessAsReadOnly) throws IllegalArgumentException { - super(aProject, toAccessAsReadOnly); - } - - /** - * @param aHandle - * @param toAccessAsReadOnly - * @throws IllegalArgumentException - */ - public WebArtifactEdit(IProject aProject, boolean toAccessAsReadOnly, boolean forCreate) throws IllegalArgumentException { - super(aProject, toAccessAsReadOnly, forCreate, J2EEProjectUtilities.DYNAMIC_WEB); - } - - /** - * @param aHandle - * @param toAccessAsReadOnly - * @throws IllegalArgumentException - */ - protected WebArtifactEdit(IProject aProject, boolean toAccessAsReadOnly, boolean forCreate, String editModelID) throws IllegalArgumentException { - super(aProject, toAccessAsReadOnly, forCreate, editModelID); - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of ArtifactEdit that are returned through this method - * must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an ArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will not be used for editing. Invocations of any save*() API on an instance returned from - * this method will throw exceptions. - * </p> - * <p> - * <b>The following method may return null. </b> - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of ArtifactEdit that may only be used to read the underlying content - * model - */ - public static WebArtifactEdit getWebArtifactEditForRead(IProject aProject) { - WebArtifactEdit artifactEdit = null; - try { - if (isValidWebModule(ComponentCore.createComponent(aProject))) - artifactEdit = new WebArtifactEdit(aProject, true, false); - } catch (Exception e) { - artifactEdit = null; - } - return artifactEdit; - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of ArtifactEdit that are returned through this method - * must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an ArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will be used for editing. - * </p> - * <p> - * <b>The following method may return null. </b> - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of ArtifactEdit that may be used to modify and persist changes to the - * underlying content model - */ - public static WebArtifactEdit getWebArtifactEditForWrite(IProject aProject) { - WebArtifactEdit artifactEdit = null; - try { - if (isValidWebModule(ComponentCore.createComponent(aProject))) - artifactEdit = new WebArtifactEdit(aProject, false, false); - } catch (Exception e) { - artifactEdit = null; - } - return artifactEdit; - } - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of WebArtifactEdit that are returned through this - * method must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an WebArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will not be used for editing. Invocations of any save*() API on an instance returned from - * this method will throw exceptions. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * - * <p> - * Note: This method is for internal use only. Clients should not call this method. - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of WebArtifactEdit that may only be used to read the underlying content - * model - * @throws UnresolveableURIException - * could not resolve uri. - */ - public static WebArtifactEdit getWebArtifactEditForRead(IVirtualComponent aModule) { - if (aModule == null) - return null; - if (aModule.isBinary()) { - return new WebArtifactEdit(aModule); - } - - return getWebArtifactEditForRead(aModule.getProject()); - } - - - /** - * <p> - * Returns an instance facade to manage the underlying edit model for the given - * {@see WorkbenchComponent}. Instances of WebArtifactEdit that are returned through this - * method must be {@see #dispose()}ed of when no longer in use. - * </p> - * <p> - * Use to acquire an WebArtifactEdit facade for a specific {@see WorkbenchComponent} that - * will be used for editing. - * </p> - * <p> - * <b>This method may return null. </b> - * </p> - * - * <p> - * Note: This method is for internal use only. Clients should not call this method. - * </p> - * - * @param aModule - * A valid {@see WorkbenchComponent} with a handle that resolves to an - * accessible project in the workspace - * @return An instance of WebArtifactEdit that may be used to modify and persist changes to the - * underlying content model - */ - public static WebArtifactEdit getWebArtifactEditForWrite(IVirtualComponent aModule) { - if (aModule == null || aModule.isBinary()) - return null; - return getWebArtifactEditForWrite(aModule.getProject()); - } - - /** - * @param module - * A {@see WorkbenchComponent} - * @return True if the supplied module - * {@see ArtifactEdit#isValidEditableModule(WorkbenchComponent)}and the moduleTypeId is - * a JST module - */ - public static boolean isValidWebModule(IVirtualComponent aModule) throws UnresolveableURIException { - if (!isValidEditableModule(aModule)) - return false; - return J2EEProjectUtilities.isDynamicWebProject(aModule.getProject()); - } - - /** - * <p> - * Creates an instance facade for the given {@see ArtifactEditModel}. - * </p> - * - * @param anArtifactEditModel - */ - public WebArtifactEdit(ArtifactEditModel model) { - super(model); - - } - - /** - * <p> - * Creates an instance facade for the given {@see ArtifactEditModel} - * </p> - * - * <p> - * Note: This method is for internal use only. Clients should not call this method. - * </p> - * - * @param aNature - * A non-null {@see ModuleCoreNature}for an accessible project - * @param aModule - * A non-null {@see WorkbenchComponent}pointing to a module from the given - * {@see ModuleCoreNature} - */ - protected WebArtifactEdit(ModuleCoreNature aNature, IVirtualComponent aModule, boolean toAccessAsReadOnly) { - super(aNature, aModule, toAccessAsReadOnly); - } - - - - /** - * <p> - * Retrieves J2EE version information from WebAppResource. - * </p> - * - * @return an integer representation of a J2EE Spec version - * - */ - @Override - public int getJ2EEVersion() { - verifyOperationSupported(); - return ((WebAppResource) getDeploymentDescriptorResource()).getJ2EEVersionID(); - } - - /** - * <p> - * Obtains the WebApp (@see WebApp) root object from the WebAppResource. If the root object does - * not exist, then one is created (@link addWebAppIfNecessary(getWebApplicationXmiResource())). - * The root object contains all other resource defined objects. - * </p> - * - * @return EObject - * - */ - @Override - public EObject getDeploymentDescriptorRoot() { - verifyOperationSupported(); - List contents = getDeploymentDescriptorResource().getContents(); - if (contents.size() > 0) - return (EObject) contents.get(0); - if (isBinary()) { - return null; - } - addWebAppIfNecessary((WebAppResource) getDeploymentDescriptorResource()); - return (EObject) contents.get(0); - } - - /** - * <p> - * Retrieves the underlying resource from the ArtifactEditModel using defined URI. - * </p> - * - * @return Resource - * - */ - @Override - public Resource getDeploymentDescriptorResource() { - verifyOperationSupported(); - if (isBinary()) { - return getBinaryComponentHelper().getResource(J2EEConstants.WEBAPP_DD_URI_OBJ); - } - return getArtifactEditModel().getResource(J2EEConstants.WEBAPP_DD_URI_OBJ); - } - - /** - * <p> - * Retrieves Servlet version information derived from the {@see WebAppResource}. - * </p> - * - * @return an integer representation of a module version - * - */ - public int getServletVersion() { - verifyOperationSupported(); - return ((WebAppResource) getDeploymentDescriptorResource()).getModuleVersionID(); - } - - /** - * This method returns the integer representation for the JSP specification level associated - * with the J2EE version for this workbench module. This method will not return null and returns - * 20 as default. - * - * @see WebArtifactEdit#getServletVersion() - * - * @return an integer representation of the JSP level - */ - public int getJSPVersion() { - verifyOperationSupported(); - int servletVersion = getServletVersion(); - if (servletVersion == J2EEVersionConstants.WEB_2_2_ID) - return J2EEVersionConstants.JSP_1_1_ID; - else if (servletVersion == J2EEVersionConstants.WEB_2_3_ID) - return J2EEVersionConstants.JSP_1_2_ID; - else - return J2EEVersionConstants.JSP_2_0_ID; - } - - /** - * <p> - * Creates a deployment descriptor root object (WebApp) and populates with data. Adds the root - * object to the deployment descriptor resource. - * </p> - * - * <p> - * - * @param aModule - * A non-null pointing to a {@see XMLResource} - * @param version - * Version to be set on resource....if null default is taken - * - * Note: This method is typically used for JUNIT - move? - * </p> - */ - protected void addWebAppIfNecessary(XMLResource aResource) { - verifyOperationSupported(); - if (isBinary()) { - throwAttemptedBinaryEditModelAccess(); - } - if (aResource != null) { - if (aResource.getContents() == null || aResource.getContents().isEmpty()) { - WebApp webAppNew = WebapplicationFactory.eINSTANCE.createWebApp(); - aResource.getContents().add(webAppNew); - aResource.setModified(true); - } - WebApp webApp = (WebApp) aResource.getContents().get(0); - URI moduleURI = getArtifactEditModel().getModuleURI(); - try { - webApp.setDisplayName(StructureEdit.getDeployedName(moduleURI)); - } catch (UnresolveableURIException e) { - // Ignore - } - aResource.setID(webApp, J2EEConstants.WEBAPP_ID); - - WelcomeFileList wList = WebapplicationFactory.eINSTANCE.createWelcomeFileList(); - List files = wList.getFile(); - WelcomeFile file = WebapplicationFactory.eINSTANCE.createWelcomeFile(); - file.setWelcomeFile("index.html"); //$NON-NLS-1$ - files.add(file); - file = WebapplicationFactory.eINSTANCE.createWelcomeFile(); - file.setWelcomeFile("index.htm"); //$NON-NLS-1$ - files.add(file); - file = WebapplicationFactory.eINSTANCE.createWelcomeFile(); - file.setWelcomeFile("index.jsp"); //$NON-NLS-1$ - files.add(file); - file = WebapplicationFactory.eINSTANCE.createWelcomeFile(); - file.setWelcomeFile("default.html"); //$NON-NLS-1$ - files.add(file); - file = WebapplicationFactory.eINSTANCE.createWelcomeFile(); - file.setWelcomeFile("default.htm"); //$NON-NLS-1$ - files.add(file); - file = WebapplicationFactory.eINSTANCE.createWelcomeFile(); - file.setWelcomeFile("default.jsp"); //$NON-NLS-1$ - files.add(file); - - webApp.setFileList(wList); - - try { - aResource.saveIfNecessary(); - } catch (java.net.ConnectException ex) { - - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - - /** - * This method returns the full path to the deployment descriptor resource for the associated - * workbench module. This method may return null. - * - * @see WebArtifactEdit#getDeploymentDescriptorResource() - * - * @return the full IPath for the deployment descriptor resource - */ - public IPath getDeploymentDescriptorPath() { - verifyOperationSupported(); - IFile file = WorkbenchResourceHelper.getFile(getDeploymentDescriptorResource()); - if (file != null) - return file.getFullPath(); - return null; - } - - /** - * This method will retrieve the web app resource, create it if necessary, add get the root - * object, the web app out of that web app resource. It will create the web app instance if need - * be, and add it to the web resource. Then, it returns the web app object as the model root. - * This method will not return null. - * - * @see EnterpriseArtifactEdit#createModelRoot() - * - * @return the eObject instance of the model root - */ - @Override - public EObject createModelRoot() { - verifyOperationSupported(); - if (isBinary()) { - throwAttemptedBinaryEditModelAccess(); - } - return createModelRoot(getJ2EEVersion()); - } - - /** - * This method will retrieve the web app resource, create it if necessary, add get the root - * object, set version the web app out of that web app resource. It will create the web app - * instance if need be, and add it to the web resource. Then, it returns the web app object as - * the model root. This method will not return null. - * - * @see EnterpriseArtifactEdit#createModelRoot() - * - * @return the eObject instance of the model root - */ - @Override - public EObject createModelRoot(int version) { - verifyOperationSupported(); - if (isBinary()) { - throwAttemptedBinaryEditModelAccess(); - } - WebAppResource res = (WebAppResource) getDeploymentDescriptorResource(); - res.setModuleVersionID(version); - addWebAppIfNecessary(res); - return res.getRootObject(); - } - - /** - * @deprecated - * use {@link WebUtilities}{@link #getLibModules()} - */ - public IVirtualReference[] getLibModules() { - return WebUtilities.getLibModules(getProject()); - } - - /** - * This method will add the dependent modules from the passed in array to the dependentmodules - * list of the associated workbench module. It will ensure a null is not passed and it will - * ensure the dependent modules are not already in the list. - * - * <p> - * Note: This method is for internal use only. Clients should not call this method. - * </p> - * - * @param libModules - * array of dependent modules to add as web libraries - */ - public void addLibModules(ReferencedComponent[] libModules) { - // TODO - Need to implement - // if (libModules==null) - // return; - // for (int i=0; i<libModules.length; i++) { - // if (!module.getReferencedComponents().contains(libModules[i])) - // module.getReferencedComponents().add(libModules[i]); - // } - } - - /** - * This method will retrieve the context root for this web project's .component file. It is - * meant to handle a standalone web case. - * - * @return contextRoot String - */ - public String getServerContextRoot() { - return J2EEProjectUtilities.getServerContextRoot(getProject()); - } - - /** - * This method will retrieve the context root for this web project in the associated parameter's - * application.xml. If the earProject is null, then the contextRoot from the .component of the - * web project is returned. - * - * @param earProject - * @return contextRoot String - */ - public String getServerContextRoot(IProject earProject) { - if (earProject == null || !J2EEProjectUtilities.isEARProject(earProject)) - return getServerContextRoot(); - EARArtifactEdit earEdit = null; - String contextRoot = null; - try { - earEdit = EARArtifactEdit.getEARArtifactEditForRead(earProject); - if (earEdit != null) - contextRoot = earEdit.getWebContextRoot(getProject()); - } finally { - if (earEdit != null) - earEdit.dispose(); - } - return contextRoot; - } - - /** - * This method will update the context root for this web project on the EAR which is passed in. - * If no EAR is passed the .component file for the web project will be updated. - * - * @param earProject - * @param aContextRoot - */ - public void setServerContextRoot(IProject earProject, String aContextRoot) { - if (earProject == null || !J2EEProjectUtilities.isEARProject(earProject)) - setServerContextRoot(aContextRoot); - EARArtifactEdit earEdit = null; - try { - earEdit = EARArtifactEdit.getEARArtifactEditForWrite(earProject); - if (earEdit != null) - earEdit.setWebContextRoot(getProject(), aContextRoot); - } finally { - if (earEdit != null) { - earEdit.saveIfNecessary(new NullProgressMonitor()); - earEdit.dispose(); - } - } - } - - /** - * This method sets the context root property on the web project's .component file for the - * standalone case. - * - * @param contextRoot - * string - */ - public void setServerContextRoot(String contextRoot) { - J2EEProjectUtilities.setServerContextRoot(getProject(), contextRoot); - } - - - /** - * @return WebApp - */ - public WebApp getWebApp() { - verifyOperationSupported(); - - return (WebApp) getDeploymentDescriptorRoot(); - } - - - public ArtifactEdit createArtifactEditForRead(IVirtualComponent aComponent) { - return getWebArtifactEditForRead(aComponent); - } - - - public ArtifactEdit createArtifactEditForWrite(IVirtualComponent aComponent) { - return getWebArtifactEditForWrite(aComponent); - } - - @Override - public Archive asArchive(boolean includeSource, boolean includeClasspathComponents) throws OpenFailureException { - return asArchive(includeSource, includeClasspathComponents, false); - } - public Archive asArchive(boolean includeSource, boolean includeClasspathComponents, boolean readOnly) throws OpenFailureException { - verifyOperationSupported(); - if (isBinary()) { - JavaEEBinaryComponentHelper helper = (JavaEEBinaryComponentHelper)getBinaryComponentHelper(); - return helper.accessLegacyArchive(); - } - WebComponentLoadStrategyImpl loader = new WebComponentLoadStrategyImpl(getComponent(), includeClasspathComponents); - loader.setExportSource(includeSource); - loader.setReadOnly(readOnly); - String uri = ModuleURIUtil.getHandleString(getComponent()); - ArchiveOptions options = new ArchiveOptions(); - options.setLoadStrategy(loader); - options.setIsReadOnly(readOnly); - return CommonarchiveFactory.eINSTANCE.openWARFile(options, uri); - } - - public static void createDeploymentDescriptor(IProject project, int version) { - WebArtifactEdit webEdit = new WebArtifactEdit(project, false, true); - try { - webEdit.createModelRoot(version); - webEdit.save(null); - } finally { // Make sure new resource is removed - the uri used for creation shouldn't be cached - Resource newRes = webEdit.getDeploymentDescriptorResource(); - WorkbenchResourceHelperBase.getResourceSet(project).getResources().remove(newRes); - newRes.unload(); - webEdit.dispose(); - } - } - @Override - public IModelProvider create(IProject project) { - return getWebArtifactEditForRead(project); - } - - @Override - public IModelProvider create(IVirtualComponent component) { - return getWebArtifactEditForRead(component); - } - - @Override - public void modify(Runnable runnable, IPath modelPath) { - setWritableEdit(getWebArtifactEditForWrite(getProject())); - try{ - runnable.run(); - if( getWritableEdit() != null ){ - // Always save regardless of resource path passed - Artifactedits save resources as a unit - getWritableEdit().saveIfNecessary( new NullProgressMonitor() ); - } - - }finally{ - getWritableEdit().dispose(); - setWritableEdit(null); - } - } - - - @Override - protected String getContentTypeDescriber() { - return WEB_CONTENT_TYPE; - } - @Override - protected URI getRootURI() { - return J2EEConstants.WEBAPP_DD_URI_OBJ; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/componentcore/util/package.xml b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/componentcore/util/package.xml deleted file mode 100644 index 6a17c4ece..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/componentcore/util/package.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../../../" /> - <title>WebArtifactEdit api overview</title> - </head> - - <body> - <abstract> - This package includes the WebArtifactEdit api. This api is used to work with the emf model - of a flexible web module. It contains api to read and serialize out the emf model for web applications. - </abstract> - - <a href="#top">top</a> - </body> -</html> -
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IConvertStaticWebToDyamnicDataModelProperties.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IConvertStaticWebToDyamnicDataModelProperties.java deleted file mode 100644 index ccfad90c8..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IConvertStaticWebToDyamnicDataModelProperties.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.web.datamodel.properties; - -import org.eclipse.jst.j2ee.internal.web.operations.ConvertStaticWebToDyamnicDataModelProvider; - -public interface IConvertStaticWebToDyamnicDataModelProperties { - - /** - * This field should not be used. It is not part of the API and may be modified in the future. - */ - public static Class _provider_class = ConvertStaticWebToDyamnicDataModelProvider.class; - - public static final String PROJECT = "IConvertStaticWebToDyamnicProperties.PROJECT"; //$NON-NLS-1$ - public static final String CONVERT_TO_WEB_VERSION = "IConvertStaticWebToDyamnicProperties.CONVERT_TO_WEB_VERSION"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IWebComponentExportDataModelProperties.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IWebComponentExportDataModelProperties.java deleted file mode 100644 index 129150da3..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IWebComponentExportDataModelProperties.java +++ /dev/null @@ -1,37 +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.web.datamodel.properties; - -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties; -/** - * <p> - * IWebComponentExportDataModelProperties provides properties to the IDataModel associated with the - * WebComponentExportDataModelProvider. - * NOTE: The associated Provider and Operations will be created during M5 - * </p> - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider - * @see org.eclipse.wst.common.frameworks.datamodel.DataModelFactory - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties - * - * @plannedfor 1.0 - */ -public interface IWebComponentExportDataModelProperties extends IJ2EEComponentExportDataModelProperties { - /** - * Required, type Boolean flag which indicates whether or not to export compiled JSP files - * (compiled files exist in /WEB-INF/classes as .class and .java[for debug]) - */ - public static final String EXCLUDE_COMPILE_JSP = "WebExportDataModel.EXCLUDE_COMPILE_JSP"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IWebComponentImportDataModelProperties.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IWebComponentImportDataModelProperties.java deleted file mode 100644 index 7a8697f63..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/IWebComponentImportDataModelProperties.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.web.datamodel.properties; - -import java.util.List; - -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEModuleImportDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * <p> - * IWebComponentImportDataModelProperties provides properties to the IDataModel associated with the - * WebComponentImportDataModelProvider. NOTE: The associated Provider and Operations will be created - * during M5 - * </p> - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider - * @see org.eclipse.wst.common.frameworks.datamodel.DataModelFactory - * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties - * - * @plannedfor 1.0 - */ -public interface IWebComponentImportDataModelProperties extends IJ2EEModuleImportDataModelProperties { - - /** - * <p> - * This optional {@link List} property is used to specify which nested web libraries should be - * expanded into projects during import. The contents of this {@link List} property should be - * {@link Archive}s. - * </p> - */ - public static final String WEB_LIB_ARCHIVES_SELECTED = "WARImportDataModel.WEB_LIB_ARCHIVES_SELECTED"; //$NON-NLS-1$ - - /** - * <p> - * This {@link List} property should not be set by clients. This list contains the - * {@link IDataModel}s for creating the new components to be created for each of the selected - * archives. This list will contain one entry for each web lib archive regardless of whether it - * is selected for import by the {@link #WEB_LIB_ARCHIVES_SELECTED} property. - * </p> - */ - public static final String WEB_LIB_MODELS = "WARImportDataModel.WEB_LIB_MODELS"; //$NON-NLS-1$ - - public static final String CONTEXT_ROOT = "IAddWebComponentToEnterpriseApplicationDataModelProperties.CONTEXT_ROOT"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/package.xml b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/package.xml deleted file mode 100644 index bc7e674b8..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/datamodel/properties/package.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> - <head> - <meta - name="root" - content="../../../../../../../" /> - <title>web module data model api overview</title> - </head> - - <body> - <abstract> - This package includes the api to create, import and export web modules. The interfaces in this package - define the properties that can be set on the web modules data models that are use to run the data model operations and drive the wizard data, validation. - </abstract> - - <a href="#top">top</a> - </body> -</html> -
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/IWebFacetInstallDataModelProperties.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/IWebFacetInstallDataModelProperties.java deleted file mode 100644 index 21c44e6b7..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/IWebFacetInstallDataModelProperties.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.project.facet; - -import org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; - -public interface IWebFacetInstallDataModelProperties extends IJ2EEModuleFacetInstallDataModelProperties { - - /** - * This field should not be used. It is not part of the API and may be modified in the future. - */ - public static Class _provider_class = WebFacetProjectCreationDataModelProvider.class; - - public static final String CONTEXT_ROOT = "IWebFacetInstallDataModelProperties.CONTEXT_ROOT"; //$NON-NLS-1$ - - public static final String SOURCE_FOLDER = "IWebFacetInstallDataModelProperties.SOURCE_FOLDER"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java deleted file mode 100644 index f7237142b..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.web.project.facet; - -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.ChangeEvent; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.eclipse.jst.j2ee.project.facet.J2EEModuleFacetInstallDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.project.facet.ProductManager; - -import com.ibm.icu.util.StringTokenizer; - -public class WebFacetInstallDataModelProvider extends J2EEModuleFacetInstallDataModelProvider implements IWebFacetInstallDataModelProperties { - - @Override - protected void handleJavaFacetSourceFoldersChanged( final ChangeEvent event ) - { - final List<IPath> sourceFolders = event.getJavaFacetInstallConfig().getSourceFolders(); - final String sourceFolder = ( sourceFolders.isEmpty() ? null : sourceFolders.get( 0 ).toPortableString() ); - getDataModel().setProperty( SOURCE_FOLDER, sourceFolder ); - } - - @Override - public Set getPropertyNames() { - Set names = super.getPropertyNames(); - names.add(CONTEXT_ROOT); - names.add(SOURCE_FOLDER); - return names; - } - - @Override - public Object getDefaultProperty(String propertyName) { - if (propertyName.equals(CONFIG_FOLDER)) { - return J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.WEB_CONTENT_FOLDER); - } else if (propertyName.equals(SOURCE_FOLDER)) { - if( this.javaFacetInstallConfig != null ) - { - final List<IPath> sourceFolders = this.javaFacetInstallConfig.getSourceFolders(); - return ( sourceFolders.isEmpty() ? null : sourceFolders.get( 0 ).toPortableString() ); - } - return null; - } else if (propertyName.equals(CONTEXT_ROOT)) { - return getStringProperty(FACET_PROJECT_NAME).replace(' ', '_'); - } else if (propertyName.equals(FACET_ID)) { - return DYNAMIC_WEB; - } else if (propertyName.equals(MODULE_URI)) { - String projectName = model.getStringProperty(FACET_PROJECT_NAME).replace(' ', '_'); - return projectName + IJ2EEModuleConstants.WAR_EXT; - } else if (propertyName.equals(GENERATE_DD)) { - IProjectFacetVersion facetVersion = (IProjectFacetVersion)getProperty(FACET_VERSION); - if(facetVersion == WebFacetUtils.WEB_25){ - return Boolean.valueOf(J2EEPlugin.getDefault().getJ2EEPreferences().getBoolean(J2EEPreferences.Keys.DYNAMIC_WEB_GENERATE_DD)); - } - return Boolean.TRUE; - } - return super.getDefaultProperty(propertyName); - } - - @Override - public boolean propertySet(String propertyName, Object propertyValue) { - if (ADD_TO_EAR.equals(propertyName)) { - model.notifyPropertyChange(CONTEXT_ROOT, IDataModel.ENABLE_CHG); - } else if (FACET_PROJECT_NAME.equals(propertyName)) { - model.notifyPropertyChange(CONTEXT_ROOT, IDataModel.VALID_VALUES_CHG); - } else if (propertyName.equals(CONFIG_FOLDER)) { - // If using optimized single root structure, update the output folder based on content folder change - // The output folder will be "<contentRoot>/WEB-INF/classes" - if (ProductManager.shouldUseSingleRootStructure()) - { - if( this.javaFacetInstallConfig != null ) - { - final IPath outputFolder - = propertyValue == null ? null : new Path( (String) propertyValue + "/" +J2EEConstants.WEB_INF_CLASSES ); //$NON-NLS-1$ - - this.javaFacetInstallConfig.setDefaultOutputFolder( outputFolder ); - } - } - return true; - } else if (propertyName.equals(SOURCE_FOLDER)) - { - if( this.javaFacetInstallConfig != null ) - { - final IPath sourceFolder - = propertyValue == null ? null : new Path( (String) propertyValue ); - - this.javaFacetInstallConfig.setSourceFolder( sourceFolder ); - } - } - - return super.propertySet(propertyName, propertyValue); - } - - @Override - public boolean isPropertyEnabled(String propertyName) { - return super.isPropertyEnabled(propertyName); - } - - @Override - protected int convertFacetVersionToJ2EEVersion(IProjectFacetVersion version) { - return J2EEVersionUtil.convertWebVersionStringToJ2EEVersionID(version.getVersionString()); - } - - @Override - public IStatus validate(String name) { - if (name.equals(CONTEXT_ROOT)) { - return validateContextRoot(getStringProperty(CONTEXT_ROOT)); - } else if (name.equals(SOURCE_FOLDER)) { - return validateFolderName(getStringProperty(SOURCE_FOLDER)); - } - // the superclass validates the content directory which is actually a "CONFIG_FOLDER" - return super.validate(name); - } - - protected IStatus validateContextRoot(String contextRoot) { - if (contextRoot == null) { - return J2EEPlugin.newErrorStatus(ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Context_Root_cannot_be_empty_2, new Object[]{contextRoot}), null); - } else if (contextRoot.trim().equals(contextRoot)) { - StringTokenizer stok = new StringTokenizer(contextRoot, "."); //$NON-NLS-1$ - while (stok.hasMoreTokens()) { - String token = stok.nextToken(); - for (int i = 0; i < token.length(); i++) { - if (!(token.charAt(i) == '_') && !(token.charAt(i) == '-') && !(token.charAt(i) == '/') && Character.isLetterOrDigit(token.charAt(i)) == false) { - Object[] invalidChar = new Object[]{(new Character(token.charAt(i))).toString()}; - String errorStatus = ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.The_character_is_invalid_in_a_context_root, invalidChar); - return J2EEPlugin.newErrorStatus(errorStatus, null); - } - } - } - } else - return J2EEPlugin.newErrorStatus(ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.Names_cannot_begin_or_end_with_whitespace_5, new Object[]{contextRoot}), null); - return OK_STATUS; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDelegate.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDelegate.java deleted file mode 100644 index 8ca241600..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDelegate.java +++ /dev/null @@ -1,341 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.web.project.facet; - -import java.io.ByteArrayInputStream; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -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.IProject; -import org.eclipse.core.resources.IWorkspace; -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.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.logger.proxy.Logger; -import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; -import org.eclipse.jst.common.project.facet.WtpUtils; -import org.eclipse.jst.common.project.facet.core.ClasspathHelper; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.web.classpath.WebAppLibrariesContainer; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.J2EEFacetInstallDelegate; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.FacetDataModelProvider; -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.datamodel.IDataModelOperation; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.project.facet.ProductManager; - -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainer; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainerUtils; -import org.eclipse.jst.javaee.core.DisplayName; -import org.eclipse.jst.javaee.core.JavaeeFactory; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.javaee.web.WebFactory; -import org.eclipse.jst.javaee.web.WelcomeFileList; - -public final class WebFacetInstallDelegate extends J2EEFacetInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, final Object cfg, final IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - final IDataModel model = (IDataModel) cfg; - - final IJavaProject jproj = JavaCore.create(project); - - // Add WTP natures. - - WtpUtils.addNatures(project); - - // Create the directory structure. - - final IWorkspace ws = ResourcesPlugin.getWorkspace(); - final IPath pjpath = project.getFullPath(); - - final IPath contentdir = setContentPropertyIfNeeded(model, pjpath, project); - mkdirs(ws.getRoot().getFolder(contentdir)); - - final IPath webinf = contentdir.append("WEB-INF"); //$NON-NLS-1$ - IFolder webinfFolder = ws.getRoot().getFolder(webinf); - mkdirs(webinfFolder); - - final IPath webinflib = webinf.append("lib"); //$NON-NLS-1$ - mkdirs(ws.getRoot().getFolder(webinflib)); - - // Setup the flexible project structure. - - final IVirtualComponent c = ComponentCore.createComponent(project, false); - - c.create(0, null); - - String contextRoot = model.getStringProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT); - setContextRootPropertyIfNeeded(c, contextRoot); - setJavaOutputPropertyIfNeeded(model,c); - - final IVirtualFolder webroot = c.getRootFolder(); - if (webroot.getProjectRelativePath().equals(new Path("/"))) //$NON-NLS-1$ - webroot.createLink(new Path("/" + model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER)), 0, null); //$NON-NLS-1$ - - if( fv == WebFacetUtils.WEB_25 ) - { - if(model.getBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD)){ - createWeb25DeploymentDescriptor(project, fv, webinfFolder, monitor); - } - } - else - { - // Create the deployment descriptor (web.xml) if one doesn't exist - if (!webinfFolder.getFile("web.xml").exists()) { //$NON-NLS-1$ - String ver = fv.getVersionString(); - int nVer = J2EEVersionUtil.convertVersionStringToInt(ver); - WebArtifactEdit.createDeploymentDescriptor(project, nVer); - } - } - - // Set entries for src folders - final IVirtualFolder jsrc = c.getRootFolder().getFolder("/WEB-INF/classes"); //$NON-NLS-1$ - final IClasspathEntry[] cp = jproj.getRawClasspath(); - for (int i = 0; i < cp.length; i++) { - final IClasspathEntry cpe = cp[i]; - if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) { - if( cpe.getPath().removeFirstSegments(1).segmentCount() > 0 ) - jsrc.createLink(cpe.getPath().removeFirstSegments(1), 0, null); - } - } - - IVirtualFile vf = c.getRootFolder().getFile(new Path(J2EEConstants.MANIFEST_URI)); - IFile manifestmf = vf.getUnderlyingFile(); - if (manifestmf == null || !manifestmf.exists()) { - try { - createManifest(project, c.getRootFolder().getUnderlyingFolder(), monitor); - } catch (InvocationTargetException e) { - Logger.getLogger().logError(e); - } catch (InterruptedException e) { - Logger.getLogger().logError(e); - } - } - - // Setup the classpath. - - ClasspathHelper.removeClasspathEntries(project, fv); - - if (!ClasspathHelper.addClasspathEntries(project, fv)) { - // TODO: Support the no runtime case. - // ClasspathHelper.addClasspathEntries( project, fv, <something> ); - } - - // Add the web libraries container. - - - if(J2EEComponentClasspathContainerUtils.getDefaultUseWebAppLibraries()){ - final IPath webLibContainer = new Path(WebAppLibrariesContainer.CONTAINER_ID); - addToClasspath(jproj, JavaCore.newContainerEntry(webLibContainer)); - } - - if(J2EEComponentClasspathContainerUtils.getDefaultUseEARLibraries()){ - final IPath earLibContainer = new Path(J2EEComponentClasspathContainer.CONTAINER_ID); - addToClasspath(jproj, JavaCore.newContainerEntry(earLibContainer)); - } - - try { - ((IDataModelOperation) model.getProperty(FacetDataModelProvider.NOTIFICATION_OPERATION)).execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().logError(e); - } - - if (monitor != null) { - monitor.worked(1); - } - } finally { - if (monitor != null) { - monitor.done(); - } - } - } - - private void setJavaOutputPropertyIfNeeded(IDataModel model, final IVirtualComponent c) { - // Make sure output folder is set properly for web projects, and the product setting for single root structure is maintained. - // We may need to change the existing setup - - if (ProductManager.shouldUseSingleRootStructure()) { - String outputFolder = model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER)+"/"+J2EEConstants.WEB_INF_CLASSES; //$NON-NLS-1$ - - IJavaProject jproj = JavaCore.create(c.getProject()); - IClasspathEntry[] current = null; - IPath pjpath = c.getProject().getFullPath(); - try { - current = jproj.getRawClasspath(); - List updatedList = new ArrayList(); - IPath sourcePath = null; - boolean changeNeeded = false; - for (int i = 0; i < current.length; i++) { - IClasspathEntry entry = current[i]; - if ((entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) && (entry.getOutputLocation() != null && entry.getOutputLocation().toString().indexOf(J2EEConstants.WEB_INF_CLASSES) == -1)) { - //output different than J2EEConstants.WEB_INF_CLASSES - sourcePath = entry.getPath(); - updatedList.add(JavaCore.newSourceEntry(sourcePath)); - changeNeeded = true; - } - else - updatedList.add(entry); - } - IPath currentDefaultOutput = null; - currentDefaultOutput = jproj.getOutputLocation(); - if (currentDefaultOutput.toString().indexOf(J2EEConstants.WEB_INF_CLASSES) == -1) - changeNeeded = true; - if (changeNeeded) { - IClasspathEntry[] updated = (IClasspathEntry[])updatedList.toArray(new IClasspathEntry[updatedList.size()]); - IPath outdir = pjpath.append(outputFolder); - jproj.setRawClasspath(updated,outdir ,null); - jproj.save(null, true); - } - } catch (JavaModelException e) { - Logger.getLogger().logError(e); - } - } - // Now just set the property - String existing = c.getMetaProperties().getProperty("java-output-path"); //$NON-NLS-1$ - if (existing == null) - setOutputFolder(model, c); - } - - /** - * This overrides the default J2EE set output folder which sets the output folder to the content root - * if the optimized single root structure is used. For web projects, we need to switch this to - * set the output folder to "<contentRoot>/WEB-INF/classes" - * - * @param model - * @param component - */ - @Override - protected void setOutputFolder(IDataModel model, IVirtualComponent component) { - String outputFolder = null; - // If using single root structure, set the output folder to "<contentRoot>/WEB-INF/classes" - if (ProductManager.shouldUseSingleRootStructure()) - outputFolder = model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER)+"/"+J2EEConstants.WEB_INF_CLASSES; //$NON-NLS-1$ - // Otherwise set the output folder to the product setting default - else - outputFolder = CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.OUTPUT_FOLDER); - - component.setMetaProperty("java-output-path", outputFolder ); //$NON-NLS-1$ - } - - private void setContextRootPropertyIfNeeded(final IVirtualComponent c, String contextRoot) { - String existing = c.getMetaProperties().getProperty("context-root"); //$NON-NLS-1$ - if (existing == null) - c.setMetaProperty("context-root", contextRoot); //$NON-NLS-1$ - } - - private IPath setContentPropertyIfNeeded(final IDataModel model, final IPath pjpath, IProject project) { - IVirtualComponent c = ComponentCore.createComponent(project, false); - if (c.exists()) { - if( !c.getRootFolder().getProjectRelativePath().isRoot() ){ - return c.getRootFolder().getUnderlyingResource().getFullPath(); - } - } - return pjpath.append(model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER)); - } - - private void createWeb25DeploymentDescriptor(final IProject project, final IProjectFacetVersion fv, - IFolder webinfFolder, IProgressMonitor monitor) throws CoreException { - // Create the deployment descriptor (web.xml) if one doesn't exist - IFile webxmlFile = webinfFolder.getFile("web.xml"); //$NON-NLS-1$ - if (!webxmlFile.exists()) { - try { - // Create a minimal web.xml file, so the model can be initialized - final String webXmlContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<web-app id=\"WebApp_ID\" version=\"2.5\" xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\">\n</web-app>"; //$NON-NLS-1$ - webxmlFile.create(new ByteArrayInputStream(webXmlContents.getBytes("UTF-8")), true, monitor); //$NON-NLS-1$ - - final IModelProvider provider = ModelProviderManager.getModelProvider(project, fv); - Runnable runnable = new Runnable(){ - - public void run() { - WebApp webApp = (WebApp) provider.getModelObject(); - - // Add the display-name tag - DisplayName displayName = JavaeeFactory.eINSTANCE.createDisplayName(); - displayName.setValue(project.getName()); - webApp.getDisplayNames().add(displayName); - - // welcome file list - List<String> welcomeFiles = Arrays.asList( - "index.html", //$NON-NLS-1$ - "index.htm", //$NON-NLS-1$ - "index.jsp", //$NON-NLS-1$ - "default.html", //$NON-NLS-1$ - "default.htm", //$NON-NLS-1$ - "default.jsp" //$NON-NLS-1$ - ); - - // Add the welcome-file-list tag - WelcomeFileList welcomeFileList = WebFactory.eINSTANCE.createWelcomeFileList(); - welcomeFileList.getWelcomeFiles().addAll(welcomeFiles); - webApp.getWelcomeFileLists().add(welcomeFileList); - } - }; - provider.modify(runnable, null); - } catch (UnsupportedEncodingException e) { - Logger.getLogger().logError(e); - } - } - } - - - private static void mkdirs(final IFolder folder) - - throws CoreException - - { - if (!folder.exists()) { - if (folder.getParent() instanceof IFolder) { - mkdirs((IFolder) folder.getParent()); - } - - folder.create(true, true, null); - } - else - { - IContainer x = folder; - - while( x instanceof IFolder && x.isDerived() ) - { - x.setDerived( false ); - x = x.getParent(); - } - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetPostInstallDelegate.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetPostInstallDelegate.java deleted file mode 100644 index fbb89f6cb..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetPostInstallDelegate.java +++ /dev/null @@ -1,72 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.web.project.facet; - -import static org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR; -import static org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME; -import static org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties.MODULE_URI; -import static org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties.FACETED_PROJECT_WORKING_COPY; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.project.facet.J2EEFacetInstallDelegate; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -public final class WebFacetPostInstallDelegate extends J2EEFacetInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, final Object cfg, final IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - final IDataModel model = (IDataModel) cfg; - - // Associate with an EAR, if necessary. - if ( model.getBooleanProperty(ADD_TO_EAR) ) { - final String earProjectName = model.getStringProperty(EAR_PROJECT_NAME); - - if ( earProjectName != null && !earProjectName.equals("") ) { //$NON-NLS-1$ - - String ver = fv.getVersionString(); - - String j2eeVersionText = J2EEVersionUtil.convertVersionIntToString(J2EEVersionUtil.convertWebVersionStringToJ2EEVersionID(ver)); - final String moduleURI = model.getStringProperty(MODULE_URI); - - final IFacetedProjectWorkingCopy fpjwc - = (IFacetedProjectWorkingCopy) model.getProperty( FACETED_PROJECT_WORKING_COPY ); - - installAndAddModuletoEAR( j2eeVersionText, - earProjectName, - fpjwc.getPrimaryRuntime(), - project, - moduleURI, - monitor ); - - } - } - - if (monitor != null) { - monitor.worked(1); - } - } finally { - if (monitor != null) { - monitor.done(); - } - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetRuntimeChangedDelegate.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetRuntimeChangedDelegate.java deleted file mode 100644 index b03ee516c..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetRuntimeChangedDelegate.java +++ /dev/null @@ -1,67 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.web.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.common.project.facet.core.ClasspathHelper; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class WebFacetRuntimeChangedDelegate - - implements IDelegate - -{ - public void execute( final IProject project, - final IProjectFacetVersion fv, - final Object cfg, - final IProgressMonitor monitor ) - - throws CoreException - - { - if( monitor != null ) - { - monitor.beginTask( "", 1 ); //$NON-NLS-1$ - } - - try - { - ClasspathHelper.removeClasspathEntries( project, fv ); - - if( ! ClasspathHelper.addClasspathEntries( project, fv ) ) - { - // TODO: Support the no runtime case. - // ClasspathHelper.addClasspathEntries( project, fv, <something> ); - } - - if( monitor != null ) - { - monitor.worked( 1 ); - } - } - finally - { - if( monitor != null ) - { - monitor.done(); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetUtils.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetUtils.java deleted file mode 100644 index cbf249113..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.web.project.facet; - -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class WebFacetUtils { - - public static final IProjectFacet WEB_FACET = ProjectFacetsManager.getProjectFacet(IJ2EEFacetConstants.DYNAMIC_WEB); - public static final IProjectFacetVersion WEB_22 = WEB_FACET.getVersion("2.2"); //$NON-NLS-1$ - public static final IProjectFacetVersion WEB_23 = WEB_FACET.getVersion("2.3"); //$NON-NLS-1$ - public static final IProjectFacetVersion WEB_24 = WEB_FACET.getVersion("2.4"); //$NON-NLS-1$ - public static final IProjectFacetVersion WEB_25 = WEB_FACET.getVersion("2.5"); //$NON-NLS-1$ - - public static final IProjectFacet WEB_XDOCLET_FACET = getWebDocletFacet(); - - public static IProjectFacet getProjectFacet(String id) { - try { - return ProjectFacetsManager.getProjectFacet(id); - } catch (IllegalArgumentException e) { - return null; - } - } - - private static IProjectFacet getWebDocletFacet() { - try { - return ProjectFacetsManager.getProjectFacet(IJ2EEFacetConstants.DYNAMIC_WEB_XDOCLET); - } catch (IllegalArgumentException e) { - // the web doclet facet is not defined - return null; - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetVersionChangeDelegate.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetVersionChangeDelegate.java deleted file mode 100644 index 278b89244..000000000 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetVersionChangeDelegate.java +++ /dev/null @@ -1,108 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.web.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.common.project.facet.core.ClasspathHelper; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class WebFacetVersionChangeDelegate - - implements IDelegate - -{ - public void execute( final IProject project, - final IProjectFacetVersion fv, - final Object cfg, - final IProgressMonitor monitor ) - - throws CoreException - - { - if( monitor != null ) - { - monitor.beginTask( "", 1 ); //$NON-NLS-1$ - } - - try - { - // Find the version that's currently installed. - - final IFacetedProject fproj - = ProjectFacetsManager.create( project ); - - final IProjectFacetVersion oldver - = fproj.getInstalledVersion( fv.getProjectFacet() ); - - // Reset the classpath. - - ClasspathHelper.removeClasspathEntries( project, oldver ); - - if( ! ClasspathHelper.addClasspathEntries( project, fv ) ) - { - // TODO: Support the no runtime case. - // ClasspathHelper.addClasspathEntries( project, fv, <something> ); - } - - // Update the component version. - - -// final IVirtualComponent c = ComponentCore.createComponent(project); - -// final StructureEdit edit -// = StructureEdit.getStructureEditForWrite( project ); -// -// try -// { -// final ComponentType oldctype -// = StructureEdit.getComponentType( c ); -// -// final ComponentType newctype -// = ComponentcoreFactory.eINSTANCE.createComponentType(); -// -// newctype.setComponentTypeId( oldctype.getComponentTypeId() ); -// newctype.setVersion( fv.getVersionString() ); -// newctype.getProperties().addAll( oldctype.getProperties() ); -// -// StructureEdit.setComponentType( c, newctype ); -// -// edit.saveIfNecessary( null ); -// } -// finally -// { -// edit.dispose(); -// } - - if( monitor != null ) - { - monitor.worked( 1 ); - } - } - finally - { - if( monitor != null ) - { - monitor.done(); - } - } - } - -} |