Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet')
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/IJSFFacetInstallDataModelProperties.java60
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFConfigurationPresetFactory11.java84
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetException.java34
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java402
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDelegate.java398
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetPrimaryRuntimeChangedListener.java61
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetUninstallConfig.java68
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetUninstallDelegate.java152
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFLibraryValidator.java34
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtilFactory.java68
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java396
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils11.java587
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils12.java484
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils20.java29
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JsfFacetConfigurationUtil.java67
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/LegacyJSFLibraryProviderDetector.java93
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/LegacyJSFLibraryProviderUninstallOperation.java68
17 files changed, 0 insertions, 3085 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/IJSFFacetInstallDataModelProperties.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/IJSFFacetInstallDataModelProperties.java
deleted file mode 100644
index da030b789..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/IJSFFacetInstallDataModelProperties.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Oracle Corporation.
- * 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:
- * Gerry Kessler - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetInstallDataModelProperties;
-
-/**
- * Defines properties used by the JSF facet install data model.
- *
- * @author Gerry Kessler - Oracle
- */
-public interface IJSFFacetInstallDataModelProperties extends
- IFacetInstallDataModelProperties {
-
- /**
- * Refers to the path where the faces config file will be created.
- * Expects a string that can be interpreted as a web root relative path.
- */
- public static final String CONFIG_PATH = "IJSFFacetInstallDataModelProperties.CONFIG_PATH"; //$NON-NLS-1$
-
- /**
- * TODO:
- */
- public static final String SERVLET_NAME = "IJSFFacetInstallDataModelProperties.SERVLET_NAME"; //$NON-NLS-1$
-
- /**
- * TODO:
- */
- public static final String SERVLET_CLASSNAME = "IJSFFacetInstallDataModelProperties.SERVLET_CLASSNAME"; //$NON-NLS-1$
-
- /**
- * Refers to configuration information about servlet url patterns to add on install
- * The model value must be a String[].
- */
- public static final String SERVLET_URL_PATTERNS = "IJSFFacetInstallDataModelProperties.SERVLET_URL_PATTERNS"; //$NON-NLS-1$
-
- /**
- * TODO:
- */
- public static final String WEBCONTENT_DIR = "IJSFFacetInstallDataModelProperties.WEBCONTENT_DIR"; //$NON-NLS-1$
-
- /**
- * TODO:
- */
- public static final String LIBRARY_PROVIDER_DELEGATE = "IJSFFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE"; //$NON-NLS-1$
-
- /**
- * TODO:
- */
- public static final String COMPONENT_LIBRARIES = "IJSFFacetInstallDataModelProperties.COMPONENT_LIBRARIES"; //$NON-NLS-1$
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFConfigurationPresetFactory11.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFConfigurationPresetFactory11.java
deleted file mode 100644
index 5a318cea5..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFConfigurationPresetFactory11.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2008 BEA Systems, Inc. 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:
- * Konstantin Komissarchik
- ******************************************************************************/
-
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jst.common.project.facet.core.JavaFacet;
-import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils;
-import org.eclipse.jst.jsf.core.IJSFCoreConstants;
-import org.eclipse.jst.jsf.core.internal.Messages;
-import org.eclipse.wst.common.project.facet.core.IDynamicPreset;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase;
-import org.eclipse.wst.common.project.facet.core.IPresetFactory;
-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.PresetDefinition;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-
-/**
- * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
- */
-
-public final class JSFConfigurationPresetFactory11
-
- implements IPresetFactory
-
-{
- public PresetDefinition createPreset( final String presetId,
- final Map<String,Object> context )
-
- throws CoreException
-
- {
- final IFacetedProjectBase fproj
- = (IFacetedProjectBase) context.get( IDynamicPreset.CONTEXT_KEY_FACETED_PROJECT );
-
- final IProjectFacetVersion webFacetVersion
- = fproj.getProjectFacetVersion( WebFacetUtils.WEB_FACET );
-
- if( webFacetVersion != null && webFacetVersion.compareTo( WebFacetUtils.WEB_23 ) >= 0 )
- {
- final Set<IProjectFacetVersion> facets = new HashSet<IProjectFacetVersion>();
-
- final IProjectFacet jsfFacet
- = ProjectFacetsManager.getProjectFacet( IJSFCoreConstants.JSF_CORE_FACET_ID );
-
- final IProjectFacetVersion jsfFacetVersion11
- = jsfFacet.getVersion( IJSFCoreConstants.JSF_VERSION_1_1 );
-
- facets.add( jsfFacetVersion11 );
- facets.add( webFacetVersion );
-
- if( webFacetVersion == WebFacetUtils.WEB_23 )
- {
- facets.add( JavaFacet.VERSION_1_3 );
- }
- else if( webFacetVersion == WebFacetUtils.WEB_24 )
- {
- facets.add( JavaFacet.VERSION_1_4 );
- }
- else
- {
- facets.add( JavaFacet.VERSION_1_5 );
- }
-
- return new PresetDefinition( Messages.JSFFacet11_presetLabel, Messages.JSFFacet11_presetDescription, facets );
- }
-
- return null;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetException.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetException.java
deleted file mode 100644
index d2878b347..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle Corporation.
- * 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:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-
-/**
- * Exception for use during JSF Facet installation/un-installation
- *
- */
-public class JSFFacetException extends CoreException {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor
- * @param msg
- */
- public JSFFacetException(String msg) {
- super(new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, msg));
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java
deleted file mode 100644
index 9fc0b6dd3..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDataModelProvider.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Oracle Corporation.
- * 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:
- * Gerry Kessler - initial API and implementation
- * Debajit Adhikary - Fixes for bug 255097 ("Request to remove input fields
- * from facet install page")
- *******************************************************************************/
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-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.jst.common.project.facet.core.libprov.IPropertyChangeListener;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
-import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
-import org.eclipse.jst.jsf.core.IJSFCoreConstants;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-import org.eclipse.jst.jsf.core.internal.Messages;
-import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference;
-import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
-import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
-import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
-
-/**
- * Provides a data model used by the JSF facet install.
- *
- * @author Gerry Kessler - Oracle
- */
-@SuppressWarnings("deprecation")
-public class JSFFacetInstallDataModelProvider extends
- FacetInstallDataModelProvider implements
- IJSFFacetInstallDataModelProperties {
-
- private static final String REGEX_FOR_VALID_CONFIG_FILE_NAME = "^(?!.*/{2,}.*$)[-\\w/.]+$"; //$NON-NLS-1$
- private static final Pattern PATTERN_FOR_VALID_CONFIG_FILE_NAME = Pattern.compile(REGEX_FOR_VALID_CONFIG_FILE_NAME);
-
- private final boolean jsfFacetConfigurationEnabled = JsfFacetConfigurationUtil.isJsfFacetConfigurationEnabled();
-
- private LibraryInstallDelegate libraryInstallDelegate = null;
-
- private void initLibraryInstallDelegate()
- {
- final IFacetedProjectWorkingCopy fpjwc = (IFacetedProjectWorkingCopy) getProperty( FACETED_PROJECT_WORKING_COPY );
- final IProjectFacetVersion fv = (IProjectFacetVersion) getProperty( FACET_VERSION );
-
- if( this.libraryInstallDelegate == null && fpjwc != null && fv != null )
- {
- this.libraryInstallDelegate = new LibraryInstallDelegate( fpjwc, fv );
-
- this.libraryInstallDelegate.addListener
- (
- new IPropertyChangeListener()
- {
- public void propertyChanged( final String property,
- final Object oldValue,
- final Object newValue )
- {
- final IDataModel dm = getDataModel();
-
- if( dm != null )
- {
- dm.notifyPropertyChange( LIBRARY_PROVIDER_DELEGATE, IDataModel.VALUE_CHG );
- }
- }
- }
- );
- }
- }
-
- private String errorMessage;
-
-
- public Set getPropertyNames() {
- Set names = super.getPropertyNames();
-
- if (jsfFacetConfigurationEnabled)
- {
- names.add(CONFIG_PATH);
- names.add(SERVLET_NAME);
- names.add(SERVLET_CLASSNAME);
- names.add(SERVLET_URL_PATTERNS);
- names.add(COMPONENT_LIBRARIES);
- names.add(WEBCONTENT_DIR);
-
- }
-
- names.add(LIBRARY_PROVIDER_DELEGATE);
-
- return names;
- }
-
- public Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(CONFIG_PATH)) {
- return JSFUtils.JSF_DEFAULT_CONFIG_PATH;
- } else if (propertyName.equals(SERVLET_NAME)) {
- return JSFUtils.JSF_DEFAULT_SERVLET_NAME;
- } else if (propertyName.equals(SERVLET_CLASSNAME)) {
- return JSFUtils.JSF_SERVLET_CLASS;
- } else if (propertyName.equals(SERVLET_URL_PATTERNS)) {
- return new String[] {JSFUtils.JSF_DEFAULT_URL_MAPPING };
- } else if (propertyName.equals(FACET_ID)) {
- return IJSFCoreConstants.JSF_CORE_FACET_ID;
- } else if (propertyName.equals(WEBCONTENT_DIR)){
- return "WebContent"; //not sure I need this //$NON-NLS-1$
- } else if (propertyName.equals(LIBRARY_PROVIDER_DELEGATE)) {
- return this.libraryInstallDelegate;
- } else if (propertyName.equals(COMPONENT_LIBRARIES)) {
- return new JSFLibraryInternalReference[0];
- }
- return super.getDefaultProperty(propertyName);
- }
-
- @Override
- public boolean propertySet( final String propertyName,
- final Object propertyValue )
- {
- if( propertyName.equals( FACETED_PROJECT_WORKING_COPY ) || propertyName.equals( FACET_VERSION ) )
- {
- initLibraryInstallDelegate();
-
- if( this.libraryInstallDelegate != null && propertyName.equals( FACET_VERSION ) )
- {
- final IProjectFacetVersion fv = (IProjectFacetVersion) getProperty( FACET_VERSION );
- this.libraryInstallDelegate.setProjectFacetVersion( fv );
- }
- }
-
- return super.propertySet( propertyName, propertyValue );
- }
-
- public IStatus validate(String name) {
- errorMessage = null;
-
- if (jsfFacetConfigurationEnabled)
- {
- if (name.equals(CONFIG_PATH)) {
- return validateConfigLocation(getStringProperty(CONFIG_PATH));
- } else if (name.equals(SERVLET_NAME)) {
- return validateServletName(getStringProperty(SERVLET_NAME));
- }
- else if (name.equals(COMPONENT_LIBRARIES)) {
- return validateClasspath();
- }
- }
-
- if (name.equals(LIBRARY_PROVIDER_DELEGATE))
- {
- return ((LibraryInstallDelegate) getProperty(LIBRARY_PROVIDER_DELEGATE)).validate();
- }
-
- return super.validate(name);
- }
-
- private IStatus createErrorStatus(String msg) {
- return new Status(IStatus.ERROR, JSFCorePlugin.PLUGIN_ID, msg);
- }
-
- private IStatus validateServletName(String servletName) {
- if (servletName == null || servletName.trim().length() == 0) {
- errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateServletName;
- return createErrorStatus(errorMessage);
- }
-
- return OK_STATUS;
- }
-
- private IStatus validateConfigLocation(String text) {
- if (text == null || text.trim().equals("")) { //$NON-NLS-1$
- errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileEmpty;
- return createErrorStatus(errorMessage);
- }
- text = text.trim();
-
- if (getProjectPath() == null) //this circumstance occurs on page init
- return OK_STATUS;
-
- IPath fullPath = getProjectPath().append(text);
- IPath passedPath = new Path(text);
- if (!fullPath.isValidPath(text)){
- errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateConfigFilePath;
- return createErrorStatus(errorMessage);
- }
-
- //FIXME: check for valid file path also [passedPath.toFile().isFile()]
- if (text.toLowerCase().lastIndexOf(".xml") != text.length() - 4) { //$NON-NLS-1$
- errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileXML;
- return createErrorStatus(errorMessage);
- }
-
- // Configuration path must not contain backslashes.
- // Must use forward slashes instead.
- if (text.lastIndexOf("\\") >= 0){ //$NON-NLS-1$
- errorMessage = Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileSlashes;
- return createErrorStatus(errorMessage);
- }
-
- // Configuration file must NOT be absolute path.
- // It must be specified relative to project.
- if (passedPath.getDevice() != null) {
- errorMessage = NLS.bind(
- Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileRelative1,
- getWebContentFolderName());
- return createErrorStatus(errorMessage);
- }
-
- // Configuration file must be located in the project's folder
- IPath webContentFolder = getWebContentFolder();
- IPath setPath = webContentFolder.append(passedPath);
- if (!getWebContentFolder().isPrefixOf(setPath)) {
- errorMessage = NLS.bind(
- Messages.JSFFacetInstallDataModelProvider_ValidateConfigFileRelative2,
- getWebContentFolderName());
- return createErrorStatus(errorMessage);
- }
-
- // Check for other general invalid characters
- if (!isValidConfigFileName(text))
- {
- errorMessage = Messages.JSFFacetInstallDataModelProvider_INVALID_JSF_CONFIG_FILE_NAME;
- return createErrorStatus(errorMessage);
- }
-
- return OK_STATUS;
- }
-
-
- /**
- * (This method had been made protected to enable JUnit testing.)
- *
- * @param configFileName
- * @return True if the argument config file name does not have any invalid
- * characters.
- */
- public static boolean isValidConfigFileName (final String configFileName)
- {
- return PATTERN_FOR_VALID_CONFIG_FILE_NAME.matcher(configFileName).matches();
- }
-
-
- private IStatus validateClasspath(){
- Set jars = new HashSet();
- if (doesProjectExist()){
- //validate actual classpath by loading jars from cp
- try {
- IClasspathEntry[] entries = getJavaProject().getResolvedClasspath(true);
- for (int i=0;i<entries.length;i++){
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY){
- jars.add(entry.getPath().makeAbsolute().toString());
- }
- }
- } catch (JavaModelException e) {
- // FIXME: what should we do in this case?
- JSFCorePlugin.log(e, "Error searching class path"); //$NON-NLS-1$
- }
- }
- //else as we do not have a javaProject yet, all we can do is validate that there is no duplicate jars (absolute path)
-
- IStatus status = null;
-
- JSFLibraryInternalReference[] compLibs = (JSFLibraryInternalReference[]) getProperty(IJSFFacetInstallDataModelProperties.COMPONENT_LIBRARIES);
- if (compLibs != null){
- for (int i=0;i<compLibs.length;i++){
- JSFLibrary lib = compLibs[i].getLibrary();
- status = checkForDupeArchiveFiles(jars, lib);
- if (!OK_STATUS.equals(status)){
- return status;
- }
- }
- }
- return OK_STATUS;
- }
-
- private IJavaProject getJavaProject() {
- IProject proj = getProject();
- if (proj != null)
- return JavaCore.create(proj);
- return null;
- }
-
- private IProject getProject(){
- String projName = (String)getProperty(FACET_PROJECT_NAME);
- if (projName == null || "".equals(projName)) //$NON-NLS-1$
- return null;
-
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
- return project;
- }
-
- private boolean doesProjectExist() {
- IProject project = getProject();
- return (project != null) && project.exists();
- }
-
- private IStatus checkForDupeArchiveFiles(Set jars,
- JSFLibrary aJSFLib) {
- if (aJSFLib == null)
- return OK_STATUS;
-
- for (Iterator it=aJSFLib.getArchiveFiles().iterator();it.hasNext();){
- ArchiveFile jar = (ArchiveFile)it.next();
- if (jars.contains(jar.getResolvedSourceLocation())){
- return createErrorStatus(NLS.bind(Messages.JSFFacetInstallDataModelProvider_DupeJarValidation,jar.getResolvedSourceLocation()));
- }
- jars.add(jar.getResolvedSourceLocation());
- }
- return OK_STATUS;
- }
-
- private IPath getProjectPath() {
- IProject project = getProject();
- if (project == null)
- return null;
- else if (project.exists())
- return project.getLocation();
-
- String projName = (String)getProperty(FACET_PROJECT_NAME);
- IFacetedProjectWorkingCopy projModel = (IFacetedProjectWorkingCopy)getProperty(FACETED_PROJECT_WORKING_COPY );
-
- if (projModel.getProjectLocation() != null)
- return projModel.getProjectLocation().append(projName);
-
- return ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(projName);
-
- }
-
- private IPath getWebContentFolder() {
- //One can get here 2 ways:
- //if web app exists and user is adding a facet, or
- // if creating a new web app.
-
- IPath webContentPath = null;
- String projName = model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
- IProject proj = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(projName);
-
- String webFolder = getWebContentFolderName();
- if (proj.exists()) {
-
- webContentPath = ComponentCore.createComponent(proj).getRootFolder()
- .getUnderlyingFolder().getRawLocation();
- }
- else {
-
- if (webFolder == null){
- //we got problems... should not happen
- return proj.getFullPath();
- }
- webContentPath = proj.getFullPath().append(webFolder);
-
- }
- return webContentPath;
- }
-
- private String getWebContentFolderName() {
- String projName = (String)getProperty(FACET_PROJECT_NAME);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
- if (project.exists()){
- IPath webContentPath = ComponentCore.createComponent(project).getRootFolder()
- .getUnderlyingFolder().getProjectRelativePath();
-
- return webContentPath.toString();
- }
-
- IFacetedProjectWorkingCopy projWC = (IFacetedProjectWorkingCopy)getProperty(FACETED_PROJECT_WORKING_COPY);
- Set<Action> pfas = projWC.getProjectFacetActions();
- for (Action action : pfas){
- if (action.getProjectFacetVersion().getProjectFacet().getId().equals("jst.web")){ //$NON-NLS-1$
- IDataModel webFacet = (IDataModel) action.getConfig();
- return webFacet.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER );
- }
- }
-
- //should not get here.
- return null;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDelegate.java
deleted file mode 100644
index b23a0e601..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetInstallDelegate.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle Corporation.
- * 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:
- * Gerry Kessler - initial API and implementation
- * Debajit Adhikary - Fixes for bug 255097 ("Request to remove input fields
- * from facet install page")
- * - MyFaces and SunRI-specific configuration
- *******************************************************************************/
-
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
-import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperationConfig;
-import org.eclipse.jst.j2ee.model.IModelProvider;
-import org.eclipse.jst.j2ee.model.ModelProviderManager;
-import org.eclipse.jst.javaee.web.WebApp;
-import org.eclipse.jst.jsf.common.facet.libraryprovider.jsf.JsfLibraryUtil;
-import org.eclipse.jst.jsf.common.webxml.WebXmlUpdater;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-import org.eclipse.jst.jsf.core.internal.Messages;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-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.IProjectFacetVersion;
-
-/**
- * JSF Facet Install Delegate for WTP faceted web projects. Deals with 2.3, 2.4 and 2.5 web app models.
- *
- * Uses <code>com.eclispe.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider<code> for model
- * <li> creates JSF configuration file if not already present. It will not attempt to upgrade or downgrade the version if there is a mismatch.
- * <li> updates web.xml for: servlet, servlet-mapping and context-param
- * <li> adds implementation jars to WEB-INF/lib if user requests
- *
- * @see org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider
- * @since 1.0
- */
-public final class JSFFacetInstallDelegate implements IDelegate {
-
- private final boolean jsfFacetConfigurationEnabled = JsfFacetConfigurationUtil.isJsfFacetConfigurationEnabled();
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject, org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
- 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 {
- IDataModel config = null;
-
- if (cfg != null) {
- config = (IDataModel) cfg;
- } else {
- throw new JSFFacetException(
- Messages.JSFFacetInstallDelegate_InternalErr);
- }
-
- final JSFUtils jsfUtil = new JSFUtilFactory().create(fv, ModelProviderManager.getModelProvider(project));
- if (jsfUtil == null)
- {
- throw new JSFFacetException(NLS.bind(
- Messages.Could_Not_GetJSFVersion, fv.toString()));
- }
-
- if (jsfFacetConfigurationEnabled)
- {
- // Before we do any configuration, verify that web.xml is // available for update
- final IModelProvider provider = jsfUtil
- .getModelProvider();
- if (provider == null)
- {
- throw new JSFFacetException(NLS.bind(
- Messages.JSFFacetInstallDelegate_ConfigErr,
- project.getName()));
- }
- else if (!(provider.validateEdit(null, null).isOK()))
- {
- if (!(provider.validateEdit(null, null).isOK()))
- {// checks for web.xml file being read-only and allows
- // user to set writeable
- throw new JSFFacetException(
- NLS.bind(
- Messages.JSFFacetInstallDelegate_NonUpdateableWebXML,
- project.getName()));
- }
- }
- }
-
-// // Create JSF Libs as classpath containers and set WTP dependencies
-// // as required
-// createClasspathEntries(project, fv, config, monitor);
-
- //Configure libraries
- ( (LibraryInstallDelegate) config.getProperty( IJSFFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE ) ).execute( new NullProgressMonitor() );
-
- final LibraryInstallDelegate libDelegate = (LibraryInstallDelegate) (config.getProperty( IJSFFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE));
- final LibraryProviderOperationConfig libConfig = libDelegate.getLibraryProviderOperationConfig();
-
- if (jsfFacetConfigurationEnabled)
- {
- // Create config file
- createConfigFile(project, fv, config, monitor, jsfUtil);
-
- // Update web model
- createServletAndModifyWebXML(project, config, monitor, jsfUtil);
- updateWebXmlByJsfVendor(libConfig, project, monitor);
- }
-
- if (monitor != null) {
- monitor.worked(1);
- }
-
- } finally {
- if (monitor != null) {
- monitor.done();
- }
- }
- }
-
-
- /**
- * Configures web.xml for MyFaces or Sun-RI when a user-library is used.
- * Does no special configuration when a third party library provider is used
- * (e.g. WebLogic shared library)
- *
- * @param libConfig
- * Library install delegate
- * @param project
- * IProject to update
- * @param monitor
- * IProgressMonitor
- */
- private void updateWebXmlByJsfVendor (final LibraryProviderOperationConfig libConfig,
- final IProject project,
- final IProgressMonitor monitor)
- {
- final UserLibraryProviderInstallOperationConfig userLibConfig = getUserLibConfig(libConfig);
- if (userLibConfig == null) // Not a user lib provider (e.g. shared lib provider)
- return; // Any special configuration will be done by third party lib provider.
-
-
- switch (JsfLibraryUtil.getJsfLibraryVendorType(userLibConfig))
- {
- case MYFACES:
- updateWebXmlForMyfaces(project, monitor);
- break;
- case SUN_RI:
- updateWebXmlForSunRi(project, monitor);
- break;
- case UNKNOWN:
- break;
- }
- }
-
-
- /**
- * (Refactored into a protected method for JUnit testing)
- *
- * @param libConfig LibraryProviderOperationConfig object
- *
- * @return WtpUserLibraryProviderInstallOperationConfig object if the
- * argument object has the same runtime type. Returns null
- * otherwise e.g. if the libConfig is of the runtime type
- * SharedLibraryProviderInstallOperationConfig.
- */
- public static UserLibraryProviderInstallOperationConfig getUserLibConfig (final LibraryProviderOperationConfig libConfig)
- {
- if (!(libConfig instanceof UserLibraryProviderInstallOperationConfig)) // Third-party shared library providers etc.
- return null;
-
- return (UserLibraryProviderInstallOperationConfig) libConfig;
- }
-
-
- /**
- * Updates web.xml for the given project with MyFaces-specific parameters.
- * (This method is public static so that it may be called by other third
- * party library providers for consistent MyFaces configuration across
- * different JSF library providers)
- *
- * @param project
- * IProject whose web.xml is to be updated.
- *
- * @param monitor
- * IProgressMonitor
- */
- public static void updateWebXmlForMyfaces (final IProject project,
- final IProgressMonitor monitor)
- {
- final WebXmlUpdater updater = new WebXmlUpdater(project, monitor);
-
- updater.addContextParam("javax.servlet.jsp.jstl.fmt.localizationContext", "resources.application", null); //$NON-NLS-1$//$NON-NLS-2$
- updater.addContextParam("javax.faces.STATE_SAVING_METHOD", "client", Messages.JSFFacetInstallDelegate_StateSavingMethod); //$NON-NLS-1$ //$NON-NLS-2$
- updater.addContextParam("org.apache.myfaces.ALLOW_JAVASCRIPT", "true", Messages.JSFFacetInstallDelegate_AllowJavascriptDescription); //$NON-NLS-1$ //$NON-NLS-2$
- updater.addContextParam("org.apache.myfaces.PRETTY_HTML", "true", Messages.JSFFacetInstallDelegate_PrettyHtmlDescription); //$NON-NLS-1$ //$NON-NLS-2$
- updater.addContextParam("org.apache.myfaces.DETECT_JAVASCRIPT", "false", null); //$NON-NLS-1$//$NON-NLS-2$
- updater.addContextParam("org.apache.myfaces.AUTO_SCROLL", "true", Messages.JSFFacetInstallDelegate_AutoScrollDescription); //$NON-NLS-1$ //$NON-NLS-2$
-
- updater.addServlet("faces", "org.apache.myfaces.webapp.MyFacesServlet", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- updater.addServletMapping("faces", "org.apache.myfaces.webapp.MyFacesServlet", "*.jsf"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- updater.addServletMapping("faces", "org.apache.myfaces.webapp.MyFacesServlet", "*.faces"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-
- updater.addListener("org.apache.myfaces.webapp.StartupServletContextListener"); //$NON-NLS-1$
-
-// // Additional, more complex updates
-// if (updater.isJavaEEWebapp())
-// {
-// updater.getProvider().modify(new UpdateWebXmlForMyfacesJavaEE(project, monitor), WebXmlUtils.WEB_XML_PATH);
-// }
-// else if (updater.isJ2EEWebapp())
-// {
-// updater.getProvider().modify(new UpdateWebXmlForMyfacesJ2EE(project, monitor), WebXmlUtils.WEB_XML_PATH);
-// }
- }
-
-
- /**
- * Updates web.xml for the given project with SunRI-specific parameters.
- * (This method is public static so that it may be called by other third
- * party library providers for consistent Sun-RI configuration across
- * different JSF library providers)
- *
- * @param project
- * IProject whose web.xml is to be updated.
- *
- * @param monitor
- * IProgressMonitor
- */
- public static void updateWebXmlForSunRi (final IProject project,
- final IProgressMonitor monitor)
- {
- final WebXmlUpdater updater = new WebXmlUpdater(project, monitor);
-
- updater.addContextParam("javax.faces.STATE_SAVING_METHOD", "client", Messages.JSFFacetInstallDelegate_StateSavingMethod); //$NON-NLS-1$//$NON-NLS-2$
- updater.addContextParam("javax.servlet.jsp.jstl.fmt.localizationContext", "resources.application", null); //$NON-NLS-1$ //$NON-NLS-2$
- updater.addListener("com.sun.faces.config.ConfigureListener"); //$NON-NLS-1$
-
- updater.addServlet("Faces Servlet", "javax.faces.webapp.FacesServlet", "1"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- updater.addServletMapping("Faces Servlet", "javax.faces.webapp.FacesServlet", "*.jsf"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- updater.addServletMapping("Faces Servlet", "javax.faces.webapp.FacesServlet", "*.faces"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
-
-
-// /**
-// * @param path
-// * @param lib
-// * @return creates new IClasspathEntry with WTP dependency attribute set, if required
-// */
-// private IClasspathEntry getNewCPEntry(final IPath path, final JSFLibraryInternalReference lib) {
-//
-// IClasspathEntry entry = null;
-// if (lib.isCheckedToBeDeployed()){
-// IClasspathAttribute depAttrib = JavaCore.newClasspathAttribute(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY,
-// ClasspathDependencyUtil.getDefaultRuntimePath(true).toString());
-// entry = JavaCore.newContainerEntry(path,null, new IClasspathAttribute[]{depAttrib}, true);
-// }
-// else {
-// entry = JavaCore.newContainerEntry(path);
-// }
-//
-// return entry;
-// }
-
-
- /**
- * @param project
- * @param jsfConfigPath
- * @return absolute IPath to jsfConfig
- */
- private IPath resolveConfigPath(final IProject project, final String jsfConfigPath) {
- return ComponentCore.createComponent(project).getRootFolder()
- .getUnderlyingFolder().getRawLocation().append(
- new Path(jsfConfigPath));
-
- }
-
- /**
- * Create the faces configuration file. If the file already exist, then the file is left alone.
- * @param project
- * @param fv
- * @param config
- * @param monitor
- */
- private void createConfigFile(final IProject project,
- final IProjectFacetVersion fv, final IDataModel config,
- final IProgressMonitor monitor, final JSFUtils jsfUtil) {
-
-
- final IPath configPath = resolveConfigPath(project, config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH));
- try {
- // do not overwrite if the file exists
- if (!configPath.toFile().exists()) {
- final IWorkspaceRunnable op = new IWorkspaceRunnable(){
- public void run(final IProgressMonitor monitor_inner) throws CoreException{
- jsfUtil.createConfigFile(configPath);
- project.refreshLocal(IResource.DEPTH_INFINITE, monitor_inner);
- }
- };
- op.run(monitor);
- }
- } catch (final CoreException e) {
- JSFCorePlugin.log(e, "Exception occured while creating faces-config.xml");//$NON-NLS-1$
- }
-
- }
-
- /**
- * Create servlet and URL mappings and update the webapp
- *
- * @param project
- * @param config
- * @param monitor
- */
- private void createServletAndModifyWebXML(final IProject project,
- final IDataModel config, final IProgressMonitor monitor,
- final JSFUtils jsfUtil)
- {
-
- final IModelProvider provider = jsfUtil.getModelProvider();
- final IPath webXMLPath = new Path("WEB-INF").append("web.xml"); //$NON-NLS-1$ //$NON-NLS-2$
- if (jsfUtil.isJavaEE(provider.getModelObject()))
- {
- provider.modify(new UpdateWebXMLForJavaEE(project, config, jsfUtil),
- doesDDFileExist(project, webXMLPath) ? webXMLPath
- : IModelProvider.FORCESAVE);
- } else
- {// must be 2.3 or 2.4
- provider.modify(new UpdateWebXMLForJ2EE(project, config, jsfUtil),
- webXMLPath);
- }
- // TODO: is the MyFaces check a todo?
- // Check if runtime is MyFaces or Sun-RI
- }
-
- private boolean doesDDFileExist(final IProject project, final IPath webXMLPath) {
- return project.getProjectRelativePath().append(webXMLPath).toFile().exists();
- }
-
- private class UpdateWebXMLForJavaEE implements Runnable {
- private final IProject project;
- private final IDataModel config;
- private final JSFUtils jsfUtil;
-
- UpdateWebXMLForJavaEE(final IProject project, final IDataModel config, final JSFUtils jsfUtil){
- this.project = project;
- this.config = config;
- this.jsfUtil = jsfUtil;
- }
-
- public void run() {
- final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject();
- jsfUtil.updateWebApp(webApp, config);
- }
- }
-
- private class UpdateWebXMLForJ2EE implements Runnable {
- private final IProject project;
- private final IDataModel config;
- private final JSFUtils jsfUtil;
-
- UpdateWebXMLForJ2EE(final IProject project, final IDataModel config, final JSFUtils jsfUtil){
- this.project = project ;
- this.config = config;
- this.jsfUtil = jsfUtil;
- }
-
- public void run() {
- final org.eclipse.jst.j2ee.webapplication.WebApp webApp = (org.eclipse.jst.j2ee.webapplication.WebApp)ModelProviderManager.getModelProvider(project).getModelObject();
- jsfUtil.updateWebApp(webApp, config);
- }
-
- }
-
-
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetPrimaryRuntimeChangedListener.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetPrimaryRuntimeChangedListener.java
deleted file mode 100644
index 7a36602ba..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetPrimaryRuntimeChangedListener.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle Corporation.
- * 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:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils;
-import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
-import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
-import org.eclipse.wst.common.project.facet.core.events.IPrimaryRuntimeChangedEvent;
-
-/**
- * Handles primary runtime changed events when the JSF Facet is installed
- *
- * @since JSF 1.0.1
- */
-@SuppressWarnings("deprecation")
-public class JSFFacetPrimaryRuntimeChangedListener implements IFacetedProjectListener {
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener#handleEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent)
- */
- public void handleEvent(IFacetedProjectEvent event) {
- if (event instanceof IPrimaryRuntimeChangedEvent &&
- getJSFFacetedVersion(event.getProject().getProject()) != null && //must be a JSF faceted project
- JSFLibraryConfigurationHelper.isConfiguredForSystemSuppliedImplementation(event.getProject().getProject())){
-
- try {
- IProject project = event.getProject().getProject();
- IProjectFacetVersion fv = getJSFFacetedVersion(project);
- ClasspathHelper.removeClasspathEntries(project, fv);
- ClasspathHelper.addClasspathEntries(project, fv);
- } catch (CoreException e) {
- JSFCorePlugin.log(IStatus.ERROR, "Unable to replace server supplied implementation when runtime changed.", e);//$NON-NLS-1$
- }
- }
-
- }
-
- /**
- * @param project
- * @return IProjectFacetVersion and null if not JSF faceted
- */
- private IProjectFacetVersion getJSFFacetedVersion(IProject project) {
- return JSFAppConfigUtils.getProjectFacet(project);
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetUninstallConfig.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetUninstallConfig.java
deleted file mode 100644
index 1c1245aac..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetUninstallConfig.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryUninstallDelegate;
-import org.eclipse.wst.common.project.facet.core.ActionConfig;
-import org.eclipse.wst.common.project.facet.core.IActionConfigFactory;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-
-/**
- * Configuration for JSF facet uninstall
- *
- */
-public class JSFFacetUninstallConfig
-
- extends ActionConfig
-
-{
- private LibraryUninstallDelegate librariesUninstallDelegate = null;
-
- /**
- * @return the library uninstall delegate
- */
- public LibraryUninstallDelegate getLibrariesUninstallDelegate()
- {
- return this.librariesUninstallDelegate;
- }
-
- @Override
- public void setFacetedProjectWorkingCopy( final IFacetedProjectWorkingCopy fpjwc )
- {
- super.setFacetedProjectWorkingCopy( fpjwc );
- init();
- }
-
- @Override
- public void setProjectFacetVersion( final IProjectFacetVersion fv )
- {
- super.setProjectFacetVersion( fv );
- init();
- }
-
- private void init()
- {
- final IFacetedProjectWorkingCopy fpjwc = getFacetedProjectWorkingCopy();
- final IProjectFacetVersion fv = getProjectFacetVersion();
-
- if( this.librariesUninstallDelegate == null && fpjwc != null && fv != null )
- {
- this.librariesUninstallDelegate = new LibraryUninstallDelegate( fpjwc, fv );
- }
- }
-
- /**
- * The action configuration factory for the JSF facet uninstall config
- *
- */
- public static final class Factory
-
- implements IActionConfigFactory
-
- {
- public Object create()
- {
- return new JSFFacetUninstallConfig();
- }
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetUninstallDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetUninstallDelegate.java
deleted file mode 100644
index 29406fbd4..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFFacetUninstallDelegate.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle Corporation.
- * 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:
- * Oracle - initial API and implementation
- * Debajit Adhikary - Fixes for bug 255097 ("Request to remove input fields
- * from facet install page")
- *******************************************************************************/
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.core.resources.IProject;
-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.jst.j2ee.model.IModelProvider;
-import org.eclipse.jst.j2ee.model.ModelProviderManager;
-import org.eclipse.jst.javaee.web.WebApp;
-import org.eclipse.jst.jsf.core.internal.Messages;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.project.facet.core.IDelegate;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-
-/**
- * JSF Facet Un-install Delegate for WTP faceted projects.
- *
- * <li> removes JSF servlet, servlet-mappings and context-params
- * <li> leaves JSF configuration files on disk
- * <li> removes JSF classpath containers
- *
- */
-public final class JSFFacetUninstallDelegate implements IDelegate {
-
- private final boolean jsfFacetConfigurationEnabled = JsfFacetConfigurationUtil.isJsfFacetConfigurationEnabled();
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject, org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(final IProject project, final IProjectFacetVersion fv,
- final Object config, final IProgressMonitor monitor) throws CoreException {
- {
-
- if (monitor != null) {
- monitor.beginTask("", 1); //$NON-NLS-1$
- }
-
- try
- {
- final JSFUtils jsfUtil = new JSFUtilFactory().create(fv, ModelProviderManager.getModelProvider(project));
- if (jsfUtil == null)
- {
- throw new JSFFacetException(NLS.bind(
- Messages.Could_Not_GetJSFVersion, fv.toString()));
- }
-
- if (jsfFacetConfigurationEnabled)
- {
- //Before we do any de-configuration, verify that web.xml is available for update
- IModelProvider provider = jsfUtil.getModelProvider();
- if (provider == null ) {
- throw new JSFFacetException(NLS.bind(Messages.JSFFacetUninstallDelegate_ConfigErr, project.getName()));
- } else if (!(provider.validateEdit(null, null).isOK())){
- throw new JSFFacetException(NLS.bind(Messages.JSFFacetUninstallDelegate_NonUpdateableWebXML, project.getName()));
- }
- }
-
- // Remove JSF Libraries
- ( (JSFFacetUninstallConfig) config ).getLibrariesUninstallDelegate().execute( null );
-
- if (jsfFacetConfigurationEnabled)
- {
- // remove servlet stuff from web.xml
- uninstallJSFReferencesFromWebApp(project, monitor, jsfUtil);
- }
- if (monitor != null) {
- monitor.worked(1);
- }
-
- } finally {
- if (monitor != null) {
- monitor.done();
- }
- }
- }
- }
-
- private void uninstallJSFReferencesFromWebApp(final IProject project,
- final IProgressMonitor monitor, final JSFUtils jsfUtil) {
-
- IModelProvider provider = jsfUtil.getModelProvider();
- Object webAppObj = provider.getModelObject();
- if (webAppObj != null)
- {
- IPath ddPath = new Path("WEB-INF").append("web.xml"); //$NON-NLS-1$ //$NON-NLS-2$
- if (isJavaEEWebApp(webAppObj))
- {
- provider.modify(new RemoveJSFFromJavaEEWebAppOperation(project,
- jsfUtil), ddPath);
- } else
- {// 2.3 or 2.4 web app
- provider.modify(new RemoveJSFFromJ2EEWebAppOperation(project,
- jsfUtil), ddPath);
- }
- }
- }
-
- private boolean isJavaEEWebApp(final Object webAppObj) {
- if (webAppObj instanceof WebApp)
- return true;
-
- return false;
-
- }
-
- static class RemoveJSFFromJavaEEWebAppOperation implements Runnable {
- private IProject _project;
- private JSFUtils _jsfUtil;
-
- RemoveJSFFromJavaEEWebAppOperation(final IProject project, JSFUtils jsfUtil){
- this._project = project;
- this._jsfUtil = jsfUtil;
- }
-
- public void run()
- {
- WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(
- _project).getModelObject();
- _jsfUtil.rollbackWebApp(webApp);
- }
-
- }
-
- static class RemoveJSFFromJ2EEWebAppOperation implements Runnable {
- private IProject _project;
- private JSFUtils _jsfUtil;
-
- RemoveJSFFromJ2EEWebAppOperation(final IProject project, JSFUtils jsfUtil){
- this._project = project;
- this._jsfUtil = jsfUtil;
- }
-
- public void run() {
- org.eclipse.jst.j2ee.webapplication.WebApp webApp = (org.eclipse.jst.j2ee.webapplication.WebApp) ModelProviderManager.getModelProvider(_project).getModelObject();
- _jsfUtil.rollbackWebApp(webApp);
- }
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFLibraryValidator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFLibraryValidator.java
deleted file mode 100644
index e862a65b2..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFLibraryValidator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 Oracle 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: Oracle Corporation - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.jst.jsf.common.facet.libraryprovider.UserLibraryVersionValidator;
-
-
-/**
- * Checks that the JSF user library is version-compatible with the JSF facet.
- *
- * @author Debajit Adhikary
- *
- */
-public class JSFLibraryValidator extends UserLibraryVersionValidator
-{
- private static final String CLASS_NAME_IDENTIFYING_IMPLEMENTATION_JAR = "javax/faces/render/RenderKit.class"; //$NON-NLS-1$
-
-
- /**
- * Construct a validator for the JSF facet.
- */
- public JSFLibraryValidator ()
- {
- super(CLASS_NAME_IDENTIFYING_IMPLEMENTATION_JAR);
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtilFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtilFactory.java
deleted file mode 100644
index 7e9bcd2a9..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtilFactory.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jst.j2ee.model.IModelProvider;
-import org.eclipse.jst.j2ee.model.ModelProviderManager;
-import org.eclipse.jst.jsf.core.JSFVersion;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-
-/**
- * Creates a new JSFUtil for a particular JSF project version.
- *
- * @author cbateman
- *
- */
-public class JSFUtilFactory
-{
- /**
- * @param project
- * @return the jsf version of the project if it is valid JSF faceted
- * project or null otherwise.
- */
- public JSFUtils create(final IProject project)
- {
- final JSFVersion jsfVersion = JSFVersion.valueOfProject(project);
- if (jsfVersion != null)
- {
- return create(jsfVersion, ModelProviderManager.getModelProvider(project));
- }
- return null;
- }
- /**
- * @param version
- * @param modelProvider
- * @return the JSF utils object for the version or null if none.
- * @throw {@link IllegalArgumentException} if version is not related
- * to a JSF facet.
- */
- public JSFUtils create(final IProjectFacetVersion version, final IModelProvider modelProvider)
- {
- final JSFVersion jsfVersion = JSFVersion.valueOfFacetVersion(version);
- if (jsfVersion != null)
- {
- return create(jsfVersion, modelProvider);
- }
- return null;
- }
-
- /**
- * @param version
- * @param modelProvider
- * @return the JSF utils object for the version or null if none.
- */
- public JSFUtils create(final JSFVersion version, final IModelProvider modelProvider)
- {
- switch (version)
- {
- case V1_0:
- case V1_1:
- return new JSFUtils11(modelProvider);
- case V1_2:
- return new JSFUtils12(modelProvider);
- case V2_0:
- return new JSFUtils20(modelProvider);
- default:
- throw new IllegalArgumentException("Unknown version: "+version); //$NON-NLS-1$
- }
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java
deleted file mode 100644
index 22c3f72dc..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Oracle Corporation.
- * 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:
- * Gerry Kessler - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jst.j2ee.model.IModelProvider;
-import org.eclipse.jst.javaee.web.WebAppVersionType;
-import org.eclipse.jst.jsf.core.JSFVersion;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-import org.eclipse.jst.jsf.core.internal.Messages;
-import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
-import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-
-/**
- *
- */
-@SuppressWarnings("deprecation")
-public abstract class JSFUtils {
- /**
- * The default name for the Faces servlet
- */
- public static final String JSF_DEFAULT_SERVLET_NAME = "Faces Servlet"; //$NON-NLS-1$
- /**
- * The default name of the Faces servlet class
- */
- public static final String JSF_SERVLET_CLASS = "javax.faces.webapp.FacesServlet"; //$NON-NLS-1$
- /**
- * The name of the context parameter used for JSF configuration files
- */
- public static final String JSF_CONFIG_CONTEXT_PARAM = "javax.faces.CONFIG_FILES"; //$NON-NLS-1$
-
- /**
- * The name of the context parameter used for defining the default JSP file extension
- */
- public static final String JSF_DEFAULT_SUFFIX_CONTEXT_PARAM = "javax.faces.DEFAULT_SUFFIX"; //$NON-NLS-1$
-
- /**
- * The path to the default application configuration file
- */
- public static final String JSF_DEFAULT_CONFIG_PATH = "/WEB-INF/faces-config.xml"; //$NON-NLS-1$
-
- /**
- * Default URL mapping to faces servlet
- */
- public static final String JSF_DEFAULT_URL_MAPPING = "/faces/*"; //$NON-NLS-1$
-
- /**
- * the key for implementation libraries in persistent properties
- */
- public static final String PP_JSF_IMPLEMENTATION_LIBRARIES = "jsf.implementation.libraries"; //$NON-NLS-1$
- /**
- * the key for component libraries in persistent properties
- */
- public static final String PP_JSF_COMPONENT_LIBRARIES = "jsf.component.libraries"; //$NON-NLS-1$
- /**
- * the key for implementation type in persistent properties
- */
- public static final String PP_JSF_IMPLEMENTATION_TYPE = "jsf.implementation.type"; //$NON-NLS-1$
-
- private static final String DEFAULT_DEFAULT_MAPPING_SUFFIX = "jsp"; //$NON-NLS-1$
-
- private final JSFVersion _version;
- private final IModelProvider _modelProvider;
-
- /**
- * @param version
- * @param modelProvider
- */
- protected JSFUtils(final JSFVersion version, final IModelProvider modelProvider)
- {
- _version = version;
- _modelProvider = modelProvider;
- }
-
- /**
- * @return the jsf version that this instance is for.
- */
- public final JSFVersion getVersion()
- {
- return _version;
- }
-
- /**
- * @param config
- * @return servlet display name to use from wizard data model
- */
- protected final String getDisplayName(IDataModel config) {
- String displayName = config.getStringProperty(IJSFFacetInstallDataModelProperties.SERVLET_NAME);
- if (displayName == null || displayName.trim().length() == 0)
- displayName = JSF_DEFAULT_SERVLET_NAME;
- return displayName.trim();
- }
-
- /**
- * @param config
- * @return servlet display name to use from wizard data model
- */
- protected final String getServletClassname(IDataModel config) {
- String className = config.getStringProperty(IJSFFacetInstallDataModelProperties.SERVLET_CLASSNAME);
- if (className == null || className.trim().equals("")) //$NON-NLS-1$
- className = JSF_SERVLET_CLASS;
- return className.trim();
- }
-
- /**
- * @return IModelProvider
- */
- public final IModelProvider getModelProvider() {
- Object webAppObj = _modelProvider.getModelObject();
- if (webAppObj == null)
- {
- return null;
- }
- return _modelProvider;
- }
-
- /**
- * @param configPath
- */
- public final void createConfigFile(IPath configPath)
- {
- FileOutputStream os = null;
-// final String QUOTE = new String(new char[] { '"' });
- try {
- IPath dirPath = configPath.removeLastSegments(1);
- dirPath.toFile().mkdirs();
- File file = configPath.toFile();
- file.createNewFile();
- os = new FileOutputStream(file);
- printConfigFile(os);
- } catch (FileNotFoundException e) {
- JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorCreatingConfigFile, e);
- } catch (IOException e) {
- JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorCreatingConfigFile, e);
- } finally {
- if (os != null) {
- try {
- os.close();
- } catch (IOException e) {
- JSFCorePlugin.log(IStatus.ERROR, Messages.JSFUtils_ErrorClosingConfigFile, e);
- }
- }
- }
- }
-
- /**
- * @param out
- */
- protected final void printConfigFile(final OutputStream out)
- {
- PrintWriter pw = null;
- try
- {
- pw = new PrintWriter(out);
- doVersionSpecificConfigFile(pw);
- }
- finally
- {
- if (pw != null)
- {
- pw.close();
- }
- }
- }
-
- /**
- * @param pw
- */
- public abstract void doVersionSpecificConfigFile(final PrintWriter pw);
-
-
- /**
- * @param webAppObj
- * @return true if this going into a JavaEE (1.5 and later) or a J2EE (1.4 and earlier)
- * configured application.
- */
- public boolean isJavaEE(final Object webAppObj)
- {
- if (webAppObj instanceof org.eclipse.jst.javaee.web.WebApp)
- {
- org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp)webAppObj;
- return WebAppVersionType.VALUES.contains(webApp.getVersion());
- }
- return false;
- }
-
- /**
- * @param config
- * @return list of URL patterns from the datamodel
- */
- protected final List<String> getServletMappings(final IDataModel config) {
- final List<String> mappings = new ArrayList<String>();
- final String[] patterns = (String[])config.getProperty(IJSFFacetInstallDataModelProperties.SERVLET_URL_PATTERNS);
- if (patterns != null)
- {
- for (final String pattern : patterns)
- {
- mappings.add(pattern);
- }
- }
- return mappings;
- }
- /**
- * Does an update of the web application's config file.
- *
- * @param webApp must be WebApp of the appropriate type.
- * @param config
- * @throws ClassCastException if webApp is not the appropriate type.
- */
- public abstract void updateWebApp(Object webApp, IDataModel config);
-
-
- /**
- * Called on a facet uninstall to remove JSF related changes.
- * @param webApp
- */
- public abstract void rollbackWebApp(Object webApp);
-
-
- /**
- * @param webAppObj
- * @param resource
- * @param existingURL
- * @return the modified url path for the (possibly) jsf resource.
- */
- public abstract IPath getFileUrlPath(Object webAppObj, IResource resource,
- IPath existingURL);
-
- /**
- * @param fileExtension
- * @return true if the file extension is deemed to be for a JSF.
- */
- protected boolean isValidKnownExtension(String fileExtension) {
- if (fileExtension != null &&
- ( fileExtension.equalsIgnoreCase(DEFAULT_DEFAULT_MAPPING_SUFFIX) ||
- fileExtension.equalsIgnoreCase("jspx") || //$NON-NLS-1$
- fileExtension.equalsIgnoreCase("jsf") || //$NON-NLS-1$
- fileExtension.equalsIgnoreCase("xhtml"))) //$NON-NLS-1$
- return true;
-
- return false;
- }
-
-
- /**
- * @param resource
- * @return true if the resource is deemed to be a JSF page.
- */
- protected boolean isJSFPage(IResource resource) {
- // currently always return true.
- // need to find quick way of determining whether this is a JSF JSP Page
- return true;
- }
-
- /**
- * @return the default value for the default mapping suffix
- */
- protected String getDefaultDefaultSuffix()
- {
- return DEFAULT_DEFAULT_MAPPING_SUFFIX;
- }
-
- /**
- * @param name
- * @param value
- * @return the
- */
- protected final String calculateSuffix(final String name, final String value)
- {
- if (name != null
- && JSF_DEFAULT_SUFFIX_CONTEXT_PARAM.equals(name
- .trim()))
- {
- return normalizeSuffix(value != null ? value.trim() : null);
- }
- return null;
- }
-
- /**
- * @param defSuffix
- * @return the suffix value with any leading dot removed
- */
- protected final String normalizeSuffix(String defSuffix)
- {
- if (defSuffix != null && defSuffix.startsWith(".")) //$NON-NLS-1$
- {
- defSuffix = defSuffix.substring(1);
- }
- return defSuffix;
- }
-
- /**
- * Holds all the obsolete JSF Library stuff. This will go away post-Helios.
- * @author cbateman
- *
- */
- public static class JSFLibraryHandler
- {
- /**
- * Construct an array that hold paths for all JARs in a JSF library.
- *
- * @param jsfLib
- * @param logMissingJar true to log an error for each invalid JAR.
- * @return elements
- */
- public final IPath[] getJARPathforJSFLib(JSFLibrary jsfLib, boolean logMissingJar) {
- EList archiveFiles = jsfLib.getArchiveFiles();
- int numJars = archiveFiles.size();
- IPath[] elements = new IPath[numJars];
- ArchiveFile ar = null;
- for (int i= 0; i < numJars; i++) {
- ar = (ArchiveFile)archiveFiles.get(i);
- if ( !ar.exists() && logMissingJar ) {
- logErroronMissingJAR(jsfLib, ar);
- }
- elements[i] = new Path(((ArchiveFile)archiveFiles.get(i)).getResolvedSourceLocation()).makeAbsolute();
- }
- return elements;
- }
-
- private int numberofValidJar(EList archiveFiles) {
- int total = 0;
- final Iterator it = archiveFiles.iterator();
- ArchiveFile ar = null;
- while(it.hasNext()) {
- ar = (ArchiveFile) it.next();
- if (ar.exists()) {
- total++;
- }
- }
- return total;
- }
-
- private void logErroronMissingJAR(JSFLibrary jsfLib, ArchiveFile ar) {
- String msg = NLS.bind(Messages.JSFUtils_MissingJAR,
- ar.getName(),
- jsfLib.getLabel());
- JSFCorePlugin.log(IStatus.ERROR, msg);
- }
-
- /**
- * Construct an array that hold paths for all JARs in a JSF library.
- * However, archive files that no longer exist are filtered out.
- *
- * @param jsfLib
- * @param logMissingJar true to log an error for each invalid JAR.
- * @return elements
- */
- public final IPath[] getJARPathforJSFLibwFilterMissingJars(JSFLibrary jsfLib, boolean logMissingJar) {
- EList archiveFiles = jsfLib.getArchiveFiles();
- int numJars = numberofValidJar(archiveFiles);
- IPath[] elements = new IPath[numJars];
- ArchiveFile ar = null;
- int idxValidJar = 0;
- for (int i= 0; i < archiveFiles.size(); i++) {
- ar = (ArchiveFile)archiveFiles.get(i);
- if ( !ar.exists() ) {
- if (logMissingJar) {
- logErroronMissingJAR(jsfLib, ar);
- }
- } else {
- elements[idxValidJar] = new Path(((ArchiveFile)archiveFiles.get(i)).getResolvedSourceLocation()).makeAbsolute();
- idxValidJar++;
- }
- }
- return elements;
- }
-
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils11.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils11.java
deleted file mode 100644
index 7ba1a5878..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils11.java
+++ /dev/null
@@ -1,587 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Oracle Corporation.
- * 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:
- * Gerry Kessler - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.common.CommonFactory;
-import org.eclipse.jst.j2ee.common.ParamValue;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.model.IModelProvider;
-import org.eclipse.jst.j2ee.webapplication.ContextParam;
-import org.eclipse.jst.j2ee.webapplication.Servlet;
-import org.eclipse.jst.j2ee.webapplication.ServletMapping;
-import org.eclipse.jst.j2ee.webapplication.ServletType;
-import org.eclipse.jst.j2ee.webapplication.WebApp;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory;
-import org.eclipse.jst.jsf.core.JSFVersion;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-/**
- * Utility file for JSF model v1.1
- *
- * @author Gerry Kessler - Oracle
- */
-/*package use JSFUtilFactory*/ class JSFUtils11 extends JSFUtils {
-
- /**
- * @param modelProvider
- */
- protected JSFUtils11(final IModelProvider modelProvider)
- {
- super(JSFVersion.V1_1, modelProvider);
- }
-
- /**
- * @param webApp
- * as Object
- * @return Servlet - the JSF Servlet for the specified WebApp or null if not
- * present
- */
- private Servlet findJSFServlet(final WebApp webApp)
- {
- if (webApp == null)
- {
- return null;
- }
-
- final Iterator it = webApp.getServlets().iterator();
-
- while (it.hasNext())
- {
- final Servlet servlet = (Servlet) it.next();
- if (servlet != null && servlet.getWebType() != null)
- {
- if (servlet.getWebType().isServletType())
- {
- if (((ServletType) servlet.getWebType()).getClassName() != null
- && ((ServletType) servlet.getWebType())
- .getClassName().trim().equals(
- JSF_SERVLET_CLASS))
- {
- return servlet;
- }
- }
- }
- }
-
- // if we get to here then we have finished the loop
- // without finding the servlet we're looking for
- return null;
- }
-
- /**
- * Creates a stubbed JSF configuration file for specified JSF version and
- * path
- */
- @Override
- public void doVersionSpecificConfigFile(final PrintWriter pw)
- {
- final String QUOTE = new String(new char[]
- { '"' });
- pw.write("<?xml version=" + QUOTE + "1.0" + QUOTE + " encoding=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + QUOTE + "UTF-8" + QUOTE + "?>\n\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- pw.write("<!DOCTYPE faces-config PUBLIC\n"); //$NON-NLS-1$
- pw.write(" " //$NON-NLS-1$
- + QUOTE
- + "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" //$NON-NLS-1$
- + QUOTE + "\n"); //$NON-NLS-1$
- pw.write(" " + QUOTE //$NON-NLS-1$
- + "http://java.sun.com/dtd/web-facesconfig_1_1.dtd" //$NON-NLS-1$
- + QUOTE + ">\n\n"); //$NON-NLS-1$
-
- pw.write("<faces-config>\n\n"); //$NON-NLS-1$
- pw.write("</faces-config>\n"); //$NON-NLS-1$
- }
-
- /**
- * Creates servlet reference in WebApp if not present or updates servlet
- * name if found using the passed configuration.
- *
- * @param webApp
- * @param config
- * @param servlet
- * @return Servlet servlet - if passed servlet was null, will return created
- * servlet
- */
- private Servlet createOrUpdateServletRef(final WebApp webApp,
- final IDataModel config, Servlet servlet)
- {
-
- String displayName = getDisplayName(config);
- String className = getServletClassname(config);
-
- if (servlet == null)
- {
- // Create the servlet instance and set up the parameters from data
- // model
- servlet = WebapplicationFactory.eINSTANCE.createServlet();
- servlet.setServletName(displayName);
-
- ServletType servletType = WebapplicationFactory.eINSTANCE
- .createServletType();
- servletType.setClassName(className);
- servlet.setWebType(servletType);
- servlet.setLoadOnStartup(Integer.valueOf(1));
- // Add the servlet to the web application model
- webApp.getServlets().add(servlet);
- }
- else
- {
- // update
- updateServletMappings(webApp, servlet, displayName);
- servlet.setServletName(displayName);
- servlet.setLoadOnStartup(Integer.valueOf(1));
- }
- return servlet;
- }
-
- private void updateServletMappings(final WebApp webApp,
- final Servlet servlet, final String displayName)
- {
- List<ServletMapping> mappings = findServletMappings(webApp, servlet);
- for (ServletMapping map : mappings)
- {
- map.setName(displayName);
- }
-
- }
-
- private List<ServletMapping> findServletMappings(final WebApp webApp, final Servlet servlet) {
- String servletName = servlet.getServletName();
- servletName = servletName != null ? servletName.trim() : servletName;
- final List<ServletMapping> mappings = new ArrayList<ServletMapping>();
- final List<ServletMapping> allMappings = webApp.getServletMappings();
- for (int i=allMappings.size()-1;i>=0;--i){
- ServletMapping mapping = allMappings.get(i);
- if (mapping != null &&
- mapping.getServlet() != null &&
- mapping.getServlet().getServletName() != null &&
- mapping.getServlet().getServletName().trim().equals(servletName))
- mappings.add(mapping);
- }
- return mappings;
- }
-
- /**
- * Creates servlet-mappings for the servlet
- *
- * @param webApp
- * @param urlMappingList - list of string values to be used in url-pattern for servlet-mapping
- * @param servlet
- */
- private void setUpURLMappings(final WebApp webApp, final List urlMappingList,
- final Servlet servlet) {
- // Add mappings
- Iterator it = urlMappingList.iterator();
- while (it.hasNext()) {
- String pattern = (String) it.next();
- if (!(doesServletMappingExist(webApp, servlet, pattern))){
- ServletMapping mapping = WebapplicationFactory.eINSTANCE
- .createServletMapping();
- mapping.setServlet(servlet);
- mapping.setName(servlet.getServletName());
- mapping.setUrlPattern(pattern);
- webApp.getServletMappings().add(mapping);
- }
- }
- }
-
-
- private boolean doesServletMappingExist(final WebApp webApp, final Servlet servlet,
- final String pattern) {
-
- List mappings = webApp.getServletMappings();
- String servletName = servlet.getServletName();
- if (servletName != null)
- {
- final Iterator it = mappings.iterator();
- while(it.hasNext())
- {
- ServletMapping mapping = (ServletMapping) it.next();
- if (mapping != null &&
- mapping.getServlet() != null &&
- mapping.getServlet().getServletName() != null &&
- mapping.getServlet().getServletName().trim().equals(servletName) &&
- mapping.getUrlPattern() != null &&
- mapping.getUrlPattern().trim().equals(pattern)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Removes servlet-mappings for servlet using servlet-name.
- * @param webApp
- * @param servlet
- */
- private void removeURLMappings(final WebApp webApp, final Servlet servlet) {
- List mappings = webApp.getServletMappings();
- String servletName = servlet.getServletName();
- if (servletName != null) {
- for (int i=mappings.size()-1;i>=0;--i){
- ServletMapping mapping = (ServletMapping)mappings.get(i);
- if (mapping != null &&
- mapping.getServlet() != null &&
- mapping.getServlet().getServletName() != null &&
- mapping.getServlet().getServletName().trim()
- .equals(servletName)) {
- mappings.remove(mapping);
- }
- }
- }
- }
-
- /**
- * Creates or updates config file context-param in v 2.3 WebApp if non default configuration file is specified.
- * @param webApp
- * @param config
- */
- private void setupConfigFileContextParamForV2_3(final WebApp webApp,
- final IDataModel config) {
- // if not default name and location, then add context param
- ContextParam cp = null;
- ContextParam foundCP = null;
- boolean found = false;
- final String stringProperty =
- config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH);
- if (stringProperty != null &&
- !stringProperty.equals(JSF_DEFAULT_CONFIG_PATH)) {
- // check to see if present
- Iterator it = webApp.getContexts().iterator();
- while (it.hasNext()) {
- cp = (ContextParam) it.next();
- if (cp != null &&
- cp.getParamName() != null &&
- cp.getParamName().equals(JSF_CONFIG_CONTEXT_PARAM)) {
- foundCP = cp;
- found = true;
- }
- }
- if (!found) {
- cp = WebapplicationFactory.eINSTANCE.createContextParam();
- cp.setParamName(JSF_CONFIG_CONTEXT_PARAM);
- cp.setParamValue(stringProperty);
- webApp.getContexts().add(cp);
- } else {
- cp = foundCP;
- if (cp.getParamValue().indexOf(stringProperty) < 0) {
- String curVal = cp.getParamValue();
- String val = stringProperty;
- if (curVal != null && !"".equals(curVal.trim())) { //$NON-NLS-1$
- val = curVal + ",\n" + val; //$NON-NLS-1$
- }
- cp.setParamValue(val);
- }
- }
- }
- }
- /**
- * Creates or updates config file context-param in v2.4 WebApp if non default configuration file is specified.
- * @param webApp
- * @param config
- */
- private void setupConfigFileContextParamForV2_4(final WebApp webApp,
- final IDataModel config) {
- // if not default name and location, then add context param
- ParamValue foundCP = null;
- ParamValue cp = null;
- boolean found = false;
- final String stringProperty =
- config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH);
- if (stringProperty != null &&
- !stringProperty.equals(JSF_DEFAULT_CONFIG_PATH)) {
- // check to see if present
- Iterator it = webApp.getContextParams().iterator();
- while (it.hasNext()) {
- cp = (ParamValue) it.next();
- if (cp != null &&
- cp.getName() != null &&
- cp.getName().trim().equals(JSF_CONFIG_CONTEXT_PARAM)) {
- foundCP = cp;
- found = true;
- }
- }
- if (!found) {
- ParamValue pv = CommonFactory.eINSTANCE.createParamValue();
- pv.setName(JSF_CONFIG_CONTEXT_PARAM);
- pv.setValue(stringProperty);
- webApp.getContextParams().add(pv);
- } else {
- cp = foundCP;
- if (cp.getValue().indexOf(stringProperty) < 0) {
- String curVal = cp.getValue();
- String val = stringProperty;
- if (curVal != null && !"".equals(curVal.trim())) { //$NON-NLS-1$
- val = curVal + ",\n" + val; //$NON-NLS-1$
- }
- cp.setValue(val);
- }
- }
- }
- }
-
- /**
- * @param webApp
- * @return the default file extension from the context param. Default is
- * "jsp" if no context param.
- */
- private String getDefaultSuffix(final WebApp webApp)
- {
- String defaultSuffix = getDefaultDefaultSuffix();
- if ("2.3".equals(webApp.getVersion())) //$NON-NLS-1$
- {
- for (Iterator it = webApp.getContexts().iterator(); it.hasNext();)
- {
- ContextParam cp = (ContextParam) it.next();
- if (cp != null)
- {
- final String paramName = cp.getParamName();
- final String suffix = calculateSuffix(paramName, cp
- .getParamValue());
- if (suffix != null)
- {
- return suffix;
- }
- }
- }
- }
- else if ("2.4".equals(webApp.getVersion())) //$NON-NLS-1$
- {
- for (Iterator it = webApp.getContextParams().iterator(); it.hasNext();)
- {
- ParamValue cp = (ParamValue) it.next();
- if (cp != null)
- {
- final String paramName = cp.getName();
- final String suffix = calculateSuffix(paramName, cp
- .getValue());
- if (suffix != null)
- {
- return suffix;
- }
- }
- }
- }
- return defaultSuffix;
- }
-
- /**
- * @param map
- * @return prefix mapping. may return null.
- */
- private String getPrefixMapping(final ServletMapping map)
- {
- final String urlPattern = map.getUrlPattern();
- if (urlPattern != null && urlPattern.trim().length() != 0)
- {
- IPath extPath = new Path(urlPattern);
- if (extPath != null)
- {
- String ext = extPath.getFileExtension();
- if (ext == null)
- {
- String lastSeg = extPath.lastSegment();
- if (lastSeg != null && lastSeg.equals("*")) //$NON-NLS-1$
- {
- return extPath.removeLastSegments(1).toString();
- }
-
- return extPath.toString();
- }
- }
- }
- return null;
- }
-
- /**
- * @param map
- * @return extension from map. Will return null if file extension not found
- * in url patterns.
- */
- private String getFileExtensionFromMap(final ServletMapping map)
- {
- final String urlPattern = map.getUrlPattern();
- if (urlPattern != null
- && urlPattern.trim().length() != 0)
- {
- IPath extPath = new Path(map.getUrlPattern());
- if (extPath != null)
- {
- String ext = extPath.getFileExtension();
- if (ext != null && ext.trim().length() != 0)
- {
- return ext;
- }
- }
- }
- return null;
- }
-
- @Override
- public void updateWebApp(Object webApp, IDataModel config)
- {
- // create or update servlet ref
- Servlet servlet = findJSFServlet((WebApp) webApp);// check to see
- // if already
- // present
-
-
- servlet = createOrUpdateServletRef((WebApp) webApp, config, servlet);
-
- // init mappings
- final List listOfMappings = getServletMappings(config);
- setUpURLMappings((WebApp) webApp, listOfMappings, servlet);
-
- // setup context params
- setupContextParams((WebApp) webApp, config);
- }
-
- private void setupContextParams(WebApp webApp, final IDataModel config) {
- if (webApp.getVersionID() == J2EEVersionConstants.WEB_2_3_ID)//shouldn't have to do it this way, but that's the way it goes 119442
- {
- setupConfigFileContextParamForV2_3(webApp, config);
- }
- else if (webApp.getVersionID() == J2EEVersionConstants.WEB_2_4_ID)
- {
- setupConfigFileContextParamForV2_4(webApp, config);
- }
- else
- {
- throw new IllegalArgumentException("Invalid argument: "+webApp.getVersionID()); //$NON-NLS-1$
- }
- }
-
- @Override
- public void rollbackWebApp(Object webApp)
- {
- org.eclipse.jst.j2ee.webapplication.Servlet servlet = findJSFServlet((WebApp) webApp);
- if (servlet == null)
- {
- return;
- }
- // remove faces url mappings
- removeURLMappings((WebApp) webApp, servlet);
- // remove context params
- removeJSFContextParams((WebApp) webApp, servlet);
- // remove servlet
- removeJSFServlet((WebApp) webApp, servlet);
- }
-
- private void removeJSFContextParams(final org.eclipse.jst.j2ee.webapplication.WebApp webApp, final org.eclipse.jst.j2ee.webapplication.Servlet servlet) {
- if ("2.3".equals(webApp.getVersion())) //$NON-NLS-1$
- {
- Iterator it = webApp.getContexts().iterator();
- while (it.hasNext())
- {
- final ContextParam cp = (ContextParam) it.next();
- if (JSFUtils.JSF_CONFIG_CONTEXT_PARAM.equals(cp.getParamName()))
- {
- webApp.getContexts().remove(cp);
- break;
- }
- }
- }
- else if ("2.4".equals(webApp.getVersion())) //$NON-NLS-1$
- {
- Iterator it = webApp.getContextParams().iterator();
- while (it.hasNext())
- {
- ParamValue cp = (ParamValue) it.next();
- if (cp.getName().equals(JSFUtils.JSF_CONFIG_CONTEXT_PARAM)) {
- webApp.getContextParams().remove(cp);
- break;
- }
- }
- }
- // otherwise do nothing
- }
-
- private void removeJSFServlet(final org.eclipse.jst.j2ee.webapplication.WebApp webApp, final org.eclipse.jst.j2ee.webapplication.Servlet servlet) {
- webApp.getServlets().remove(servlet);
- }
-
- @Override
- public IPath getFileUrlPath(Object webAppObj, IResource resource,
- IPath existingURL)
- {
- if (webAppObj instanceof WebApp)
- {
- final WebApp webApp = (WebApp)webAppObj;
- final Servlet servlet = findJSFServlet(webApp);
- // if no faces servlet, do nothing
- if (servlet == null)
- {
- return null;
- }
-
- //if not a JSF page, do nothing
- if (!isJSFPage(resource))
- {
- return null;
- }
-
- final String defaultSuffix = getDefaultSuffix(webApp);
- //is the resource using default_suffix
- final String fileExtension = resource.getFileExtension();
- final boolean canUseExtensionMapping =
- fileExtension != null && fileExtension.equalsIgnoreCase(defaultSuffix);
-
- //if not using default extension and is not a known file extension, then we will abort
- if (! canUseExtensionMapping && ! isValidKnownExtension(fileExtension))
- {
- return null;
- }
-
- Iterator mappings = servlet.getMappings().iterator();
- ServletMapping map = null;
- String foundFileExtension = null;
- String foundPrefixMapping = null;
- while (mappings.hasNext())
- {
- map = (ServletMapping)mappings.next();
-
- foundFileExtension = getFileExtensionFromMap(map);
- if (foundFileExtension != null && canUseExtensionMapping)
- {
- return existingURL.removeFileExtension().addFileExtension(foundFileExtension);
- }
-
- if (foundPrefixMapping == null)
- {
- foundPrefixMapping = getPrefixMapping(map);
- }
- }
- if (foundPrefixMapping != null)
- {
- return new Path(foundPrefixMapping).append(existingURL);
- }
- if (! canUseExtensionMapping && foundFileExtension != null){
- //we could prompt user that this may not work...
- //for now we will return the extension mapping
- return existingURL.removeFileExtension().addFileExtension(foundFileExtension);
- }
-
- //we could, at this point, add a url mapping to the faces servlet, or prompt user that it may be a good idea to add one... ;-
- }
- return null;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils12.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils12.java
deleted file mode 100644
index 811a0eb87..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils12.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle Corporation.
- * 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:
- * Gerry Kessler - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.model.IModelProvider;
-import org.eclipse.jst.javaee.core.JavaeeFactory;
-import org.eclipse.jst.javaee.core.ParamValue;
-import org.eclipse.jst.javaee.core.UrlPatternType;
-import org.eclipse.jst.javaee.web.Servlet;
-import org.eclipse.jst.javaee.web.ServletMapping;
-import org.eclipse.jst.javaee.web.WebApp;
-import org.eclipse.jst.javaee.web.WebFactory;
-import org.eclipse.jst.jsf.core.JSFVersion;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-/**
- * Utility file for JSF v1.2 model
- *
- * @author Gerry Kessler - Oracle
- */
-/*package: use JSFUtilFactory*/ class JSFUtils12 extends JSFUtils {
-
- /**
- * @param modelProvider
- *
- */
- protected JSFUtils12(final IModelProvider modelProvider)
- {
- this(JSFVersion.V1_2, modelProvider);
- }
-
- /**
- * @param jsfVersion
- * @param modelProvider
- */
- protected JSFUtils12(final JSFVersion jsfVersion, final IModelProvider modelProvider)
- {
- super(jsfVersion, modelProvider);
- if (jsfVersion.compareTo(JSFVersion.V1_2) < 0)
- {
- throw new IllegalArgumentException(
- "JsfVersion must be at least 1.2"); //$NON-NLS-1$
- }
- }
-
- /**
- * @param webApp
- * @return Servlet - the JSF Servlet for the specified WebApp or null if not
- * present
- */
- private Servlet findJSFServlet(final WebApp webApp)
- {
- if (webApp == null)
- {
- return null;
- }
-
- for (final Servlet servlet : webApp.getServlets())
- {
- if (servlet != null &&
- servlet.getServletClass() != null
- && servlet.getServletClass().trim().equals(
- JSF_SERVLET_CLASS))
- {
- return servlet;
- }
- }
-
- // if we get to here then we have finished the loop
- // without finding the servlet we're looking for
- return null;
- }
-
- @Override
- public void doVersionSpecificConfigFile(PrintWriter pw)
- {
- final String QUOTE = new String(new char[]
- { '"' });
- final String schemaVersionString = getVersion().toString().replaceAll("\\.", "_"); //$NON-NLS-1$//$NON-NLS-2$
- pw.write("<?xml version=" + QUOTE + "1.0" + QUOTE + " encoding=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + QUOTE + "UTF-8" + QUOTE + "?>\n\n"); //$NON-NLS-1$ //$NON-NLS-2$
- pw.write("<faces-config\n"); //$NON-NLS-1$
- pw.write(" " + "xmlns=" + QUOTE //$NON-NLS-1$ //$NON-NLS-2$
- + "http://java.sun.com/xml/ns/javaee" + QUOTE + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- pw.write(" " + "xmlns:xsi=" + QUOTE //$NON-NLS-1$ //$NON-NLS-2$
- + "http://www.w3.org/2001/XMLSchema-instance" + QUOTE //$NON-NLS-1$
- + "\n"); //$NON-NLS-1$
- pw.write(" " //$NON-NLS-1$
- + "xsi:schemaLocation=" //$NON-NLS-1$
- + QUOTE
- + String.format("http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_%s.xsd", schemaVersionString) //$NON-NLS-1$
- + QUOTE + "\n"); //$NON-NLS-1$
- pw.write(" " + "version=" + QUOTE + getVersion().toString() + QUOTE + ">\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- pw.write("</faces-config>\n"); //$NON-NLS-1$
- }
-
- /**
- * Creates servlet reference in WebApp if not present or updates servlet name if found
- * using the passed configuration.
- *
- * @param webApp
- * @param config
- * @param servlet
- * @return Servlet servlet - if passed servlet was null, will return created servlet
- */
- private Servlet createOrUpdateServletRef(final WebApp webApp,
- final IDataModel config, Servlet servlet) {
-
- String displayName = getDisplayName(config);
- String className = getServletClassname(config);
-
- if (servlet == null){
- // Create the servlet instance and set up the parameters from data
- // model
- servlet = WebFactory.eINSTANCE.createServlet();
- servlet.setServletName(displayName);
- servlet.setServletClass(className);
- servlet.setLoadOnStartup(Integer.valueOf(1));
- // Add the servlet to the web application model
- webApp.getServlets().add(servlet);
-
- } else {
- updateServletMappings(webApp, servlet, displayName);
- servlet.setServletName(displayName);
- servlet.setLoadOnStartup(Integer.valueOf(1));
- }
- return servlet;
- }
-
- private void updateServletMappings(final WebApp webApp,
- final Servlet servlet, final String displayName)
- {
- // update mappings for new name
- ServletMapping mapping = findServletMapping(webApp, servlet);
- if (mapping != null)
- {
- mapping.setServletName(displayName);
- }
- }
-
- /**
- * Creates servlet-mappings for the servlet for 2.5 WebModules or greated
- *
- * @param webApp
- * @param urlMappingList
- * - list of string values to be used in url-pattern for
- * servlet-mapping
- * @param servlet
- */
- private void setUpURLMappings(final WebApp webApp,
- final List<String> urlMappingList, final Servlet servlet)
- {
-
- if (urlMappingList.size() > 0)
- {
- ServletMapping mapping = findServletMapping(webApp, servlet);
- if (mapping == null)
- {
- mapping = WebFactory.eINSTANCE
- .createServletMapping();
- mapping.setServletName(servlet.getServletName());
- webApp.getServletMappings().add(mapping);
- }
- // Add patterns
- for (final String pattern : urlMappingList)
- {
- if (!(doesServletMappingPatternExist(webApp, servlet, pattern)))
- {
- UrlPatternType urlPattern = JavaeeFactory.eINSTANCE
- .createUrlPatternType();
- urlPattern.setValue(pattern);
- mapping.getUrlPatterns().add(urlPattern);
- }
- }
- }
- }
-
- private ServletMapping findServletMapping(final WebApp webApp, final Servlet servlet) {
- for (Iterator it=webApp.getServletMappings().iterator();it.hasNext();){
- ServletMapping mapping = (ServletMapping)it.next();
- if (mapping.getServletName() != null &&
- servlet.getServletName() != null &&
- mapping.getServletName().trim().equals(servlet.getServletName().trim()))
- return mapping;
- }
- return null;
- }
-
- private boolean doesServletMappingPatternExist(final WebApp webApp,
- final Servlet servlet, final String pattern)
- {
- List<ServletMapping> mappings = webApp.getServletMappings();
- String servletName = servlet.getServletName();
- if (servletName != null)
- {
- servletName = servletName.trim();
- for (final ServletMapping mapping : mappings)
- {
- if (mapping != null &&
- mapping.getServletName() != null &&
- servletName.equals(mapping.getServletName().trim()))
- {
- for (final UrlPatternType urlPattern : mapping.getUrlPatterns())
- {
- String patternTypeValue = urlPattern.getValue();
- if (patternTypeValue != null
- && pattern.equals(patternTypeValue.trim()))
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Removes servlet-mappings for servlet using servlet-name for >= 2.5 WebModules.
- * @param webApp
- * @param servlet
- */
- private void removeURLMappings(final WebApp webApp, final Servlet servlet) {
- List mappings = webApp.getServletMappings();
- String servletName = servlet.getServletName();
- if (servletName != null) {
- servletName = servletName.trim();
- for (int i=mappings.size()-1;i>=0;--i){
- ServletMapping mapping = (ServletMapping)mappings.get(i);
- if (mapping != null &&
- mapping.getServletName() != null &&
- mapping.getServletName().trim()
- .equals(servletName)) {
- mappings.remove(mapping);
- }
- }
- }
- }
-
- /**
- * Creates or updates config file context-param in v2.5 WebApp if non default configuration file is specified.
- * @param webApp
- * @param config
- */
- private void setupConfigFileContextParamForV2_5(final org.eclipse.jst.javaee.web.WebApp webApp,
- final IDataModel config) {
- // if not default name and location, then add context param
- ParamValue foundCP = null;
- ParamValue cp = null;
- boolean found = false;
- String stringProperty = config.getStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH);
- if (stringProperty != null &&
- !stringProperty.equals(JSF_DEFAULT_CONFIG_PATH)) {
- // check to see if present
- Iterator it = webApp.getContextParams().iterator();
- while (it.hasNext()) {
- cp = (org.eclipse.jst.javaee.core.ParamValue) it.next();
- if (cp != null &&
- cp.getParamName()!= null &&
- cp.getParamName().trim().equals(JSF_CONFIG_CONTEXT_PARAM)) {
- foundCP = cp;
- found = true;
- }
- }
- if (!found) {
- ParamValue pv = JavaeeFactory.eINSTANCE.createParamValue();
- pv.setParamName(JSF_CONFIG_CONTEXT_PARAM);
- pv.setParamValue(stringProperty);
- webApp.getContextParams().add(pv);
- } else {
- cp = foundCP;
- if (cp.getParamValue().indexOf(stringProperty) < 0) {
- String curVal = cp.getParamValue();
- String val = stringProperty;
- if (curVal != null && !"".equals(curVal.trim())) { //$NON-NLS-1$
- val = curVal + ",\n" + val; //$NON-NLS-1$
- }
- cp.setParamValue(val);
- }
- }
- }
- }
-
- /**
- * @param webApp
- * @return the default file extension from the context param. Default is
- * "jsp" if no context param
- */
- private String getDefaultSuffix(final WebApp webApp)
- {
- String defaultSuffix = getDefaultDefaultSuffix();
- for (Iterator it = webApp.getContextParams().iterator(); it.hasNext();)
- {
- ParamValue cp = (ParamValue) it.next();
- if (cp != null)
- {
- final String paramName = cp.getParamName();
- final String suffix = calculateSuffix(paramName, cp
- .getParamValue());
- if (suffix != null)
- {
- return suffix;
- }
- }
- }
- return defaultSuffix;
- }
-
-
- /**
- * @param map
- * @return prefix mapping
- */
- private String getPrefixMapping(final ServletMapping map) {
- List urls = map.getUrlPatterns();
- for (Iterator it=urls.iterator();it.hasNext();){
- IPath extPath = new Path(((UrlPatternType)it.next()).getValue());
- if (extPath != null){
- String ext = extPath.getFileExtension();
- if (ext == null){
- String lastSeg = extPath.lastSegment();
- if (lastSeg.equals("*")) //$NON-NLS-1$
- {
- return extPath.removeLastSegments(1).toString();
- }
-
- return extPath.toString();
- }
- }
- }
- return null;
- }
-
- /**
- * @param map
- * @return extension from map. Will return null if file extension not found in url patterns.
- */
- private String getFileExtensionFromMap(final ServletMapping map) {
- List urls = map.getUrlPatterns();
- for (Iterator it=urls.iterator();it.hasNext();){
- IPath extPath = new Path(((UrlPatternType)it.next()).getValue());
- if (extPath != null){
- String ext = extPath.getFileExtension();
- if (ext != null && !ext.equals("")) //$NON-NLS-1$
- return ext;
- }
- }
- return null;
- }
-
- @Override
- public void updateWebApp(Object webApp, IDataModel config)
- {
- // create or update servlet ref
- Servlet servlet = findJSFServlet((WebApp)webApp);// check to see
- // if already
-
- servlet = createOrUpdateServletRef((WebApp) webApp, config, servlet);
-
- // init mappings
- final List listOfMappings = getServletMappings(config);
- setUpURLMappings((WebApp)webApp, listOfMappings, servlet);
-
- // setup context params
- setupConfigFileContextParamForV2_5((WebApp)webApp, config);
-
- }
-
-
- @Override
- public void rollbackWebApp(Object webApp)
- {
- Servlet servlet = findJSFServlet((WebApp) webApp);
- if (servlet == null)
- {
- return;
- }
- // remove faces url mappings
- removeURLMappings((WebApp)webApp, servlet);
- // remove context params
- removeJSFContextParams((WebApp)webApp, servlet);
- // remove servlet
- removeJSFServlet((WebApp)webApp, servlet);
- }
-
- private void removeJSFContextParams(final WebApp webApp, final Servlet servlet) {
- Iterator it = webApp.getContextParams().iterator();
- while (it.hasNext()) {
- ParamValue cp = (ParamValue) it.next();
- if (cp.getParamName().equals(JSFUtils.JSF_CONFIG_CONTEXT_PARAM)) {
- webApp.getContextParams().remove(cp);
- break;
- }
- }
- }
-
- private void removeJSFServlet(final WebApp webApp, final Servlet servlet) {
- webApp.getServlets().remove(servlet);
- }
-
- @Override
- public IPath getFileUrlPath(Object webAppObj, IResource resource,
- IPath existingURL)
- {
- if (webAppObj instanceof WebApp)
- {
- WebApp webApp = (WebApp) webAppObj;
- Servlet servlet = findJSFServlet(webApp);
- if (servlet == null)
- {// if no faces servlet, do nothing
- return null;
- }
-
- final String servletName = servlet.getServletName();
-
- // if not a JSF page, do nothing
- if (!isJSFPage(resource))
- {
- return null;
- }
-
- String defaultSuffix = getDefaultSuffix(webApp);
- // is the resource using default_suffix
- String fileExtension = resource.getFileExtension();
- boolean canUseExtensionMapping = fileExtension != null && fileExtension.equalsIgnoreCase(defaultSuffix);
-
- // if not using default extension and is not a known file extension,
- // then we will abort
- if (!canUseExtensionMapping
- && !isValidKnownExtension(resource.getFileExtension()))
- return null;
-
- String foundFileExtension = null;
- for (final ServletMapping map : webApp.getServletMappings())
- {
- if (map != null &&
- map.getServletName() != null &&
- map.getServletName().trim().equals(servletName.trim()))
- {
- foundFileExtension = getFileExtensionFromMap(map);
- if (foundFileExtension != null && canUseExtensionMapping)
- {
- return existingURL.removeFileExtension()
- .addFileExtension(foundFileExtension);
- }
-
- String foundPrefixMapping = getPrefixMapping(map);
- if (foundPrefixMapping != null)
- {
- return new Path(foundPrefixMapping).append(existingURL);
- }
- }
- }
-
- if (!canUseExtensionMapping && foundFileExtension != null)
- {
- // we could prompt user that this may not work...
- // for now we will return the extension mapping
- return existingURL.removeFileExtension().addFileExtension(
- foundFileExtension);
- }
-
- // we could, at this point, add a url mapping to the faces servlet,
- // or prompt user that it may be a good idea to add one... ;-
- }
- return null;
- }
-
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils20.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils20.java
deleted file mode 100644
index 28583ae1e..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JSFUtils20.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.jst.j2ee.model.IModelProvider;
-import org.eclipse.jst.jsf.core.JSFVersion;
-
-/**
- * JSF Utils instance for JSF 2.0.
- *
- * @author cbateman
- *
- */
-/* package: use JSFUtilFactory */class JSFUtils20 extends JSFUtils12
-{
- private static final String DEFAULT_DEFAULT_MAPPING_SUFFIX = "xhtml"; //$NON-NLS-1$
-
- /**
- * @param modelProvider
- */
- protected JSFUtils20(final IModelProvider modelProvider)
- {
- super(JSFVersion.V2_0, modelProvider);
- }
-
- @Override
- protected String getDefaultDefaultSuffix()
- {
- return DEFAULT_DEFAULT_MAPPING_SUFFIX;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JsfFacetConfigurationUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JsfFacetConfigurationUtil.java
deleted file mode 100644
index 21f725fda..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/JsfFacetConfigurationUtil.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Oracle Corporation.
- * 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:
- * Debajit Adhikary - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-
-
-/**
- * Utility class to provide an easy way to read the jsfFacetConfiguration
- * extension-point (org.eclipse.jst.jsf.core.jsfFacetConfiguration).
-
- * @author Debajit Adhikary (Oracle)
- *
- */
-public class JsfFacetConfigurationUtil
-{
- private static final String JSF_FACES_CONFIG_EXTENSION_ID = "jsfFacetConfiguration"; //$NON-NLS-1$
- private static final String DISABLED_ATTR_NAME = "disabled"; //$NON-NLS-1$
- private static final String TRUE_STRING = "true"; //$NON-NLS-1$
-
-
- /**
- * @return True if the disabled attribute is not set to "true".
- */
- public static boolean isJsfFacetConfigurationEnabled ()
- {
- return !isJsfFacetConfigurationDisabled();
- }
-
-
- /**
- * @return True if disabled="true" is set in the extension point.
- */
- public static boolean isJsfFacetConfigurationDisabled ()
- {
- IExtensionPoint jsfFacetConfigExtensionPoint = JSFCorePlugin.getDefault().getExtension(JSF_FACES_CONFIG_EXTENSION_ID);
- for (final IExtension extension : jsfFacetConfigExtensionPoint.getExtensions())
- {
- for (final IConfigurationElement configElement : extension.getConfigurationElements())
- {
- if (configElement != null && configElement.getName().equals(JSF_FACES_CONFIG_EXTENSION_ID))
- {
- final String attrValue = configElement.getAttribute(DISABLED_ATTR_NAME);
- if(attrValue != null)
- {
- return attrValue.equalsIgnoreCase(TRUE_STRING);
- }
- }
- }
- }
-
- return false;
- }
-
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/LegacyJSFLibraryProviderDetector.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/LegacyJSFLibraryProviderDetector.java
deleted file mode 100644
index 653d5c105..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/LegacyJSFLibraryProviderDetector.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2008 Oracle
- * 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 implementation and ongoing maintenance
- ******************************************************************************/
-
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
-import org.eclipse.jst.common.project.facet.core.libprov.LegacyLibraryProviderDetector;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderFramework;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil;
-import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
-import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-
-/**
- * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
- */
-@SuppressWarnings("deprecation")
-public final class LegacyJSFLibraryProviderDetector
-
- extends LegacyLibraryProviderDetector
-
-{
- private static final String LEGACY_JSF_LIBRARY_PROVIDER_ID
- = "legacy-jsf-library-provider"; //$NON-NLS-1$
-
- @Override
- public ILibraryProvider detect( final IProject project,
- final IProjectFacet facet )
- {
- try
- {
- final IJavaProject jproj = JavaCore.create( project );
-
- for( IClasspathEntry cpe : jproj.getRawClasspath() )
- {
- if( detect( cpe ) )
- {
- return LibraryProviderFramework.getProvider( LEGACY_JSF_LIBRARY_PROVIDER_ID );
- }
- }
- }
- catch( Exception e )
- {
- JSFCorePlugin.log( e, e.getMessage() );
- }
-
- return null;
- }
-
- /**
- * @param cpe
- * @return true if the classpath entry is detected
- */
- public static boolean detect( final IClasspathEntry cpe )
- {
- if( cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER )
- {
- final IPath path = cpe.getPath();
-
- if( isJSFLibraryContainer( path ) )
- {
- String libId = path.lastSegment();
- JSFLibrary ref = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getJSFLibraryByID(libId);
-
- if( ref != null && ref.isImplementation() )
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- private static boolean isJSFLibraryContainer(IPath path) {
- return path != null && path.segmentCount() == 2 && JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID.equals(path.segment(0));
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/LegacyJSFLibraryProviderUninstallOperation.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/LegacyJSFLibraryProviderUninstallOperation.java
deleted file mode 100644
index daf009a1a..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/project/facet/LegacyJSFLibraryProviderUninstallOperation.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2008 Oracle
- * 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 implementation and ongoing maintenance
- ******************************************************************************/
-
-package org.eclipse.jst.jsf.core.internal.project.facet;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperation;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
-
-/**
- * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
- */
-
-public final class LegacyJSFLibraryProviderUninstallOperation
-
- extends LibraryProviderOperation
-
-{
- public void execute( final LibraryProviderOperationConfig config,
- final IProgressMonitor monitor )
-
- throws CoreException
-
- {
- monitor.beginTask( "", 1 ); //$NON-NLS-1$
-
- try
- {
- final IProject project = config.getFacetedProject().getProject();
- final IJavaProject jproj = JavaCore.create( project );
- final List<IClasspathEntry> newcp = new ArrayList<IClasspathEntry>();
-
- for( IClasspathEntry cpe : jproj.getRawClasspath() )
- {
- if( ! LegacyJSFLibraryProviderDetector.detect( cpe ) )
- {
- newcp.add( cpe );
- }
- }
-
- final IClasspathEntry[] array = newcp.toArray( new IClasspathEntry[ newcp.size() ] );
- jproj.setRawClasspath( array, null );
-
- monitor.worked( 1 );
- }
- finally
- {
- monitor.done();
- }
- }
-
-}

Back to the top