org.eclipse.wst.web_1.1.501.v201201190400

= owner;
  }
  
  protected void initializeDefaultPreferences()
  {
    getPreferences().setDefault("org.eclipse.jst.j2ee.preference.staticWebContentName", "WebContent");
  }
  
  public String getStaticWebContentFolderName()
  {
    return getPreferences().getString("org.eclipse.jst.j2ee.preference.staticWebContentName");
  }
  
  public void setStaticWebContentFolderName(String value)
  {
    getPreferences().setValue("org.eclipse.jst.j2ee.preference.staticWebContentName", value);
    firePreferenceChanged();
  }
  
  public void firePreferenceChanged()
  {
    if (isPersistOnChange()) {
      persist();
    }
  }
  
  public void persist()
  {
    getOwner().savePluginPreferences();
  }
  
  public boolean isPersistOnChange()
  {
    return persistOnChange;
  }
  
  public void setPersistOnChange(boolean persistOnChange)
  {
    this.persistOnChange = persistOnChange;
  }
  
  private Preferences getPreferences()
  {
    if (preferences == null) {
      preferences = getOwner().getPluginPreferences();
    }
    return preferences;
  }
  
  private Plugin getOwner()
  {
    return owner;
  }
  
  public static abstract interface Defaults
  {
    public static final String STATIC_WEB_CONTENT = "WebContent";
  }
  
  public static abstract interface Keys
  {
    public static final String STATIC_WEB_CONTENT = "org.eclipse.jst.j2ee.preference.staticWebContentName";
  }
  
  public static abstract interface Values
  {
    public static final String STATIC_WEB_CONTENT = "WebContent";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.WSTWebPreferences
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal;

import com.ibm.icu.util.StringTokenizer;

public class WebPropertiesUtil
{
  private static final char[] BAD_CHARS = { '/', '\\', ':' };
  
  public static String validateContextRoot(String contextRoot)
  {
    if (contextRoot == null) {
      return null;
    }
    String errorMessage = null;
    
    String name = contextRoot;
    if (name.equals(""))
    {
      errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title;
      
      return errorMessage;
    }
    if (name.trim().equals(name))
    {
      StringTokenizer stok = new StringTokenizer(name, ".");
      String token;
      int i;
      for (; stok.hasMoreTokens(); i < token.length())
      {
        token = stok.nextToken();
        i = 0; continue;
        if ((token.charAt(i) != '_') && (token.charAt(i) != '-') && (token.charAt(i) != '/') && (!Character.isLetterOrDigit(token.charAt(i))) && 
          (!Character.isWhitespace(token.charAt(i))))
        {
          errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title;
          
          break;
        }
        i++;
      }
    }
    else
    {
      errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title;
    }
    return errorMessage;
  }
  
  private static boolean contains(String str, char[] chars)
  {
    for (int i = 0; i < chars.length; i++) {
      if (str.indexOf(chars[i]) != -1) {
        return true;
      }
    }
    return false;
  }
  
  public static String validateFolderName(String folderName)
  {
    if (folderName.length() == 0) {
      return ResourceHandler.StaticWebProjectWizardBasePage_Page_Title;
    }
    if (contains(folderName, BAD_CHARS)) {
      return ResourceHandler.StaticWebProjectWizardBasePage_Page_Title;
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.WebPropertiesUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.common.componentcore.ArtifactEdit;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualContainer;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.model.IModuleFile;
import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.util.ModuleFile;
import org.eclipse.wst.server.core.util.ModuleFolder;
import org.eclipse.wst.server.core.util.ProjectModule;

/**
 * @deprecated
 */
public abstract class ComponentDeployable
  extends ProjectModule
{
  protected IVirtualComponent component = null;
  protected List<IModuleResource> members = new ArrayList();
  
  public ComponentDeployable(IProject project)
  {
    this(project, ComponentCore.createComponent(project));
  }
  
  public ComponentDeployable(IProject project, IVirtualComponent aComponent)
  {
    super(project);
    component = aComponent;
  }
  
  public boolean isBinary()
  {
    if (component == null) {
      return false;
    }
    return component.isBinary();
  }
  
  protected void addMembersToModuleFolder(ModuleFolder mf, IModuleResource[] mr)
  {
    if ((mf == null) || (mr == null) || (mr.length == 0)) {
      return;
    }
    IModuleResource[] mf_members = mf.members();
    int mf_size = 0;
    if (mf_members != null) {
      mf_size = mf_members.length;
    }
    IModuleResource[] res = new IModuleResource[mf_size + mr.length];
    if ((mf_members != null) && (mf_size > 0)) {
      System.arraycopy(mf_members, 0, res, 0, mf_size);
    }
    System.arraycopy(mr, 0, res, mf_size, mr.length);
    
    mf.setMembers(res);
  }
  
  public IModule[] getChildModules()
  {
    return getModules();
  }
  
  public IModule[] getModules()
  {
    List<IModule> modules = new ArrayList();
    if (component != null)
    {
      IVirtualReference[] components = getReferences(component);
      for (int i = 0; i < components.length; i++)
      {
        IVirtualReference reference = components[i];
        if ((reference != null) && (reference.getDependencyType() == 0))
        {
          IVirtualComponent virtualComp = reference.getReferencedComponent();
          IModule module = gatherModuleReference(component, virtualComp);
          if ((module != null) && (!modules.contains(module))) {
            modules.add(module);
          }
        }
      }
    }
    return (IModule[])modules.toArray(new IModule[modules.size()]);
  }
  
  protected IVirtualReference[] getReferences(IVirtualComponent aComponent)
  {
    return aComponent.getReferences();
  }
  
  protected IModule gatherModuleReference(IVirtualComponent component, IVirtualComponent targetComponent)
  {
    if ((targetComponent != null) && (targetComponent.getProject() != component.getProject()) && 
      (!targetComponent.isBinary())) {
      return ServerUtil.getModule(targetComponent.getProject());
    }
    return null;
  }
  
  protected IModuleResource[] getMembers(IContainer cont, IPath path, IPath javaPath, IContainer[] javaCont)
    throws CoreException
  {
    IResource[] res = cont.members();
    int size2 = res.length;
    List<IModuleFile> list = new ArrayList(size2);
    for (int j = 0; j < size2; j++) {
      if ((res[j] instanceof IContainer))
      {
        IContainer cc = (IContainer)res[j];
        
        IPath newPath = path.append(cc.getName()).makeRelative();
        
        ModuleFolder mf = (ModuleFolder)getExistingModuleResource(members, newPath);
        if (mf == null)
        {
          mf = new ModuleFolder(cc, cc.getName(), path);
          ModuleFolder parent = (ModuleFolder)getExistingModuleResource(members, path);
          if (path.isEmpty())
          {
            members.add(mf);
          }
          else
          {
            if (parent == null) {
              parent = ensureParentExists(path, cc);
            }
            addMembersToModuleFolder(parent, new IModuleResource[] { mf });
          }
        }
        IModuleResource[] mr = getMembers(cc, newPath, javaPath, javaCont);
        if ((javaPath != null) && (newPath.isPrefixOf(javaPath))) {
          mr = handleJavaPath(path, javaPath, newPath, javaCont, mr, cc);
        }
        addMembersToModuleFolder(mf, mr);
      }
      else
      {
        IFile f = (IFile)res[j];
        if (path.equals(javaPath))
        {
          ModuleFolder mFolder = (ModuleFolder)getExistingModuleResource(members, javaPath);
          IModuleFile mFile = createModuleFile(f, javaPath);
          if (mFolder != null) {
            addMembersToModuleFolder(mFolder, new IModuleResource[] { mFile });
          } else {
            list.add(mFile);
          }
        }
        else
        {
          IModuleFile mf = createModuleFile(f, path);
          list.add(mf);
        }
      }
    }
    IModuleResource[] mr = new IModuleResource[list.size()];
    list.toArray(mr);
    return mr;
  }
  
  protected IModuleFile createModuleFile(IFile file, IPath path)
  {
    return new ModuleFile(file, file.getName(), path);
  }
  
  protected IModuleResource[] getMembers(IVirtualContainer cont, IPath path)
    throws CoreException
  {
    IVirtualResource[] res = cont.members();
    int size2 = res.length;
    List<IModuleFile> list = new ArrayList(size2);
    for (int j = 0; j < size2; j++) {
      if ((res[j] instanceof IVirtualContainer))
      {
        IVirtualContainer cc = (IVirtualContainer)res[j];
        
        ModuleFolder mf = (ModuleFolder)getExistingModuleResource(members, path.append(new Path(cc.getName()).makeRelative()));
        if (mf == null)
        {
          mf = new ModuleFolder((IContainer)cc.getUnderlyingResource(), cc.getName(), path);
          ModuleFolder parent = (ModuleFolder)getExistingModuleResource(members, path);
          if (path.isEmpty())
          {
            members.add(mf);
          }
          else
          {
            if (parent == null) {
              parent = ensureParentExists(path, (IContainer)cc.getUnderlyingResource());
            }
            addMembersToModuleFolder(parent, new IModuleResource[] { mf });
          }
        }
        IModuleResource[] mr = getMembers(cc, path.append(cc.getName()));
        addMembersToModuleFolder(mf, mr);
      }
      else
      {
        IFile f = (IFile)res[j].getUnderlyingResource();
        IModuleFile mf = null;
        if (shouldAddComponentFile(f))
        {
          mf = createModuleFile(f, path);
          list.add(mf);
        }
      }
    }
    IModuleResource[] mr = new IModuleResource[list.size()];
    list.toArray(mr);
    return mr;
  }
  
  protected ModuleFolder ensureParentExists(IPath path, IContainer cc)
  {
    ModuleFolder parent = (ModuleFolder)getExistingModuleResource(members, path);
    if (parent == null)
    {
      String folderName = path.lastSegment();
      IPath folderPath = Path.EMPTY;
      if (path.segmentCount() > 1) {
        folderPath = path.removeLastSegments(1);
      }
      parent = new ModuleFolder(cc, folderName, folderPath);
      if (path.segmentCount() > 1) {
        addMembersToModuleFolder(ensureParentExists(path.removeLastSegments(1), cc), new IModuleResource[] { parent });
      } else {
        members.add(parent);
      }
    }
    return parent;
  }
  
  protected boolean shouldAddComponentFile(IFile file)
  {
    return true;
  }
  
  protected IModuleResource getExistingModuleResource(List aList, IPath path)
  {
    if ((aList == null) || (aList.isEmpty()) || (path == null)) {
      return null;
    }
    String[] pathSegments = path.segments();
    IModuleResource moduleResource = null;
    if (pathSegments.length == 0) {
      return null;
    }
    for (Iterator iter = aList.iterator(); iter.hasNext();)
    {
      moduleResource = (IModuleResource)iter.next();
      String[] moduleSegments = moduleResource.getModuleRelativePath().segments();
      if ((pathSegments[(pathSegments.length - 1)].equals(moduleResource.getName())) && 
        (moduleSegments.length + 1 == pathSegments.length) && 
        (startsWith(moduleSegments, pathSegments))) {
        return moduleResource;
      }
      if (((moduleResource instanceof IModuleFolder)) && 
        (startsWith(moduleSegments, pathSegments)) && (pathSegments.length > moduleSegments.length)) {
        if ((moduleResource.getName().equals(pathSegments[0])) && 
          (((IModuleFolder)moduleResource).members() != null)) {
          return getExistingModuleResource(Arrays.asList(((IModuleFolder)moduleResource).members()), path);
        }
      }
    }
    return null;
  }
  
  private boolean startsWith(String[] beginningSegments, String[] testSegments)
  {
    for (int i = 0; i < beginningSegments.length; i++) {
      if (!beginningSegments[i].equals(testSegments[i])) {
        return false;
      }
    }
    return true;
  }
  
  protected IModuleResource[] handleJavaPath(IPath path, IPath javaPath, IPath curPath, IContainer[] javaCont, IModuleResource[] mr, IContainer cc)
    throws CoreException
  {
    return new IModuleResource[0];
  }
  
  public IModuleResource[] members()
    throws CoreException
  {
    members.clear();
    IVirtualComponent vc = ComponentCore.createComponent(getProject());
    if (vc != null)
    {
      IVirtualFolder vFolder = vc.getRootFolder();
      IModuleResource[] mr = getMembers(vFolder, Path.EMPTY);
      int size = mr.length;
      for (int j = 0; j < size; j++) {
        members.add(mr[j]);
      }
      addUtilMembers(vc);
    }
    IModuleResource[] mr = new IModuleResource[members.size()];
    members.toArray(mr);
    return mr;
  }
  
  protected boolean shouldIncludeUtilityComponent(IVirtualComponent virtualComp, IVirtualReference[] components, ArtifactEdit edit)
  {
    return (virtualComp != null) && (virtualComp.isBinary()) && (virtualComp.getProject() == component.getProject());
  }
  
  /* Error */
  protected void addUtilMembers(IVirtualComponent vc)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aload_0
    //   3: invokevirtual 361	org/eclipse/wst/web/internal/deployables/ComponentDeployable:getComponentArtifactEditForRead	()Lorg/eclipse/wst/common/componentcore/ArtifactEdit;
    //   6: astore_2
    //   7: aload_1
    //   8: invokeinterface 402 1 0
    //   13: astore_3
    //   14: iconst_0
    //   15: istore 4
    //   17: goto +46 -> 63
    //   20: aload_3
    //   21: iload 4
    //   23: aaload
    //   24: astore 5
    //   26: aload 5
    //   28: invokeinterface 412 1 0
    //   33: astore 6
    //   35: aload_0
    //   36: aload 6
    //   38: aload_3
    //   39: aload_2
    //   40: invokevirtual 369	org/eclipse/wst/web/internal/deployables/ComponentDeployable:shouldIncludeUtilityComponent	(Lorg/eclipse/wst/common/componentcore/resources/IVirtualComponent;[Lorg/eclipse/wst/common/componentcore/resources/IVirtualReference;Lorg/eclipse/wst/common/componentcore/ArtifactEdit;)Z
    //   43: ifeq +17 -> 60
    //   46: aload_0
    //   47: aload_1
    //   48: aload 5
    //   50: aload 5
    //   52: invokeinterface 411 1 0
    //   57: invokevirtual 368	org/eclipse/wst/web/internal/deployables/ComponentDeployable:addUtilMember	(Lorg/eclipse/wst/common/componentcore/resources/IVirtualComponent;Lorg/eclipse/wst/common/componentcore/resources/IVirtualReference;Lorg/eclipse/core/runtime/IPath;)V
    //   60: iinc 4 1
    //   63: iload 4
    //   65: aload_3
    //   66: arraylength
    //   67: if_icmplt -47 -> 20
    //   70: goto +16 -> 86
    //   73: astore 7
    //   75: aload_2
    //   76: ifnull +7 -> 83
    //   79: aload_2
    //   80: invokevirtual 347	org/eclipse/wst/common/componentcore/ArtifactEdit:dispose	()V
    //   83: aload 7
    //   85: athrow
    //   86: aload_2
    //   87: ifnull +7 -> 94
    //   90: aload_2
    //   91: invokevirtual 347	org/eclipse/wst/common/componentcore/ArtifactEdit:dispose	()V
    //   94: return
    // Line number table:
    //   Java source line #349	-> byte code offset #0
    //   Java source line #351	-> byte code offset #2
    //   Java source line #352	-> byte code offset #7
    //   Java source line #353	-> byte code offset #14
    //   Java source line #354	-> byte code offset #20
    //   Java source line #355	-> byte code offset #26
    //   Java source line #356	-> byte code offset #35
    //   Java source line #357	-> byte code offset #46
    //   Java source line #353	-> byte code offset #60
    //   Java source line #360	-> byte code offset #73
    //   Java source line #361	-> byte code offset #75
    //   Java source line #362	-> byte code offset #79
    //   Java source line #363	-> byte code offset #83
    //   Java source line #361	-> byte code offset #86
    //   Java source line #362	-> byte code offset #90
    //   Java source line #364	-> byte code offset #94
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	95	0	this	ComponentDeployable
    //   0	95	1	vc	IVirtualComponent
    //   1	90	2	edit	ArtifactEdit
    //   13	53	3	components	IVirtualReference[]
    //   15	49	4	i	int
    //   24	27	5	reference	IVirtualReference
    //   33	4	6	virtualComp	IVirtualComponent
    //   73	11	7	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   2	73	73	finally
  }
  
  protected void addUtilMember(IVirtualComponent parent, IVirtualReference reference, IPath runtimePath)
  {
    IModuleFile mf = null;
    String archiveName2 = reference.getArchiveName();
    String archiveName = new Path(archiveName2).lastSegment();
    IVirtualComponent virtualComp = reference.getReferencedComponent();
    IFile ifile = (IFile)virtualComp.getAdapter(IFile.class);
    if (ifile != null)
    {
      String name = archiveName != null ? archiveName : ifile.getName();
      mf = new ModuleFile(ifile, name, runtimePath.makeRelative());
    }
    else
    {
      File extFile = (File)virtualComp.getAdapter(File.class);
      String name = archiveName != null ? archiveName : extFile.getName();
      mf = new ModuleFile(extFile, name, runtimePath.makeRelative());
    }
    IModuleResource moduleParent = getExistingModuleResource(members, mf.getModuleRelativePath());
    if ((moduleParent != null) && ((moduleParent instanceof ModuleFolder)))
    {
      addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[] { mf });
    }
    else if (mf.getModuleRelativePath().isEmpty())
    {
      members.add(mf);
    }
    else
    {
      if (moduleParent == null) {
        moduleParent = ensureParentExists(mf.getModuleRelativePath(), (IContainer)parent.getRootFolder().getUnderlyingResource());
      }
      addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[] { mf });
    }
  }
  
  protected ArtifactEdit getComponentArtifactEditForRead()
  {
    return null;
  }
  
  protected static boolean isProjectOfType(IProject project, String typeID)
  {
    IFacetedProject facetedProject = null;
    try
    {
      facetedProject = ProjectFacetsManager.create(project);
    }
    catch (CoreException localCoreException)
    {
      return false;
    }
    if ((facetedProject != null) && (ProjectFacetsManager.isProjectFacetDefined(typeID)))
    {
      IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(typeID);
      return (projectFacet != null) && (facetedProject.hasProjectFacet(projectFacet));
    }
    return false;
  }
  
  public IContainer[] getResourceFolders()
  {
    IVirtualComponent vc = ComponentCore.createComponent(getProject());
    if (vc != null)
    {
      IVirtualFolder vFolder = vc.getRootFolder();
      if (vFolder != null) {
        return vFolder.getUnderlyingFolders();
      }
    }
    return new IContainer[0];
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.deployables.ComponentDeployable
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.server.core.IModule;

class FlatComponentDeployable$1
  implements IAdapterFactory
{
  public Class[] getAdapterList()
  {
    return new Class[] { IVirtualComponent.class };
  }
  
  public Object getAdapter(Object adaptableObject, Class adapterType)
  {
    if ((adaptableObject instanceof IModule))
    {
      IModule module = (IModule)adaptableObject;
      FlatComponentDeployable deployable = (FlatComponentDeployable)module.loadAdapter(FlatComponentDeployable.class, null);
      if (deployable != null)
      {
        IVirtualComponent virtualComponent = deployable.getComponent();
        return virtualComponent;
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

import org.eclipse.core.runtime.IPath;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
import org.eclipse.wst.server.core.model.IModuleFile;

public class FlatComponentDeployable$ComponentModuleFile
  extends FlatComponentDeployable.ComponentModuleResource
  implements IModuleFile
{
  public FlatComponentDeployable$ComponentModuleFile(IFlatResource resource)
  {
    super(resource);
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof IModuleFile)) {
      return false;
    }
    IModuleFile mf = (IModuleFile)obj;
    if (!getName().equals(mf.getName())) {
      return false;
    }
    if (!getModuleRelativePath().equals(mf.getModuleRelativePath())) {
      return false;
    }
    return true;
  }
  
  public int hashCode()
  {
    return getName().hashCode() * 37 + getModuleRelativePath().hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.ComponentModuleFile
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

import org.eclipse.core.runtime.IPath;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
import org.eclipse.wst.server.core.model.IModuleFolder;

public class FlatComponentDeployable$ComponentModuleFolder
  extends FlatComponentDeployable.ComponentModuleResource
  implements IModuleFolder
{
  public FlatComponentDeployable$ComponentModuleFolder(IFlatResource resource)
  {
    super(resource);
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof IModuleFolder)) {
      return false;
    }
    IModuleFolder mf = (IModuleFolder)obj;
    if (!getName().equals(mf.getName())) {
      return false;
    }
    if (!getModuleRelativePath().equals(mf.getModuleRelativePath())) {
      return false;
    }
    return true;
  }
  
  public int hashCode()
  {
    return getName().hashCode() * 37 + getModuleRelativePath().hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.ComponentModuleFolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

import org.eclipse.core.runtime.IPath;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
import org.eclipse.wst.server.core.model.IModuleResource;

public class FlatComponentDeployable$ComponentModuleResource
{
  protected IFlatResource delegate;
  
  public FlatComponentDeployable$ComponentModuleResource(IFlatResource resource)
  {
    delegate = resource;
  }
  
  public long getModificationStamp()
  {
    return ((IFlatFile)delegate).getModificationStamp();
  }
  
  public IPath getModuleRelativePath()
  {
    return delegate.getModuleRelativePath();
  }
  
  public String getName()
  {
    return delegate.getName();
  }
  
  public Object getAdapter(Class adapter)
  {
    return delegate.getAdapter(adapter);
  }
  
  public IModuleResource[] members()
  {
    IFlatResource[] children = ((IFlatFolder)delegate).members();
    return FlatComponentDeployable.convert(children);
  }
  
  public String toString()
  {
    return getName();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.ComponentModuleResource
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent;
import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel;
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource;
import org.eclipse.wst.common.componentcore.internal.flat.IFlatVirtualComponent;
import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
import org.eclipse.wst.common.componentcore.internal.util.VirtualReferenceUtilities;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.model.IModuleFile;
import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.util.ModuleFile;
import org.eclipse.wst.server.core.util.ProjectModule;

public abstract class FlatComponentDeployable
  extends ProjectModule
{
  static
  {
    Platform.getAdapterManager().registerAdapters(new IAdapterFactory()
    {
      public Class[] getAdapterList()
      {
        return new Class[] { IVirtualComponent.class };
      }
      
      public Object getAdapter(Object adaptableObject, Class adapterType)
      {
        if ((adaptableObject instanceof IModule))
        {
          IModule module = (IModule)adaptableObject;
          FlatComponentDeployable deployable = (FlatComponentDeployable)module.loadAdapter(FlatComponentDeployable.class, null);
          if (deployable != null)
          {
            IVirtualComponent virtualComponent = deployable.getComponent();
            return virtualComponent;
          }
        }
        return null;
      }
    }, IModule.class);
  }
  
  protected IVirtualComponent component = null;
  protected List<IModuleResource> members = new ArrayList();
  
  public FlatComponentDeployable(IProject project)
  {
    this(project, ComponentCore.createComponent(project));
  }
  
  public FlatComponentDeployable(IProject project, IVirtualComponent aComponent)
  {
    super(project);
    component = aComponent;
  }
  
  public IVirtualComponent getComponent()
  {
    return component;
  }
  
  private FlatVirtualComponent cacheFlattened = null;
  
  public boolean shouldCache()
  {
    return false;
  }
  
  public void clearCache()
  {
    cacheFlattened = null;
  }
  
  protected IFlatVirtualComponent getFlatComponent()
  {
    if ((!shouldCache()) || (cacheFlattened == null))
    {
      FlatVirtualComponent.FlatComponentTaskModel options = new FlatVirtualComponent.FlatComponentTaskModel();
      options.put("org.eclipse.wst.common.componentcore.export.participantList", Arrays.asList(getParticipants()));
      FlatVirtualComponent tmp = new FlatVirtualComponent(component, options);
      if (shouldCache()) {
        cacheFlattened = tmp;
      }
      return tmp;
    }
    return cacheFlattened;
  }
  
  protected IFlattenParticipant[] getParticipants()
  {
    return new IFlattenParticipant[0];
  }
  
  public boolean isBinary()
  {
    return component == null ? false : component.isBinary();
  }
  
  public IModuleResource[] members()
    throws CoreException
  {
    if (component.isBinary()) {
      return LEGACY_binaryMembers();
    }
    IFlatVirtualComponent em = getFlatComponent();
    IFlatResource[] resources = em.fetchResources();
    return convert(resources);
  }
  
  protected IModuleResource[] LEGACY_binaryMembers()
  {
    IFile ifile = (IFile)component.getAdapter(IFile.class);
    File file = (File)component.getAdapter(File.class);
    ModuleFile mf = ifile != null ? new ModuleFile(ifile, ifile.getName(), new Path("")) : 
      new ModuleFile(file, file.getName(), new Path(""));
    return new IModuleResource[] { mf };
  }
  
  public IModule[] getChildModules()
  {
    return getModules();
  }
  
  public IChildModuleReference[] getExportModelChildren()
    throws CoreException
  {
    IFlatVirtualComponent em = getFlatComponent();
    IChildModuleReference[] children = em.getChildModules();
    return children;
  }
  
  public IModule[] getModules()
  {
    if (component.isBinary()) {
      return new IModule[0];
    }
    try
    {
      List<IModule> modules = new ArrayList();
      IChildModuleReference[] children = getExportModelChildren();
      for (int i = 0; i < children.length; i++)
      {
        IModule child = gatherModuleReference(component, children[i]);
        if (child != null) {
          modules.add(child);
        }
      }
      return (IModule[])modules.toArray(new IModule[modules.size()]);
    }
    catch (CoreException localCoreException) {}
    return new IModule[0];
  }
  
  public String getPath(IModule m)
  {
    return getURI(m);
  }
  
  public String getURI(IModule module)
  {
    ProjectModule md = (ProjectModule)module.loadAdapter(ProjectModule.class, new NullProgressMonitor());
    if (md == this) {
      return VirtualReferenceUtilities.INSTANCE.getDefaultProjectArchiveName(component);
    }
    try
    {
      FlatComponentDeployable cd = (FlatComponentDeployable)module.loadAdapter(FlatComponentDeployable.class, new NullProgressMonitor());
      if (cd != null)
      {
        IFlatVirtualComponent em = getFlatComponent();
        IChildModuleReference[] children = em.getChildModules();
        for (int i = 0; i < children.length; i++)
        {
          IModule child = gatherModuleReference(component, children[i]);
          if ((child != null) && (child.getId().equals(module.getId()))) {
            return children[i].getRelativeURI().toString();
          }
        }
      }
    }
    catch (CoreException localCoreException) {}
    return null;
  }
  
  protected IModule gatherModuleReference(IVirtualComponent component, IChildModuleReference child)
  {
    IVirtualComponent targetComponent = child.getComponent();
    if ((targetComponent != null) && (targetComponent.getProject() != component.getProject()) && 
      (!targetComponent.isBinary())) {
      return filterModuleDelegates(ServerUtil.getModules(targetComponent.getProject()));
    }
    return null;
  }
  
  protected IModule filterModuleDelegates(IModule[] modules)
  {
    for (int i = 0; i < modules.length; i++)
    {
      ModuleDelegate md = (ModuleDelegate)modules[i].loadAdapter(ModuleDelegate.class, new NullProgressMonitor());
      if ((md instanceof ProjectModule)) {
        return modules[i];
      }
    }
    return modules.length > 0 ? modules[0] : null;
  }
  
  protected static IModuleResource[] convert(IFlatResource[] resources)
  {
    ArrayList<IModuleResource> list = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
      if ((resources[i] instanceof IFlatFile)) {
        list.add(new ComponentModuleFile(resources[i]));
      } else if ((resources[i] instanceof IFlatFolder)) {
        list.add(new ComponentModuleFolder(resources[i]));
      }
    }
    return (IModuleResource[])list.toArray(new IModuleResource[list.size()]);
  }
  
  public static class ComponentModuleResource
  {
    protected IFlatResource delegate;
    
    public ComponentModuleResource(IFlatResource resource)
    {
      delegate = resource;
    }
    
    public long getModificationStamp()
    {
      return ((IFlatFile)delegate).getModificationStamp();
    }
    
    public IPath getModuleRelativePath()
    {
      return delegate.getModuleRelativePath();
    }
    
    public String getName()
    {
      return delegate.getName();
    }
    
    public Object getAdapter(Class adapter)
    {
      return delegate.getAdapter(adapter);
    }
    
    public IModuleResource[] members()
    {
      IFlatResource[] children = ((IFlatFolder)delegate).members();
      return FlatComponentDeployable.convert(children);
    }
    
    public String toString()
    {
      return getName();
    }
  }
  
  public static class ComponentModuleFile
    extends FlatComponentDeployable.ComponentModuleResource
    implements IModuleFile
  {
    public ComponentModuleFile(IFlatResource resource)
    {
      super();
    }
    
    public boolean equals(Object obj)
    {
      if (obj == this) {
        return true;
      }
      if (!(obj instanceof IModuleFile)) {
        return false;
      }
      IModuleFile mf = (IModuleFile)obj;
      if (!getName().equals(mf.getName())) {
        return false;
      }
      if (!getModuleRelativePath().equals(mf.getModuleRelativePath())) {
        return false;
      }
      return true;
    }
    
    public int hashCode()
    {
      return getName().hashCode() * 37 + getModuleRelativePath().hashCode();
    }
  }
  
  public static class ComponentModuleFolder
    extends FlatComponentDeployable.ComponentModuleResource
    implements IModuleFolder
  {
    public ComponentModuleFolder(IFlatResource resource)
    {
      super();
    }
    
    public boolean equals(Object obj)
    {
      if (obj == this) {
        return true;
      }
      if (!(obj instanceof IModuleFolder)) {
        return false;
      }
      IModuleFolder mf = (IModuleFolder)obj;
      if (!getName().equals(mf.getName())) {
        return false;
      }
      if (!getModuleRelativePath().equals(mf.getModuleRelativePath())) {
        return false;
      }
      return true;
    }
    
    public int hashCode()
    {
      return getName().hashCode() * 37 + getModuleRelativePath().hashCode();
    }
  }
  
  protected static boolean isProjectOfType(IProject project, String typeID)
  {
    IFacetedProject facetedProject = null;
    try
    {
      facetedProject = ProjectFacetsManager.create(project);
    }
    catch (CoreException localCoreException)
    {
      return false;
    }
    if ((facetedProject != null) && (ProjectFacetsManager.isProjectFacetDefined(typeID)))
    {
      IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(typeID);
      return (projectFacet != null) && (facetedProject.hasProjectFacet(projectFacet));
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.deployables.FlatComponentDeployable
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

public abstract interface IStaticWebModuleArtifact {}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.deployables.IStaticWebModuleArtifact
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

import java.util.Properties;
import org.eclipse.core.resources.IProject;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.server.core.util.IStaticWeb;

public class StaticWebDeployable
  extends FlatComponentDeployable
  implements IStaticWeb
{
  public StaticWebDeployable(IProject project, IVirtualComponent component)
  {
    super(project);
  }
  
  public String getContextRoot()
  {
    Properties props = component.getMetaProperties();
    if (props.containsKey("context-root")) {
      return props.getProperty("context-root");
    }
    return component.getName();
  }
  
  public String getVersion()
  {
    IFacetedProject facetedProject = null;
    try
    {
      facetedProject = ProjectFacetsManager.create(component.getProject());
      if ((facetedProject != null) && (ProjectFacetsManager.isProjectFacetDefined("wst.web")))
      {
        IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet("wst.web");
        return facetedProject.getInstalledVersion(projectFacet).getVersionString();
      }
    }
    catch (Exception localException) {}
    return "1.0";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.web.internal.deployables.StaticWebDeployable
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.web.internal.deployables;

import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.common.componentcore.internal.StructureEdit;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate;
import org.eclipse.wst.web.internal.WSTWebPlugin;

public class StaticWebDeployableFactory
  extends ProjectModuleFactoryDelegate
{
  private static final String ID = "org.eclipse.wst.web.internal.deployables.static";
  protected ArrayList moduleDelegates = new ArrayList();
  
  public static String getFactoryId()
  {
    return "org.eclipse.wst.web.internal.deployables.static";
  }
  
  /**
   * @deprecated
   */
  protected IModule[] createModules(ModuleCoreNature nature)
  {
    if (nature != null) {
      return createModules(nature.getProject());
    }
    return null;
  }
  
  protected boolean isValidModule(IProject project)
  {
    try
    {
      IFacetedProject facetedP
1 2 3

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-2019. Infinite Loop Ltd