Search in sources :

Example 1 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class AbstractModuleAssembler method copyModule.

protected IPath copyModule(IModule module, IProgressMonitor monitor) throws CoreException {
    ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, monitor);
    IStatus[] status = publishHelper.publishSmart(pm.members(), fAssembleRoot, monitor);
    if (status != null && status.length > 0)
        throw new CoreException(status[0]);
    return fAssembleRoot;
}
Also used : ProjectModule(org.eclipse.wst.server.core.util.ProjectModule) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class EarModuleAssembler method assemble.

public IPath assemble(IProgressMonitor monitor) throws CoreException {
    // copy ear root to the temporary assembly directory
    IPath parent = fAssembleRoot;
    final IModule[] rootMod = { fModule };
    boolean shouldCopy = (IServer.PUBLISH_STATE_NONE != fServer.getServer().getModulePublishState(rootMod));
    if (shouldCopy)
        copyModule(fModule, monitor);
    IEnterpriseApplication earModule = (IEnterpriseApplication) fModule.loadAdapter(IEnterpriseApplication.class, monitor);
    IModule[] childModules = earModule.getModules();
    for (int i = 0; i < childModules.length; i++) {
        IModule module = childModules[i];
        String uri = earModule.getURI(module);
        if (uri == null) {
            // The bad memories of WTP 1.0
            // $NON-NLS-1$
            IStatus status = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, "unable to assemble module null uri", null);
            throw new CoreException(status);
        }
        IJ2EEModule jeeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, monitor);
        if (jeeModule != null && jeeModule.isBinary()) {
            // Binary module
            // just copy
            ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
            IModuleResource[] resources = pm.members();
            publishHelper.publishToPath(resources, parent.append(uri), monitor);
            // done! no need to go further
            continue;
        }
        if (shouldRepack(module)) {
            packModule(module, uri, parent);
        }
    }
    return parent;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModule(org.eclipse.wst.server.core.IModule) IStatus(org.eclipse.core.runtime.IStatus) IJ2EEModule(org.eclipse.jst.server.core.IJ2EEModule) IPath(org.eclipse.core.runtime.IPath) IEnterpriseApplication(org.eclipse.jst.server.core.IEnterpriseApplication) ProjectModule(org.eclipse.wst.server.core.util.ProjectModule) CoreException(org.eclipse.core.runtime.CoreException)

Example 3 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class ModuleHelper method listModule.

public static void listModule(IModule module) throws CoreException {
    System.out.println("--- Contents of " + module.getName() + "/" + module.getId() + "---");
    ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
    IModuleResource[] mr = pm.members();
    for (IModuleResource m : mr) {
        if (m instanceof IModuleFile) {
            System.out.println(m.getName());
        } else {
            System.out.println(m.getName() + "/");
            listFolder((IModuleFolder) m, "  ");
        }
    }
    System.out.println("------");
}
Also used : ProjectModule(org.eclipse.wst.server.core.util.ProjectModule)

Example 4 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.sourceediting by eclipse.

the class FlatComponentDeployable method getURI.

/**
 * Returns the URI of the given contained CHILD module.
 *
 * SOFT requirements (NOT API!!) in use by some adopters
 * If the passed in module is equal to this module, return our own deployed name
 *
 * @param module a module
 * @return the URI of the given module, or <code>null</code> if the URI could
 *    not be found
 */
public String getURI(IModule module) {
    ProjectModule md = (ProjectModule) module.loadAdapter(ProjectModule.class, new NullProgressMonitor());
    if (md == this) {
        // guess my own name
        return VirtualReferenceUtilities.INSTANCE.getDefaultProjectArchiveName(this.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 ce) {
    }
    return null;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProjectModule(org.eclipse.wst.server.core.util.ProjectModule) IFlatVirtualComponent(org.eclipse.wst.common.componentcore.internal.flat.IFlatVirtualComponent) IModule(org.eclipse.wst.server.core.IModule) CoreException(org.eclipse.core.runtime.CoreException) IChildModuleReference(org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference)

Example 5 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class AbstractModuleAssembler method packModule.

protected void packModule(IModule module, String deploymentUnitName, IPath destination) throws CoreException {
    String dest = destination.append(deploymentUnitName).toString();
    ModulePackager packager = null;
    try {
        packager = new ModulePackager(dest, false);
        ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
        IModuleResource[] resources = pm.members();
        for (int i = 0; i < resources.length; i++) {
            doPackModule(resources[i], packager);
        }
    } catch (IOException e) {
        IStatus status = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, "unable to assemble module", // $NON-NLS-1$
        e);
        throw new CoreException(status);
    } finally {
        try {
            packager.finished();
        } catch (IOException e) {
        // unhandled
        }
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) ProjectModule(org.eclipse.wst.server.core.util.ProjectModule) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Aggregations

ProjectModule (org.eclipse.wst.server.core.util.ProjectModule)10 CoreException (org.eclipse.core.runtime.CoreException)5 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)3 IModule (org.eclipse.wst.server.core.IModule)3 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)3 IPath (org.eclipse.core.runtime.IPath)2 IJ2EEModule (org.eclipse.jst.server.core.IJ2EEModule)2 IOException (java.io.IOException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IEnterpriseApplication (org.eclipse.jst.server.core.IEnterpriseApplication)1 IWebModule (org.eclipse.jst.server.core.IWebModule)1 IChildModuleReference (org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference)1 IFlatVirtualComponent (org.eclipse.wst.common.componentcore.internal.flat.IFlatVirtualComponent)1