use of org.eclipse.wst.common.componentcore.resources.IVirtualComponent in project liferay-ide by liferay.
the class PluginPackageResourceListener method processRequiredDeploymentContexts.
protected void processRequiredDeploymentContexts(Properties props, IProject project) {
IVirtualComponent rootComponent = ComponentCore.createComponent(project);
if (rootComponent == null) {
return;
}
List<IVirtualReference> removeRefs = new ArrayList<>();
IClasspathContainer webAppLibrariesContainer = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project);
if (webAppLibrariesContainer == null) {
return;
}
IClasspathEntry[] existingEntries = webAppLibrariesContainer.getClasspathEntries();
for (IClasspathEntry entry : existingEntries) {
IPath path = entry.getPath();
String archiveName = path.lastSegment();
if (archiveName.endsWith("-service.jar")) {
IFile file = _getWorkspaceFile(path);
if (file.exists() && ProjectUtil.isLiferayFacetedProject(file.getProject())) {
for (IVirtualReference ref : rootComponent.getReferences()) {
if (archiveName.equals(ref.getArchiveName())) {
removeRefs.add(ref);
}
}
}
}
}
List<IVirtualReference> addRefs = new ArrayList<>();
String requiredDeploymenContexts = props.getProperty("required-deployment-contexts");
if (requiredDeploymenContexts != null) {
String[] contexts = requiredDeploymenContexts.split(StringPool.COMMA);
if (ListUtil.isNotEmpty(contexts)) {
for (String context : contexts) {
IVirtualReference ref = processContext(rootComponent, context);
if (ref != null) {
addRefs.add(ref);
}
}
}
}
new WorkspaceJob("Update virtual component.") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
updateVirtualComponent(rootComponent, removeRefs, addRefs);
updateWebClasspathContainer(rootComponent, addRefs);
return Status.OK_STATUS;
}
}.schedule();
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualComponent in project liferay-ide by liferay.
the class PluginPackageResourceListener method processPortalDependencyTlds.
protected void processPortalDependencyTlds(Properties props, IProject project) {
String portalDependencyTlds = props.getProperty("portal-dependency-tlds");
if (portalDependencyTlds == null) {
return;
}
String[] portalTlds = portalDependencyTlds.split(StringPool.COMMA);
IVirtualComponent component = ComponentCore.createComponent(project);
if (component == null) {
return;
}
IFolder webroot = (IFolder) component.getRootFolder().getUnderlyingFolder();
IFolder tldFolder = webroot.getFolder("WEB-INF/tld");
IPath portalDir = ServerUtil.getPortalDir(project);
List<IPath> tldFilesToCopy = new ArrayList<>();
if (portalDir != null) {
for (String portalTld : portalTlds) {
IFile tldFile = tldFolder.getFile(portalTld);
if (!tldFile.exists()) {
IPath realPortalTld = portalDir.append("WEB-INF/tld/" + portalTld);
if (realPortalTld.toFile().exists()) {
tldFilesToCopy.add(realPortalTld);
}
}
}
}
if (ListUtil.isEmpty(tldFilesToCopy)) {
return;
}
new WorkspaceJob("copy portal tlds") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
CoreUtil.prepareFolder(tldFolder);
for (IPath tldFileToCopy : tldFilesToCopy) {
IFile newTldFile = tldFolder.getFile(tldFileToCopy.lastSegment());
try {
newTldFile.create(Files.newInputStream(tldFileToCopy.toFile().toPath()), true, null);
} catch (Exception e) {
throw new CoreException(ProjectCore.createErrorStatus(e));
}
}
return Status.OK_STATUS;
}
}.schedule();
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualComponent in project liferay-ide by liferay.
the class PluginPackageResourceListener method processContext.
protected IVirtualReference processContext(IVirtualComponent rootComponent, String context) {
// first check for jar file
IFile serviceJar = ComponentUtil.findServiceJarForContext(context);
if (serviceJar == null) {
return null;
}
IPath serviceJarPath = serviceJar.getFullPath();
if (rootComponent == null) {
return null;
}
String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR;
IVirtualComponent archive = ComponentCore.createArchiveComponent(rootComponent.getProject(), type + serviceJarPath.makeRelative().toString());
IVirtualReference ref = ComponentCore.createReference(rootComponent, archive, new Path(J2EEConstants.WEB_INF_LIB).makeAbsolute());
ref.setArchiveName(serviceJarPath.lastSegment());
return ref;
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualComponent in project liferay-ide by liferay.
the class PluginFacetInstall method getWebRootFolder.
protected IFolder getWebRootFolder() {
IDataModel webFacetDataModel = null;
if (masterModel != null) {
FacetDataModelMap map = (FacetDataModelMap) masterModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
webFacetDataModel = map.getFacetDataModel(IJ2EEFacetConstants.DYNAMIC_WEB_FACET.getId());
} else {
webFacetDataModel = getFacetDataModel(IModuleConstants.JST_WEB_MODULE);
}
IPath webrootFullPath = null;
if (webFacetDataModel != null) {
String configFolder = webFacetDataModel.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER);
webrootFullPath = project.getFullPath().append(configFolder);
} else {
IVirtualComponent component = ComponentCore.createComponent(project);
if (component != null) {
IContainer container = component.getRootFolder().getUnderlyingFolder();
webrootFullPath = container.getFullPath();
}
}
return CoreUtil.getWorkspaceRoot().getFolder(webrootFullPath);
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualComponent in project liferay-ide by liferay.
the class ModuleTraverser method traverse.
/**
* Scans the module using the specified visitor.
*
* @param module module to traverse
* @param visitor visitor to handle resources
* @param monitor a progress monitor
* @throws CoreException
*/
public static void traverse(IModule module, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException {
if (module == null || module.getModuleType() == null)
return;
String typeId = module.getModuleType().getId();
IVirtualComponent component = ComponentCore.createComponent(module.getProject());
if (component == null) {
// + module.getName());
return;
}
if (EAR_MODULE.equals(typeId)) {
traverseEarComponent(component, visitor, monitor);
} else if (WEB_MODULE.equals(typeId)) {
traverseWebComponent(component, visitor, monitor);
}
}
Aggregations