org.eclipse.jst.j2ee.web_1.1.502.v201202090300

16:45:46.296 INFO  jd.cli.Main - Decompiling org.eclipse.jst.j2ee.web_1.1.502.v201202090300.jar
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import java.io.FileNotFoundException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
import org.eclipse.jst.j2ee.commonarchivecore.internal.File;

public class WTProjectStrategyUtils
{
  public static File findSourceFile(Archive archive, String file)
  {
    if (isClassFile(file)) {
      return findSourceFileForClass(archive, file);
    }
    try
    {
      if (!isOutputFile(file)) {
        return archive.getFile(file);
      }
    }
    catch (FileNotFoundException localFileNotFoundException) {}
    return null;
  }
  
  public static File findSourceFileForClass(Archive archive, String classFile)
  {
    IPath classFilePath = new Path(classFile);
    IPath sourceFilePath = classFilePath.removeFileExtension().addFileExtension("java");
    try
    {
      File file = archive.getFile(sourceFilePath.toString());
      if (file != null) {
        return file;
      }
    }
    catch (FileNotFoundException localFileNotFoundException1)
    {
      sourceFilePath = new Path("WEB-INF/lib/").append(sourceFilePath);
      try
      {
        File file = archive.getFile(sourceFilePath.toString());
        if (file != null) {
          return file;
        }
      }
      catch (FileNotFoundException localFileNotFoundException2) {}
    }
    return null;
  }
  
  public static boolean isClassFile(String uri)
  {
    return (uri.startsWith("WEB-INF/classes/")) && (uri.endsWith(".class"));
  }
  
  public static boolean isOutputFile(String uri)
  {
    return uri.startsWith("WEB-INF/classes/");
  }
  
  public static boolean isSourceFile(String uri)
  {
    if ((uri.startsWith("WEB-INF/")) && 
      (uri.endsWith(".java"))) {
      return true;
    }
    return false;
  }
  
