Search in sources :

Example 1 with UnresolveableURIException

use of org.eclipse.wst.common.componentcore.UnresolveableURIException in project webtools.servertools by eclipse.

the class ModuleTraverser method traverseWebComponent.

private static void traverseWebComponent(IVirtualComponent component, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException {
    visitor.visitWebComponent(component);
    IProject proj = component.getProject();
    StructureEdit warStruct = StructureEdit.getStructureEditForRead(proj);
    try {
        WorkbenchComponent comp = warStruct.getComponent();
        if (comp == null) {
            Trace.trace(Trace.SEVERE, "Error getting WorkbenchComponent from war project. IProject=\"" + proj + "\" StructureEdit=\"" + warStruct + "\" WorkbenchComponent=\"" + comp + "\"");
            return;
        }
        traverseWebComponentLocalEntries(comp, visitor, monitor);
        // traverse referenced components
        List children = comp.getReferencedComponents();
        for (Iterator itor = children.iterator(); itor.hasNext(); ) {
            ReferencedComponent childRef = (ReferencedComponent) itor.next();
            IPath rtFolder = childRef.getRuntimePath();
            URI refHandle = childRef.getHandle();
            if (PlatformURLModuleConnection.CLASSPATH.equals(refHandle.segment(ModuleURIUtil.ModuleURI.SUB_PROTOCOL_INDX))) {
                IPath refPath = getResolvedPathForArchiveComponent(refHandle);
                // If an archive component, add to list
                if (refPath != null) {
                    if (!refPath.isAbsolute()) {
                        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(refPath);
                        IPath refPath2 = file.getLocation();
                        if (refPath2 != null) {
                            visitor.visitArchiveComponent(rtFolder, refPath2);
                        } else {
                            Trace.trace(Trace.WARNING, NLS.bind("Could not get the location of a referenced component.  It may not exist.  Project={0}, Parent Component={1}, Referenced Component Path={2}", new Object[] { proj.getName(), comp.getName(), refPath }));
                        }
                    } else {
                        visitor.visitArchiveComponent(rtFolder, refPath);
                    }
                } else {
                // TODO Determine if any use case would arrive here.
                }
            } else {
                try {
                    WorkbenchComponent childCom = warStruct.findComponentByURI(refHandle);
                    if (childCom == null) {
                        continue;
                    }
                    traverseDependentEntries(visitor, rtFolder, childCom, monitor);
                } catch (UnresolveableURIException e) {
                    TomcatPlugin.log(e);
                }
            }
        }
    } finally {
        warStruct.dispose();
    }
    visitor.endVisitWebComponent(component);
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) WorkbenchComponent(org.eclipse.wst.common.componentcore.internal.WorkbenchComponent) Iterator(java.util.Iterator) List(java.util.List) ReferencedComponent(org.eclipse.wst.common.componentcore.internal.ReferencedComponent) UnresolveableURIException(org.eclipse.wst.common.componentcore.UnresolveableURIException) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject) StructureEdit(org.eclipse.wst.common.componentcore.internal.StructureEdit)

Example 2 with UnresolveableURIException

use of org.eclipse.wst.common.componentcore.UnresolveableURIException in project liferay-ide by liferay.

the class ModuleTraverser method traverseWebComponent.

private static void traverseWebComponent(IVirtualComponent component, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException {
    visitor.visitWebComponent(component);
    IProject proj = component.getProject();
    StructureEdit warStruct = StructureEdit.getStructureEditForRead(proj);
    try {
        WorkbenchComponent comp = warStruct.getComponent();
        if (comp == null) {
            // + "\" WorkbenchComponent=\"" + comp + "\""); //$NON-NLS-1$ //$NON-NLS-2$
            return;
        }
        traverseWebComponentLocalEntries(comp, visitor, monitor);
        // traverse referenced components
        List children = comp.getReferencedComponents();
        for (Iterator itor = children.iterator(); itor.hasNext(); ) {
            ReferencedComponent childRef = (ReferencedComponent) itor.next();
            IPath rtFolder = childRef.getRuntimePath();
            URI refHandle = childRef.getHandle();
            if (PlatformURLModuleConnection.CLASSPATH.equals(refHandle.segment(ModuleURIUtil.ModuleURI.SUB_PROTOCOL_INDX))) {
                IPath refPath = getResolvedPathForArchiveComponent(refHandle);
                // If an archive component, add to list
                if (refPath != null) {
                    if (!refPath.isAbsolute()) {
                        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(refPath);
                        IPath refPath2 = file.getLocation();
                        if (refPath2 != null) {
                            visitor.visitArchiveComponent(rtFolder, refPath2);
                        } else {
                        // Trace.trace(Trace.WARNING, NLS.bind(
                        // "Could not get the location of a referenced component.  It may not exist.  Project={0}, Parent Component={1}, Referenced Component Path={2}", //$NON-NLS-1$
                        // new Object[] { proj.getName(), comp.getName(), refPath}));
                        }
                    } else {
                        visitor.visitArchiveComponent(rtFolder, refPath);
                    }
                } else {
                // TODO Determine if any use case would arrive here.
                }
            } else {
                try {
                    WorkbenchComponent childCom = warStruct.findComponentByURI(refHandle);
                    if (childCom == null) {
                        continue;
                    }
                    traverseDependentEntries(visitor, rtFolder, childCom, monitor);
                } catch (UnresolveableURIException e) {
                    LiferayServerCore.logError(e);
                }
            }
        }
    } finally {
        warStruct.dispose();
    }
    visitor.endVisitWebComponent(component);
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) WorkbenchComponent(org.eclipse.wst.common.componentcore.internal.WorkbenchComponent) Iterator(java.util.Iterator) List(java.util.List) ReferencedComponent(org.eclipse.wst.common.componentcore.internal.ReferencedComponent) UnresolveableURIException(org.eclipse.wst.common.componentcore.UnresolveableURIException) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject) StructureEdit(org.eclipse.wst.common.componentcore.internal.StructureEdit)

Aggregations

Iterator (java.util.Iterator)2 List (java.util.List)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IPath (org.eclipse.core.runtime.IPath)2 URI (org.eclipse.emf.common.util.URI)2 UnresolveableURIException (org.eclipse.wst.common.componentcore.UnresolveableURIException)2 ReferencedComponent (org.eclipse.wst.common.componentcore.internal.ReferencedComponent)2 StructureEdit (org.eclipse.wst.common.componentcore.internal.StructureEdit)2 WorkbenchComponent (org.eclipse.wst.common.componentcore.internal.WorkbenchComponent)2