use of org.eclipse.wst.server.core.model.IModuleResource in project sling by apache.
the class SlingContentModuleAdapterTest method projectMembersContainDotDirFoldersLast.
@Test
public void projectMembersContainDotDirFoldersLast() throws Exception {
// create faceted project
IProject contentProject = projectRule.getProject();
ProjectAdapter project = new ProjectAdapter(contentProject);
project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
// install bundle facet
project.installFacet("sling.content", "1.0");
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/testproject/_jcr_content/image/file"), new ByteArrayInputStream(new byte[0]));
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/testproject/_jcr_content/image/file.dir/.content.xml"), new ByteArrayInputStream(new byte[0]));
project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/testproject/_jcr_content/image/file.dir/_jcr_content/_dam_thumbnails/_dam_thumbnail_319.png"), new ByteArrayInputStream(new byte[0]));
IModule module = ServerUtil.getModule(contentProject);
SlingContentModuleFactory moduleFactory = new SlingContentModuleFactory();
ModuleDelegate moduleDelegate = moduleFactory.getModuleDelegate(module);
IModuleResource[] members = moduleDelegate.members();
int fileIdx = -1;
int fileDirIdx = -1;
for (int i = 0; i < members.length; i++) {
String memberName = members[i].getModuleRelativePath().lastSegment();
if (memberName == null) {
continue;
} else if (memberName.equals("file.dir")) {
fileDirIdx = i;
} else if (memberName.equals("file")) {
fileIdx = i;
}
}
Assert.assertTrue("file not sorted before file.dir ; file index = " + fileIdx + ", file.dir index = " + fileDirIdx, fileIdx < fileDirIdx);
}
use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.sourceediting by eclipse.
the class ComponentDeployable method addUtilMember.
protected void addUtilMember(IVirtualComponent parent, IVirtualReference reference, IPath runtimePath) {
IModuleFile mf = null;
final String archiveName2 = reference.getArchiveName();
final String archiveName = new Path(archiveName2).lastSegment();
final IVirtualComponent virtualComp = reference.getReferencedComponent();
IFile ifile = virtualComp.getAdapter(IFile.class);
if (ifile != null) {
// In Workspace
String name = null != archiveName ? archiveName : ifile.getName();
mf = new ModuleFile(ifile, name, runtimePath.makeRelative());
} else {
File extFile = virtualComp.getAdapter(File.class);
String name = null != archiveName ? 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 });
}
}
}
use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.sourceediting by eclipse.
the class ComponentDeployable method members.
@Override
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;
}
use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.sourceediting by eclipse.
the class ComponentDeployable method getMembers.
protected IModuleResource[] getMembers(IVirtualContainer cont, IPath path) throws CoreException {
IVirtualResource[] res = cont.members();
int size2 = res.length;
List<IModuleFile> list = new ArrayList<IModuleFile>(size2);
for (int j = 0; j < size2; j++) {
if (res[j] instanceof IVirtualContainer) {
IVirtualContainer cc = (IVirtualContainer) res[j];
// Retrieve already existing module folder if applicable
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;
}
use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.sourceediting by eclipse.
the class FlatComponentDeployable method LEGACY_binaryMembers.
protected IModuleResource[] LEGACY_binaryMembers() {
IFile ifile = component.getAdapter(IFile.class);
File file = component.getAdapter(File.class);
ModuleFile mf = // $NON-NLS-1$
ifile != null ? // $NON-NLS-1$
new ModuleFile(ifile, ifile.getName(), new Path("")) : // $NON-NLS-1$
new ModuleFile(file, file.getName(), new Path(""));
return new IModuleResource[] { mf };
}
Aggregations