use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class LiferayDescriptorHelper method getDescriptorVersion.
public static String getDescriptorVersion(IProject project, String defaultValue) {
String retval = defaultValue;
try {
ILiferayProject lProject = LiferayCore.create(project);
if (lProject != null) {
ILiferayPortal portal = lProject.adapt(ILiferayPortal.class);
if (portal != null) {
String versionStr = portal.getVersion();
retval = getDescriptorVersionFromPortalVersion(versionStr);
}
}
} catch (Exception e) {
LiferayCore.logError("Could not get liferay runtime.", e);
}
if ("0.0.0".equals(retval)) {
retval = defaultValue;
}
return retval;
}
use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class LiferayHookModelTests method strutsActionPathPossibleValuesCacheService.
@Test
public void strutsActionPathPossibleValuesCacheService() throws Exception {
if (shouldSkipBundleTests())
return;
final NewLiferayPluginProjectOp op = newProjectOp("testPossibleValuesCache");
op.setPluginType(PluginType.hook);
final IProject hookProject = createAntProject(op);
final IFolder webappRoot = LiferayCore.create(IWebProject.class, hookProject).getDefaultDocrootFolder();
assertNotNull(webappRoot);
final IFile hookXml = webappRoot.getFile("WEB-INF/liferay-hook.xml");
assertEquals(true, hookXml.exists());
final Hook hook = Hook6xx.TYPE.instantiate(new RootXmlResource(new XmlResourceStore(hookXml.getContents())));
assertNotNull(hook);
final ILiferayProject liferayProject = LiferayCore.create(hookProject);
final ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
final IPath strutsConfigPath = portal.getAppServerPortalDir().append("WEB-INF/struts-config.xml");
final StrutsAction strutsAction = hook.getStrutsActions().insert();
final Value<String> strutsActionPath = strutsAction.getStrutsActionPath();
final TreeSet<String> vals1 = strutsActionPath.service(StrutsActionPathPossibleValuesCacheService.class).getPossibleValuesForPath(strutsConfigPath);
final TreeSet<String> vals2 = strutsActionPath.service(StrutsActionPathPossibleValuesCacheService.class).getPossibleValuesForPath(strutsConfigPath);
assertTrue(vals1 == vals2);
}
use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class InitConfigureProjectPage method _getWorkspaceProjectBuilder.
private IWorkspaceProjectBuilder _getWorkspaceProjectBuilder(IProject project) throws CoreException {
final ILiferayProject liferayProject = LiferayCore.create(project);
if (liferayProject == null) {
throw new CoreException(ProjectUI.createErrorStatus("Can't find Liferay workspace project."));
}
final IWorkspaceProjectBuilder builder = liferayProject.adapt(IWorkspaceProjectBuilder.class);
if (builder == null) {
throw new CoreException(ProjectUI.createErrorStatus("Can't find Liferay Gradle project builder."));
}
return builder;
}
use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class CompareFileHandler method getTemplateFile.
protected File getTemplateFile(IFile currentFile) throws Exception {
final IProject project = currentFile.getProject();
final ILiferayProject liferayProject = LiferayCore.create(project);
final String themeParent = liferayProject.getProperty("theme.parent", "_styled");
final ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
final IPath themesPath = portal.getAppServerPortalDir().append("html/themes/" + themeParent);
String name = currentFile.getName();
String parent = currentFile.getParent().getName();
IPath diffs = themesPath.append("_diffs");
IPath tempFilePath = diffs.append(parent).append(name);
if (!tempFilePath.toFile().exists()) {
tempFilePath = themesPath.append(parent).append(name);
}
if (tempFilePath.toFile().exists()) {
return tempFilePath.toFile();
}
}
return null;
}
use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class RemoteServerBehavior method publishModuleFull.
protected int publishModuleFull(IModule[] module, int deltaKind, IProgressMonitor monitor) throws CoreException {
if (module == null) {
throw new CoreException(LiferayServerCore.error(// $NON-NLS-1$
"Cannot publish module with length " + (module != null ? module.length : 0)));
}
if (monitor == null) {
monitor = new NullProgressMonitor();
}
final IModule publishModule = module[0];
final IProject moduleProject = publishModule.getProject();
final IProgressMonitor submon = CoreUtil.newSubMonitor(monitor, 100);
// $NON-NLS-1$ //$NON-NLS-2$
submon.subTask("Deploying " + moduleProject.getName() + " to Liferay...");
final ILiferayProject liferayProject = LiferayCore.create(moduleProject);
final IRemoteServerPublisher publisher = liferayProject.adapt(IRemoteServerPublisher.class);
if (publisher == null) {
setModuleStatus(module, null);
throw new CoreException(LiferayServerCore.error(Msgs.publishingModuleProject));
}
final IPath warPath = publisher.publishModuleFull(monitor);
// 25% complete
submon.worked(25);
if (monitor.isCanceled()) {
return IServer.PUBLISH_STATE_FULL;
}
final String appName = ComponentUtilities.getServerContextRoot(moduleProject);
IServerManagerConnection remoteConnection = getServerManagerConnection();
setModuleStatus(module, LiferayServerCore.info(Msgs.installing));
// 50% complete
submon.worked(25);
if (monitor.isCanceled()) {
return IServer.PUBLISH_STATE_FULL;
}
submon.subTask(NLS.bind(Msgs.publishingModuleProject, moduleProject.getName()));
Object error = null;
try {
error = remoteConnection.installApplication(warPath.toOSString(), appName, submon);
} catch (Exception ex) {
setModuleStatus(module, null);
setModuleState(module, IServer.STATE_UNKNOWN);
throw new CoreException(LiferayServerCore.createErrorStatus(ex));
} finally {
if (warPath.toFile().exists()) {
warPath.toFile().delete();
}
}
if (error != null) {
setModuleStatus(module, null);
setModuleState(module, IServer.STATE_UNKNOWN);
throw new CoreException(LiferayServerCore.error(error.toString()));
}
// 90%
submon.worked(40);
setModuleStatus(module, LiferayServerCore.info(Msgs.starting));
if (monitor.isCanceled()) {
setModuleStatus(module, null);
return IServer.PUBLISH_STATE_UNKNOWN;
}
setModuleStatus(module, null);
setModuleState(module, IServer.STATE_STARTED);
// 100%
submon.worked(10);
monitor.done();
return IServer.PUBLISH_STATE_NONE;
}
Aggregations