Bug 103888 - [modulecore] Need api for getting at the actual links defining a virtual component
Summary: [modulecore] Need api for getting at the actual links defining a virtual comp...
Status: NEW
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.common (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows XP
: P4 normal with 1 vote (vote)
Target Milestone: Future   Edit
Assignee: Chuck Bridgham CLA
QA Contact: Carl Anderson CLA
URL:
Whiteboard:
Keywords: helpwanted
: 284060 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-14 15:11 EDT by Konstantin Komissarchik CLA
Modified: 2010-03-26 20:33 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Komissarchik CLA 2005-07-14 15:11:06 EDT
There is currently no way, short of using StructureEdit to get at the actual 
links (wb-resource elements) that define a virtual component. This is necessary 
in order to instruct a server where to find various resources without copying.
Comment 1 John Lanuti CLA 2005-08-15 10:44:35 EDT
What does your code look like now using structure edit?
Comment 2 Thomas Yip CLA 2005-08-16 16:18:17 EDT
Thank John,


Here is the code snipplet from my PublishTask assembler. 
The fact that we create a link instead of making copy doesn't change the
requirement. We need the ability to obtain the actual wb-resource elements so
that we can do the assembling in a PublishTask.




    IProject proj = mod.getProject();
    StructureEdit earStruct = StructureEdit.getStructureEditForRead(proj);
    try {
        StringBuffer buffer = new StringBuffer();
        WorkbenchComponent earComp = earStruct.findComponentByName(mod.getName());
                    
        // ear entries
        generateApplicationEntries(earComp, buffer, monitor);
                    
        // dependents entries
        EList children = earComp.getReferencedComponents();
        for (Iterator itor=children.iterator(); itor.hasNext();) {
            ReferencedComponent childRef = (ReferencedComponent) itor.next();
            WorkbenchComponent childCom =
earStruct.findComponentByURI(childRef.getHandle());
            generateDependentEntries(childCom, buffer, monitor);
        }
    } finally {
        earStruct.dispose();
    }


private void generateDependentEntries(WorkbenchComponent child, 
                        StringBuffer buffer, IProgressMonitor monitor) 
throws CoreException {
    // find dependent component of the ear
    IProject childProject = StructureEdit.getContainingProject(child);

    String name = child.getName(); // assume it is the same as URI

    // go thru all entries
    EList res = child.getResources();
    for (Iterator itorRes = res.iterator(); itorRes.hasNext();) {
        ComponentResource childComp = (ComponentResource) itorRes.next();
        IPath srcPath = childComp.getSourcePath();
        IPath rtPath = childComp.getRuntimePath();

        link(srcPath, rtPath); // we create softlinks instead of copying the
entries.
    }
}
Comment 3 Rob Stryker CLA 2009-09-08 12:09:11 EDT
*** Bug 284060 has been marked as a duplicate of this bug. ***