Search in sources :

Example 36 with ILiferayProject

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;
}
Also used : ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Example 37 with ILiferayProject

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);
}
Also used : Hook(com.liferay.ide.hook.core.model.Hook) IFile(org.eclipse.core.resources.IFile) StrutsActionPathPossibleValuesCacheService(com.liferay.ide.hook.core.model.internal.StrutsActionPathPossibleValuesCacheService) IPath(org.eclipse.core.runtime.IPath) IWebProject(com.liferay.ide.core.IWebProject) XmlResourceStore(org.eclipse.sapphire.modeling.xml.XmlResourceStore) StrutsAction(com.liferay.ide.hook.core.model.StrutsAction) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource) IProject(org.eclipse.core.resources.IProject) ILiferayProject(com.liferay.ide.core.ILiferayProject) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 38 with ILiferayProject

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;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILiferayProject(com.liferay.ide.core.ILiferayProject) IWorkspaceProjectBuilder(com.liferay.ide.project.core.IWorkspaceProjectBuilder)

Example 39 with ILiferayProject

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Example 40 with ILiferayProject

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;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IModule(org.eclipse.wst.server.core.IModule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException) APIException(com.liferay.ide.core.remote.APIException)

Aggregations

ILiferayProject (com.liferay.ide.core.ILiferayProject)45 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)29 IProject (org.eclipse.core.resources.IProject)21 IPath (org.eclipse.core.runtime.IPath)18 IFile (org.eclipse.core.resources.IFile)17 CoreException (org.eclipse.core.runtime.CoreException)15 ArrayList (java.util.ArrayList)9 IFolder (org.eclipse.core.resources.IFolder)8 Version (org.osgi.framework.Version)8 IOException (java.io.IOException)7 File (java.io.File)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 Path (org.eclipse.core.runtime.Path)4 IWebProject (com.liferay.ide.core.IWebProject)3 Hook (com.liferay.ide.hook.core.model.Hook)3 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)3