  public static String makeRelative(String pathString, String relToPathString)
  {
    IPath relToPath = new Path(relToPathString);
    IPath path = new Path(pathString);
    if (path.matchingFirstSegments(relToPath) == relToPath.segmentCount()) {
      path = path.removeFirstSegments(relToPath.segmentCount());
    }
    return path.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WTProjectStrategyUtils
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import java.util.Set;
import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentExportDataModelProvider;
import org.eclipse.jst.j2ee.internal.archive.operations.JavaEEComponentExportOperation;
import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler;
import org.eclipse.jst.j2ee.web.datamodel.properties.IWebComponentExportDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;

public class WebComponentExportDataModelProvider
  extends J2EEComponentExportDataModelProvider
  implements IWebComponentExportDataModelProperties
{
  public IDataModelOperation getDefaultOperation()
  {
    return new JavaEEComponentExportOperation(model);
  }
  
  public Set getPropertyNames()
  {
    Set propertyNames = super.getPropertyNames();
    propertyNames.add("WebExportDataModel.EXCLUDE_COMPILE_JSP");
    return propertyNames;
  }
  
  public Object getDefaultProperty(String propertyName)
  {
    if ("WebExportDataModel.EXCLUDE_COMPILE_JSP".equals(propertyName)) {
      return Boolean.FALSE;
    }
    return super.getDefaultProperty(propertyName);
  }
  
  protected String getProjectType()
  {
    return "jst.web";
  }
  
  protected String getWrongComponentTypeString(String projectName)
  {
    return EARCreationResourceHandler.getString(EARCreationResourceHandler.NOT_A_WAR, new Object[] { projectName });
  }
  
  protected String getModuleExtension()
  {
    return ".war";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactExportOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;

/**
 * @deprecated
 */
public class WebComponentExportOperation
  extends J2EEArtifactExportOperation
{
  public WebComponentExportOperation() {}
  
  public WebComponentExportOperation(IDataModel model)
  {
    super(model);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportOperation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import org.eclipse.jst.j2ee.application.internal.operations.J2EEArtifactImportDataModelProvider;
import org.eclipse.jst.j2ee.application.internal.operations.J2EEUtilityJarImportOperationNew;
import org.eclipse.jst.j2ee.web.project.facet.WebFragmentFacetProjectCreationDataModelProvider;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;

class WebComponentImportDataModelProvider$1
  extends J2EEArtifactImportDataModelProvider
{
  WebComponentImportDataModelProvider$1(WebComponentImportDataModelProvider paramWebComponentImportDataModelProvider) {}
  
  protected IDataModel createJ2EEComponentCreationDataModel()
  {
    return DataModelFactory.createDataModel(new WebFragmentFacetProjectCreationDataModelProvider());
  }
  
  public IDataModelOperation getDefaultOperation()
  {
    return new J2EEUtilityJarImportOperationNew(model);
  }
  
  protected int getType()
  {
    return 0;
  }
  
  protected void refreshInterpretedSpecVersion()
  {
    updateJavaFacetVersion();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentImportDataModelProvider.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jst.j2ee.application.internal.operations.J2EEArtifactImportDataModelProvider;
import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentImportDataModelProvider;
import org.eclipse.jst.j2ee.application.internal.operations.J2EEUtilityJarImportDataModelProvider;
import org.eclipse.jst.j2ee.application.internal.operations.J2EEUtilityJarImportOperationNew;
import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper;
import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil;
import org.eclipse.jst.j2ee.internal.moduleextension.EarModuleManager;
import org.eclipse.jst.j2ee.internal.moduleextension.EjbModuleExtension;
import org.eclipse.jst.j2ee.web.datamodel.properties.IWebComponentImportDataModelProperties;
import org.eclipse.jst.j2ee.web.project.facet.WebFragmentFacetProjectCreationDataModelProvider;
import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap;
import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;

public final class WebComponentImportDataModelProvider
  extends J2EEComponentImportDataModelProvider
  implements IWebComponentImportDataModelProperties
{
  public Set getPropertyNames()
  {
    Set propertyNames = super.getPropertyNames();
    propertyNames.add("WARImportDataModel.WEB_LIB_MODELS");
    propertyNames.add("WARImportDataModel.WEB_LIB_ARCHIVES_SELECTED");
    propertyNames.add("IAddWebComponentToEnterpriseApplicationDataModelProperties.CONTEXT_ROOT");
    return propertyNames;
  }
  
  public Object getDefaultProperty(String propertyName)
  {
    if ((propertyName.equals("WARImportDataModel.WEB_LIB_MODELS")) || (propertyName.equals("WARImportDataModel.WEB_LIB_ARCHIVES_SELECTED"))) {
      return Collections.EMPTY_LIST;
    }
    return super.getDefaultProperty(propertyName);
  }
  
  protected int getType()
  {
    return 4;
  }
  
  protected void handleUnknownType(JavaEEQuickPeek jqp)
  {
    jqp.setType(4);
    jqp.setVersion(30);
    jqp.setJavaEEVersion(60);
  }
  
  protected IStatus validateModuleType()
  {
    if (getArchiveWrapper().getJavaEEQuickPeek().getType() == 4) {
      return OK_STATUS;
    }
    return WTPCommonPlugin.createErrorStatus(WTPCommonPlugin.getResourceString("Temp String for none WARFile"));
  }
  
  public boolean propertySet(String propertyName, Object propertyValue)
  {
    super.propertySet(propertyName, propertyValue);
    if (propertyName.equals("IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER"))
    {
      if (getArchiveWrapper() != null)
      {
        refreshInterpretedSpecVersion();
        model.notifyPropertyChange("IJ2EEComponentImportDataModelProperties.PROJECT_NAME", 4);
      }
      ArchiveWrapper archiveWrapper = (ArchiveWrapper)propertyValue;
      if (archiveWrapper != null)
      {
        List<ArchiveWrapper> libs = archiveWrapper.getWebLibs();
        List nestedModels = new ArrayList();
        for (ArchiveWrapper libWrapper : libs)
        {
          IDataModel localModel = null;
          JavaEEQuickPeek jqp = libWrapper.getJavaEEQuickPeek();
          if (jqp.getType() == 6) {
            localModel = DataModelFactory.createDataModel(new J2EEArtifactImportDataModelProvider()
            {
              protected IDataModel createJ2EEComponentCreationDataModel()
              {
                return DataModelFactory.createDataModel(new WebFragmentFacetProjectCreationDataModelProvider());
              }
              
              public IDataModelOperation getDefaultOperation()
              {
                return new J2EEUtilityJarImportOperationNew(model);
              }
              
              protected int getType()
              {
                return 0;
              }
              
              protected void refreshInterpretedSpecVersion()
              {
                updateJavaFacetVersion();
              }
            });
          } else if ((jqp.getType() == 0) && (EarModuleManager.hasEJBModuleExtension())) {
            localModel = EarModuleManager.getEJBModuleExtension().createImportDataModel();
          } else {
            localModel = DataModelFactory.createDataModel(new J2EEUtilityJarImportDataModelProvider());
          }
          localModel.setProperty("IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER", libWrapper);
          localModel.setProperty("IFacetProjectCreationDataModelProperties.FACET_RUNTIME", getProperty("IFacetProjectCreationDataModelProperties.FACET_RUNTIME"));
          IDataModel facetDataModel = localModel.getNestedModel("IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION");
          facetDataModel.setBooleanProperty("IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR", false);
          nestedModels.add(localModel);
        }
        setProperty("WARImportDataModel.WEB_LIB_MODELS", nestedModels);
      }
    }
    else if (propertyName.equals("IAddWebComponentToEnterpriseApplicationDataModelProperties.CONTEXT_ROOT"))
    {
      IDataModel creationModel = model.getNestedModel("IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION");
      IFacetProjectCreationDataModelProperties.FacetDataModelMap map = (IFacetProjectCreationDataModelProperties.FacetDataModelMap)creationModel.getProperty("IFacetProjectCreationDataModelProperties.FACET_DM_MAP");
      IDataModel webFacetDataModel = map.getFacetDataModel("jst.web");
      webFacetDataModel.setStringProperty("IWebFacetInstallDataModelProperties.CONTEXT_ROOT", (String)propertyValue);
    }
    else if (propertyName.equals("WARImportDataModel.WEB_LIB_ARCHIVES_SELECTED"))
    {
      validateLibModelRuntimes();
    }
    return true;
  }
  
  protected void refreshInterpretedSpecVersion()
  {
    IDataModel moduleDM = model.getNestedModel("IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION");
    IFacetProjectCreationDataModelProperties.FacetDataModelMap map = (IFacetProjectCreationDataModelProperties.FacetDataModelMap)moduleDM.getProperty("IFacetProjectCreationDataModelProperties.FACET_DM_MAP");
    IDataModel webFacetDataModel = map.getFacetDataModel("jst.web");
    int version = getInterpretedSpecVersion(getArchiveWrapper()).getVersion();
    String versionText = J2EEVersionUtil.getServletTextVersion(version);
    webFacetDataModel.setStringProperty("IFacetDataModelProperties.FACET_VERSION_STR", versionText);
    updateWorkingCopyFacetVersion(moduleDM, webFacetDataModel);
    updateJavaFacetVersion();
  }
  
  public IStatus validate(String propertyName)
  {
    if ("IJ2EEArtifactImportDataModelProperties.FACET_RUNTIME".equals(propertyName))
    {
      super.validate(propertyName);
      return validateLibModelRuntimes();
    }
    return super.validate(propertyName);
  }
  
  private IStatus validateLibModelRuntimes()
  {
    List libArchives = (List)getProperty("WARImportDataModel.WEB_LIB_ARCHIVES_SELECTED");
    List libModels = (List)getProperty("WARImportDataModel.WEB_LIB_MODELS");
    IStatus status = OK_STATUS;
    for (int i = 0; i < libModels.size(); i++)
    {
      IDataModel libModel = (IDataModel)libModels.get(i);
      if (libArchives.contains(libModel.getProperty("IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER"))) {
        status = libModel.validateProperty("IJ2EEArtifactImportDataModelProperties.FACET_RUNTIME");
      }
      if (!status.isOK()) {
        return status;
      }
    }
    return status;
  }
  
  protected IDataModel createJ2EEComponentCreationDataModel()
  {
    return DataModelFactory.createDataModel(new WebFacetProjectCreationDataModelProvider());
  }
  
  public IDataModelOperation getDefaultOperation()
  {
    return new WebComponentImportOperation(model);
  }
  
  public void init()
  {
    super.init();
    IDataModel componentCreationDM = model.getNestedModel("IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION");
    IFacetProjectCreationDataModelProperties.FacetDataModelMap map = (IFacetProjectCreationDataModelProperties.FacetDataModelMap)componentCreationDM.getProperty("IFacetProjectCreationDataModelProperties.FACET_DM_MAP");
    IDataModel webFacet = map.getFacetDataModel("jst.web");
    webFacet.setBooleanProperty("IJ2EEFacetInstallDataModelProperties.GENERATE_DD", false);
  }
  
  public void propertyChanged(DataModelEvent event)
  {
    super.propertyChanged(event);
    if ((event.getPropertyName().equals("IFacetProjectCreationDataModelProperties.FACET_RUNTIME")) && (event.getDataModel() == model.getNestedModel("IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION")))
    {
      Object propertyValue = event.getProperty();
      IDataModel nestedModel = null;
      List projectModels = (List)getProperty("WARImportDataModel.WEB_LIB_MODELS");
      for (int i = 0; i < projectModels.size(); i++)
      {
        nestedModel = (IDataModel)projectModels.get(i);
        nestedModel.setProperty("IFacetProjectCreationDataModelProperties.FACET_RUNTIME", propertyValue);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentImportDataModelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper;
import org.eclipse.jst.j2ee.internal.archive.ComponentArchiveSaveAdapter;
import org.eclipse.jst.j2ee.internal.archive.WebComponentArchiveSaveAdapter;
import org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactImportOperation;
import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin;
import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit;
import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;

public class WebComponentImportOperation
  extends J2EEArtifactImportOperation
{
  public WebComponentImportOperation(IDataModel model)
  {
    super(model);
  }
  
  protected final int LINK_COMPONENTS_WORK = 10;
  protected final int LIB_FOLDER_WORK = 2;
  
  protected int computeTotalWork()
  {
    int baseWork = super.computeTotalWork() + 2;
    List selectedLibs = (List)model.getProperty("WARImportDataModel.WEB_LIB_ARCHIVES_SELECTED");
    List libProjects = (List)model.getProperty("WARImportDataModel.WEB_LIB_MODELS");
    IDataModel importModel = null;
    ArchiveWrapper libArchive = null;
    for (int i = 0; (libProjects != null) && (i < libProjects.size()); i++)
    {
      importModel = (IDataModel)libProjects.get(i);
      libArchive = (ArchiveWrapper)importModel.getProperty("IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER");
      if (selectedLibs.contains(libArchive)) {
        baseWork += 40 + libArchive.getSize();
      }
    }
    return baseWork;
  }
  
  protected void doExecute(IProgressMonitor monitor)
    throws ExecutionException
  {
    super.doExecute(monitor);
    IVirtualFolder libFolder = virtualComponent.getRootFolder().getFolder(WebArtifactEdit.WEBLIB);
    if (!libFolder.exists()) {
      try
      {
        libFolder.create(1, new SubProgressMonitor(monitor, 2));
      }
      catch (CoreException e)
      {
        WebPlugin.logError(e);
      }
    } else {
      monitor.worked(2);
    }
    try
    {
      importWebLibraryProjects(monitor);
    }
    catch (InvocationTargetException e)
    {
      WebPlugin.logError(e);
    }
    catch (InterruptedException e)
    {
      WebPlugin.logError(e);
    }
  }
  
  private void importWebLibraryProjects(IProgressMonitor monitor)
    throws InvocationTargetException, InterruptedException, ExecutionException
  {
    List<ArchiveWrapper> selectedLibs = (List)model.getProperty("WARImportDataModel.WEB_LIB_ARCHIVES_SELECTED");
    List<Object> selectedLibsUnderlyingArchives = new ArrayList();
    for (ArchiveWrapper lib : selectedLibs) {
      selectedLibsUnderlyingArchives.add(lib.getUnderLyingArchive());
    }
    List<IDataModel> libProjects = (List)model.getProperty("WARImportDataModel.WEB_LIB_MODELS");
    IDataModel importModel = null;
    IVirtualComponent nestedComponent = null;
    ArchiveWrapper libArchive = null;
    List targetComponents = new ArrayList();
    Map compToURIMap = new HashMap();
    for (int i = 0; (libProjects != null) && (i < libProjects.size()); i++)
    {
      importModel = (IDataModel)libProjects.get(i);
      libArchive = (ArchiveWrapper)importModel.getProperty("IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER");
      if (selectedLibsUnderlyingArchives.contains(libArchive.getUnderLyingArchive()))
      {
        importModel.getDefaultOperation().execute(new SubProgressMonitor(monitor, 30 + libArchive.getSize()), info);
        nestedComponent = (IVirtualComponent)importModel.getProperty("IJ2EEComponentImportDataModelProperties.COMPONENT");
        targetComponents.add(nestedComponent);
        String archiveURI = libArchive.getPath().lastSegment();
        compToURIMap.put(nestedComponent, archiveURI);
      }
    }
    if (targetComponents.size() > 0)
    {
      IDataModel createRefComponentsModel = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider());
      createRefComponentsModel.setProperty("ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT", virtualComponent);
      createRefComponentsModel.setProperty("ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_DEPLOY_PATH", "/WEB-INF/lib/");
      createRefComponentsModel.setProperty("ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT", targetComponents);
      createRefComponentsModel.setProperty("ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP", compToURIMap);
      createRefComponentsModel.getDefaultOperation().execute(new SubProgressMonitor(monitor, 10 * targetComponents.size()), info);
    }
  }
  
  protected ComponentArchiveSaveAdapter getArchiveSaveAdapter(IVirtualComponent virtualComponent)
  {
    return new WebComponentArchiveSaveAdapter(virtualComponent);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentImportOperation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import java.io.File;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent;
import org.eclipse.jst.j2ee.internal.archive.operations.ComponentLoadStrategyImpl;
import org.eclipse.jst.j2ee.internal.archive.operations.ComponentLoadStrategyImpl.FilesHolder;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler;
import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin;
import org.eclipse.jst.j2ee.project.WebUtilities;
import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit;
import org.eclipse.wst.common.componentcore.ArtifactEdit;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;

public class WebComponentLoadStrategyImpl
  extends ComponentLoadStrategyImpl
{
  public WebComponentLoadStrategyImpl(IVirtualComponent vComponent)
  {
    super(vComponent);
  }
  
  public WebComponentLoadStrategyImpl(IVirtualComponent vComponent, boolean includeClasspathComponents)
  {
    super(vComponent, includeClasspathComponents);
  }
  
  public List getFiles()
  {
    super.getFiles();
    addLooseLibJARsToFiles();
    if (includeClasspathComponents) {
      addMappedClassFolders(IClasspathDependencyConstants.WEB_INF_CLASSES_PATH);
    }
    return filesHolder.getFiles();
  }
  
  public IVirtualReference[] getLibModules()
  {
    return WebUtilities.getLibModules(getComponent());
  }
  
  public void addLooseLibJARsToFiles()
  {
    IVirtualReference[] libModules = getLibModules();
    for (int i = 0; i < libModules.length; i++)
    {
      IVirtualReference iLibModule = libModules[i];
      IVirtualComponent looseComponent = iLibModule.getReferencedComponent();
      if (looseComponent.isBinary())
      {
        File diskFile = (File)looseComponent.getAdapter(File.class);
        String uri = iLibModule.getRuntimePath().makeRelative().toString() + "/" + diskFile.getName();
        addExternalFile(uri, diskFile);
      }
      else
      {
        String name = null;
        String archiveName = iLibModule.getArchiveName();
        if ((archiveName != null) && (archiveName.length() > 0)) {
          name = archiveName;
        } else {
          name = looseComponent.getName() + ".jar";
        }
        String prefix = iLibModule.getRuntimePath().makeRelative().toString();
        if ((prefix.length() > 0) && (prefix.charAt(prefix.length() - 1) != '/')) {
          prefix = prefix + "/";
        }
        addClasspathComponentDependencies(looseComponent);
        
        String uri = prefix + name;
        try
        {
          Archive utilJAR = J2EEProjectUtilities.asArchive(uri, looseComponent.getProject(), isExportSource());
          if (utilJAR != null) {
            filesHolder.addFile(utilJAR);
          }
        }
        catch (OpenFailureException oe)
        {
          String message = ProjectSupportResourceHandler.getString(ProjectSupportResourceHandler.UNABLE_TO_LOAD_MODULE_ERROR_, new Object[] { uri, getComponent().getProject().getName(), oe.getConcatenatedMessages() });
          WebPlugin.logError(message);
        }
      }
    }
  }
  
  protected synchronized ArtifactEdit getArtifactEditForRead()
  {
    if (artifactEdit == null) {
      artifactEdit = WebArtifactEdit.getWebArtifactEditForRead(vComponent);
    }
    return artifactEdit;
  }
  
  private void addClasspathComponentDependencies(IVirtualComponent referencedComponent)
  {
    if ((includeClasspathComponents) && ((referencedComponent instanceof J2EEModuleVirtualComponent)))
    {
      IVirtualReference[] cpRefs = ((J2EEModuleVirtualComponent)referencedComponent).getJavaClasspathReferences();
      for (int j = 0; j < cpRefs.length; j++)
      {
        IVirtualReference ref = cpRefs[j];
        IPath runtimePath = ref.getRuntimePath();
        if ((ref.getReferencedComponent().isBinary()) && 
          (runtimePath.equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH)))
        {
          File cpEntryFile = (File)ref.getReferencedComponent().getAdapter(File.class);
          addExternalFile("WEB-INF/lib/" + ref.getArchiveName(), cpEntryFile);
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentLoadStrategyImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
import org.eclipse.jst.j2ee.internal.archive.operations.J2EEComponentSaveStrategyImpl;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;

/**
 * @deprecated
 */
public class WebComponentSaveStrategyImpl
  extends J2EEComponentSaveStrategyImpl
{
  protected Map nonStandardSourceFiles;
  
  public WebComponentSaveStrategyImpl(IVirtualComponent vComponent)
  {
    super(vComponent);
  }
  
  /**
   * @deprecated
   */
  protected boolean operationHandlesNested(Archive archive)
  {
    return !shouldLinkAsComponentRef(archive);
  }
  
  protected boolean shouldAddImportedClassesToClasspath()
  {
    return false;
  }
  
  protected String getImportedClassesURI(File aFile)
  {
    String uri = aFile.getURI();
    return WTProjectStrategyUtils.makeRelative(uri, "WEB-INF/classes/");
  }
  
  protected IPath getImportedClassesRuntimePath()
  {
    return new Path("/WEB-INF/classes/");
  }
  
  protected IPath getOutputPathForFile(File aFile)
  {
    if ((nonStandardSourceFiles != null) && (nonStandardSourceFiles.containsKey(aFile)))
    {
      IVirtualFolder rootFolder = vComponent.getRootFolder();
      IVirtualFile vFile = rootFolder.getFile((String)nonStandardSourceFiles.get(aFile));
      IFile iFile = vFile.getUnderlyingFile();
      return iFile.getProjectRelativePath();
    }
    return super.getOutputPathForFile(aFile);
  }
  
  protected boolean isClassWithoutSource(File aFile)
  {
    String javaUri = ArchiveUtil.classUriToJavaUri(aFile.getURI());
    if (javaUri == null) {
      return false;
    }
    if (archive.containsFile(javaUri)) {
      return false;
    }
    String jspUri = javaUri.substring(0, javaUri.indexOf(".java"));
    int lastSlash = jspUri.lastIndexOf('/');
    int _index = lastSlash == -1 ? "WEB-INF/classes/".length() : lastSlash + 1;
    if (jspUri.charAt(_index) == '_')
    {
      jspUri = jspUri.substring("WEB-INF/classes/".length(), _index) + jspUri.substring(_index + 1) + ".jsp";
      if (archive.containsFile(jspUri)) {
        return false;
      }
    }
    File sourceFile = ((WARFile)archive).getSourceFile(aFile);
    if (sourceFile == null) {
      return true;
    }
    if (nonStandardSourceFiles == null) {
      nonStandardSourceFiles = new HashMap();
    }
    if (!nonStandardSourceFiles.containsKey(sourceFile)) {
      nonStandardSourceFiles.put(sourceFile, javaUri);
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentSaveStrategyImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;

class WebFacetProjectCreationDataModelProvider$1
  implements IDataModelListener
{
  WebFacetProjectCreationDataModelProvider$1(WebFacetProjectCreationDataModelProvider paramWebFacetProjectCreationDataModelProvider) {}
  
  public void propertyChanged(DataModelEvent event)
  {
    if ("IJ2EEFacetInstallDataModelProperties.EAR_PROJECT_NAME".equals(event.getPropertyName()))
    {
      if (WebFacetProjectCreationDataModelProvider.access$0(this$0, "IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME")) {
        WebFacetProjectCreationDataModelProvider.access$1(this$0, "IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME", event.getProperty());
      } else {
        WebFacetProjectCreationDataModelProvider.access$2(this$0).notifyPropertyChange("IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME", 2);
      }
    }
    else if ("IJ2EEFacetInstallDataModelProperties.ADD_TO_EAR".equals(event.getPropertyName())) {
      WebFacetProjectCreationDataModelProvider.access$1(this$0, "IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR", event.getProperty());
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.archive.operations;

import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.jst.common.project.facet.JavaFacetUtils;
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences;
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
import org.eclipse.jst.j2ee.project.facet.J2EEFacetProjectCreationDataModelProvider;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap;
import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;

public class WebFacetProjectCreationDataModelProvider
  extends J2EEFacetProjectCreationDataModelProvider
{
  public void init()
  {
    super.init();
    
    Collection<IProjectFacet> requiredFacets = new ArrayList();
    requiredFacets.add(JavaFacetUtils.JAVA_FACET);
    requiredFacets.add(IJ2EEFacetConstants.DYNAMIC_WEB_FACET);
    setProperty("FacetProjectCreationDataModelProvider.REQUIRED_FACETS_COLLECTION", requiredFacets);
    
    IFacetProjectCreationDataModelProperties.FacetDataModelMap map = (IFacetProjectCreationDataModelProperties.FacetDataModelMap)getProperty("IFacetProjectCreationDataModelProperties.FACET_DM_MAP");
    IDataModel javaFacet = map.getFacetDataModel(JavaFacetUtils.JAVA_FACET.getId());
    IDataModel webFacet = map.getFacetDataModel(IJ2EEFacetConstants.DYNAMIC_WEB_FACET.getId());
    
    String webSrc = webFacet.getStringProperty("IWebFacetInstallDataModelProperties.SOURCE_FOLDER");
    javaFacet.setProperty("IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME", webSrc);
    javaFacet.setProperty("IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME", 
      J2EEPlugin.getDefault().getJ2EEPreferences().getString("dynWebOutput"));
    
    webFacet.addListener(new IDataModelListener()
    {
      public void propertyChanged(DataModelEvent event)
      {
        if ("IJ2EEFacetInstallDataModelProperties.EAR_PROJECT_NAME".equals(event.getPropertyName()))
        {
          if (isPropertySet("IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME")) {
            setProperty("IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME", event.getProperty());
          } else {
            model.notifyPropertyChange("IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME", 2);
          }
        }
        else if ("IJ2EEFacetInstallDataModelProperties.ADD_TO_EAR".equals(event.getPropertyName())) {
          setProperty("IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR", event.getProperty());
        }
      }
    });
  }
  
  public boolean propertySet(String propertyName, Object propertyValue)
  {
    if (propertyName.equals("IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI"))
    {
      IFacetProjectCreationDataModelProperties.FacetDataModelMap map = (IFacetProjectCreationDataModelProperties.FacetDataModelMap)getProperty("IFacetProjectCreationDataModelProperties.FACET_DM_MAP");
      IDataModel webFacet = map.getFacetDataModel("jst.web");
      webFacet.setProperty("IJ2EEModuleFacetInstallDataModelProperties.MODULE_URI", propertyValue);
    }
    return super.propertySet(propertyName, propertyValue);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.classpath;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

class WebAppLibrariesContainer$1
  extends Job
{
  WebAppLibrariesContainer$1(WebAppLibrariesContainer paramWebAppLibrariesContainer, String $anonymous0)
  {
    super($anonymous0);
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    this$0.refresh(false);
    return Status.OK_STATUS;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.classpath.WebAppLibrariesContainer.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.classpath;

import org.eclipse.osgi.util.NLS;

final class WebAppLibrariesContainer$Resources
  extends NLS
{
  public static String label;
  public static String labelWithProject;
  public static String verify;
  
  static
  {
    initializeMessages(WebAppLibrariesContainer.class.getName(), 
      Resources.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.internal.web.classpath.WebAppLibrariesContainer.Resources
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.internal.web.classpath;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IClasspathContainer;
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.internal.modulecore.ClasspathContainerVirtualComponent;
import org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer;
import org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer.PathType;
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.componentcore.internal.builder.IDependencyGraph;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;

public final class WebAppLibrariesContainer
  extends FlexibleProjectContainer
{
  private WebAppLibrariesStore.RestoreState restoreState;
  private static final IPath[] paths = { new Path("WEB-INF/lib"), 
    new Path("WEB-INF/classes") };
  private static final FlexibleProjectContainer.PathType[] types = { FlexibleProjectContainer.PathType.LIB_DIRECTORY, FlexibleProjectContainer.PathType.CLASSES_DIRECTORY };
  public static final String CONTAINER_ID = "org.eclipse.jst.j2ee.internal.web.container";
  
  public WebAppLibrariesContainer(IPath path, IJavaProject jproject)
  {
    super(path, jproject, getProject(path, jproject), paths, types);
    boolean needToVerify = false;
    if (restoreState != null) {
      synchronized (restoreState)
      {
        needToVerify = restoreState.needToVerify;
        restoreState.needToVerify = false;
      }
    }
    if (needToVerify)
    {
      Job verifyJob = new Job(Resources.verify)
      {
        protected IStatus run(IProgressMonitor monitor)
        {
          refresh(false);
          return Status.OK_STATUS;
        }
      };
      verifyJob.setSystem(true);
      verifyJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
      verifyJob.schedule();
    }
  }
  
  public String getDescription()
  {
    if (owner.getProject() != project) {
      return NLS.bind(Resources.labelWithProject, project.getName());
    }
    return Resources.label;
  }
  
  public void install()
  {
    IJavaProject[] projects = { owner };
    IClasspathContainer[] conts = { this };
    try
    {
      JavaCore.setClasspathContainer(path, projects, conts, null);
    }
    catch (JavaModelException e)
    {
      WebPlugin.log(e);
    }
  }
  
  public boolean isOutOfDate()
  {
    if (IDependencyGraph.INSTANCE.isStale())
    {
      J2EEComponentClasspathUpdater.getInstance().queueUpdate(owner.getProject());
      return true;
    }
    List currentEntries = computeClasspathEntries(false);
    boolean outOfDate = !entries.equals(currentEntries);
    if (outOfDate) {
      WebAppLibrariesStore.flush(project.getName());
    }
    return outOfDate;
  }
  
  public void refresh(boolean forceUpdate)
  {
    if (IDependencyGraph.INSTANC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd