use of org.eclipse.wst.server.core.model.IModuleResourceDelta in project liferay-ide by liferay.
the class MavenProjectRemoteServerPublisher method processResourceDeltas.
@Override
public void processResourceDeltas(IModuleResourceDelta[] deltas, ZipOutputStream zip, Map<ZipEntry, String> deleteEntries, String deletePrefix, String deltaPrefix, boolean adjustGMTOffset) throws CoreException, IOException {
for (IModuleResourceDelta delta : deltas) {
IResource deltaResource = (IResource) delta.getModuleResource().getAdapter(IResource.class);
IProject deltaProject = deltaResource.getProject();
IWebProject lrproject = LiferayCore.create(IWebProject.class, deltaProject);
if ((lrproject == null) || (lrproject.getDefaultDocrootFolder() == null)) {
continue;
}
IFolder webappRoot = lrproject.getDefaultDocrootFolder();
int deltaKind = delta.getKind();
IPath deltaFullPath = deltaResource.getFullPath();
boolean deltaZip = false;
IPath deltaPath = null;
if (FileUtil.exists(webappRoot)) {
IPath containerFullPath = webappRoot.getFullPath();
if (containerFullPath.isPrefixOf(deltaFullPath)) {
deltaZip = true;
deltaPath = new Path(deltaPrefix + deltaFullPath.makeRelativeTo(containerFullPath));
}
}
if ((deltaZip == false) && new Path("WEB-INF").isPrefixOf(delta.getModuleRelativePath())) {
List<IFolder> folders = CoreUtil.getSourceFolders(JavaCore.create(deltaProject));
for (IFolder folder : folders) {
IPath folderPath = folder.getFullPath();
if (folderPath.isPrefixOf(deltaFullPath)) {
deltaZip = true;
break;
}
}
}
if ((deltaZip == false) && ((deltaKind == IModuleResourceDelta.ADDED) || (deltaKind == IModuleResourceDelta.CHANGED) || (deltaKind == IModuleResourceDelta.REMOVED))) {
IPath targetPath = JavaCore.create(deltaProject).getOutputLocation();
deltaZip = true;
deltaPath = new Path("WEB-INF/classes").append(deltaFullPath.makeRelativeTo(targetPath));
}
if (deltaZip) {
if ((deltaKind == IModuleResourceDelta.ADDED) || (deltaKind == IModuleResourceDelta.CHANGED)) {
addToZip(deltaPath, deltaResource, zip, adjustGMTOffset);
} else if (deltaKind == IModuleResourceDelta.REMOVED) {
addRemoveProps(deltaPath, deltaResource, zip, deleteEntries, deletePrefix);
} else if (deltaKind == IModuleResourceDelta.NO_CHANGE) {
IModuleResourceDelta[] children = delta.getAffectedChildren();
processResourceDeltas(children, zip, deleteEntries, deletePrefix, deltaPrefix, adjustGMTOffset);
}
}
}
}
use of org.eclipse.wst.server.core.model.IModuleResourceDelta in project webtools.servertools by eclipse.
the class PublishHelper method publishDelta.
/**
* Handle a delta publish.
*
* @param delta a module resource delta
* @param path the path to publish to
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting and cancellation are not desired
* @return a possibly-empty array of error and warning status
*/
public IStatus[] publishDelta(IModuleResourceDelta delta, IPath path, IProgressMonitor monitor) {
List<IStatus> status = new ArrayList<IStatus>(2);
IModuleResource resource = delta.getModuleResource();
int kind2 = delta.getKind();
if (resource instanceof IModuleFile) {
IModuleFile file = (IModuleFile) resource;
try {
if (kind2 == IModuleResourceDelta.REMOVED)
deleteFile(path, file);
else {
IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
File f = path2.toFile().getParentFile();
if (!f.exists())
f.mkdirs();
copyFile(file, path2);
}
} catch (CoreException ce) {
status.add(ce.getStatus());
}
IStatus[] stat = new IStatus[status.size()];
status.toArray(stat);
return stat;
}
if (kind2 == IModuleResourceDelta.ADDED) {
IPath path2 = path.append(resource.getModuleRelativePath()).append(resource.getName());
File file = path2.toFile();
if (!file.exists() && !file.mkdirs()) {
status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorMkdir, path2), null));
IStatus[] stat = new IStatus[status.size()];
status.toArray(stat);
return stat;
}
}
IModuleResourceDelta[] childDeltas = delta.getAffectedChildren();
int size = childDeltas.length;
for (int i = 0; i < size; i++) {
IStatus[] stat = publishDelta(childDeltas[i], path, monitor);
addArrayToList(status, stat);
}
if (kind2 == IModuleResourceDelta.REMOVED) {
IPath path2 = path.append(resource.getModuleRelativePath()).append(resource.getName());
File file = path2.toFile();
if (file.exists() && !file.delete()) {
status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, path2), null));
}
}
IStatus[] stat = new IStatus[status.size()];
status.toArray(stat);
return stat;
}
use of org.eclipse.wst.server.core.model.IModuleResourceDelta in project liferay-ide by liferay.
the class RemoteServerBehavior method shouldPublishModuleFull.
protected boolean shouldPublishModuleFull(IModuleResourceDelta[] deltas) {
boolean retval = false;
if (ListUtil.isNotEmpty(deltas)) {
for (IModuleResourceDelta delta : deltas) {
if (shouldPublishModuleFull(delta.getAffectedChildren())) {
retval = true;
break;
} else {
final IModuleResource resource = delta.getModuleResource();
final IFile resourceFile = (IFile) resource.getAdapter(IFile.class);
if (resourceFile != null) {
final IWebProject lrproject = LiferayCore.create(IWebProject.class, resourceFile.getProject());
if (lrproject != null) {
final IPath docrootPath = lrproject.getDefaultDocrootFolder().getFullPath();
if (lrproject.findDocrootResource(resourceFile.getFullPath().makeRelativeTo(docrootPath)) != null) {
if (resource.getName().equals("web.xml") || resource.getName().equals(ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE)) {
break;
} else if (resource.getName().equals("portlet.xml")) {
break;
}
}
}
}
}
}
}
return retval;
}
use of org.eclipse.wst.server.core.model.IModuleResourceDelta in project liferay-ide by liferay.
the class ComponentUtil method containsMember.
public static boolean containsMember(IModuleResourceDelta delta, String[] paths) {
if (delta == null) {
return false;
}
// iterate over the path and find matching child delta
IModuleResourceDelta[] currentChildren = delta.getAffectedChildren();
if (currentChildren == null) {
IFile file = (IFile) delta.getModuleResource().getAdapter(IFile.class);
if (file != null) {
String filePath = file.getFullPath().toString();
for (String path : paths) {
if (filePath.contains(path)) {
return true;
}
}
}
return false;
}
for (int j = 0, jmax = currentChildren.length; j < jmax; j++) {
IPath moduleRelativePath = currentChildren[j].getModuleRelativePath();
String moduleRelativePathValue = moduleRelativePath.toString();
String moduleRelativeLastSegment = moduleRelativePath.lastSegment();
for (String path : paths) {
if (moduleRelativePathValue.equals(path) || moduleRelativeLastSegment.equals(path)) {
return true;
}
}
boolean childContains = containsMember(currentChildren[j], paths);
if (childContains) {
return true;
}
}
return false;
}
use of org.eclipse.wst.server.core.model.IModuleResourceDelta in project liferay-ide by liferay.
the class AbstractRemoteServerPublisher method processResourceDeltas.
protected void processResourceDeltas(IModuleResourceDelta[] deltas, ZipOutputStream zip, Map<ZipEntry, String> deleteEntries, String deletePrefix, String deltaPrefix, boolean adjustGMTOffset) throws IOException, CoreException {
for (IModuleResourceDelta delta : deltas) {
final int deltaKind = delta.getKind();
final IResource deltaResource = (IResource) delta.getModuleResource().getAdapter(IResource.class);
final IProject deltaProject = deltaResource.getProject();
// IDE-110 IDE-648
final IWebProject lrproject = LiferayCore.create(IWebProject.class, deltaProject);
if (lrproject != null) {
final IFolder webappRoot = lrproject.getDefaultDocrootFolder();
IPath deltaPath = null;
if (webappRoot != null && webappRoot.exists()) {
final IPath deltaFullPath = deltaResource.getFullPath();
final IPath containerFullPath = webappRoot.getFullPath();
deltaPath = new Path(deltaPrefix + deltaFullPath.makeRelativeTo(containerFullPath));
if (deltaPath != null && deltaPath.segmentCount() > 0) {
break;
}
}
if (deltaKind == IModuleResourceDelta.ADDED || deltaKind == IModuleResourceDelta.CHANGED) {
addToZip(deltaPath, deltaResource, zip, adjustGMTOffset);
} else if (deltaKind == IModuleResourceDelta.REMOVED) {
addRemoveProps(deltaPath, deltaResource, zip, deleteEntries, deletePrefix);
} else if (deltaKind == IModuleResourceDelta.NO_CHANGE) {
IModuleResourceDelta[] children = delta.getAffectedChildren();
processResourceDeltas(children, zip, deleteEntries, deletePrefix, deltaPrefix, adjustGMTOffset);
}
}
}
}
Aggregations