Search in sources :

Example 26 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal 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 27 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class LiferayPropertiesSourceViewerConfiguration method _getAppServerPortalDir.

private IPath _getAppServerPortalDir(IEditorInput input) {
    IPath retval = null;
    IFile ifile = input.getAdapter(IFile.class);
    if (ifile != null) {
        ILiferayProject project = LiferayCore.create(ifile.getProject());
        if (project != null) {
            ILiferayPortal portal = project.adapt(ILiferayPortal.class);
            if (portal != null) {
                retval = portal.getAppServerPortalDir();
            }
        }
    } else {
        File file = input.getAdapter(File.class);
        if ((file == null) && input instanceof FileStoreEditorInput) {
            FileStoreEditorInput fInput = (FileStoreEditorInput) input;
            file = new File(fInput.getURI().getPath());
        }
        if ((file != null) && file.exists()) {
            try {
                IPath propsParentPath = new Path(file.getParentFile().getCanonicalPath());
                for (IRuntime runtime : ServerCore.getRuntimes()) {
                    if (propsParentPath.equals(runtime.getLocation()) || propsParentPath.isPrefixOf(runtime.getLocation())) {
                        ILiferayRuntime lr = ServerUtil.getLiferayRuntime(runtime);
                        retval = lr.getAppServerPortalDir();
                        break;
                    }
                }
            } catch (Exception e) {
                LiferayUIPlugin.logError("Unable to get portal language properties file", e);
            }
        }
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) JarFile(java.util.jar.JarFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput) IOException(java.io.IOException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 28 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class PortalLanguagePropertiesCacheUtil method getPortalLanguageProperties.

public static Properties getPortalLanguageProperties(ILiferayProject project) {
    if (project == null) {
        return new Properties();
    }
    Properties retval = null;
    JarFile jar = null;
    InputStream in = null;
    try {
        ILiferayPortal portal = project.adapt(ILiferayPortal.class);
        if (portal == null) {
            IRuntime[] runtimes = ServerCore.getRuntimes();
            if (ListUtil.isNotEmpty(runtimes)) {
                for (IRuntime runtime : runtimes) {
                    PortalBundle portalBundle = LiferayServerCore.newPortalBundle(runtime.getLocation());
                    if (portalBundle != null) {
                        portal = portalBundle;
                        break;
                    }
                }
            }
            if (portal == null) {
                return retval;
            }
        }
        IPath appServerPortalDir = portal.getAppServerPortalDir();
        retval = _languagePortalMap.get(appServerPortalDir);
        if (retval == null) {
            if ((appServerPortalDir != null) && appServerPortalDir.toFile().exists()) {
                jar = new JarFile(appServerPortalDir.append("WEB-INF/lib/portal-impl.jar").toFile());
                ZipEntry lang = jar.getEntry("content/Language.properties");
                retval = new Properties();
                in = jar.getInputStream(lang);
                retval.load(in);
            }
            _languagePortalMap.put(appServerPortalDir, retval);
        }
    } catch (Exception e) {
        LiferayXMLSearchUI.logError("Unable to find portal language properties", e);
    } finally {
        try {
            if (in != null) {
                in.close();
            }
            if (jar != null) {
                jar.close();
            }
        } catch (IOException ioe) {
        // no errors this is best effort
        }
    }
    return retval;
}
Also used : PortalBundle(com.liferay.ide.server.core.portal.PortalBundle) IPath(org.eclipse.core.runtime.IPath) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) Properties(java.util.Properties) JarFile(java.util.jar.JarFile) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IOException(java.io.IOException) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 29 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class EmailAddressValidationService method _getSchemaVersion.

private Version _getSchemaVersion() {
    Version schemaVersion = new Version(KaleoCore.DEFAULT_KALEO_VERSION);
    if (context(WorkflowDefinition.class) != null) {
        WorkflowDefinition workflowDefinition = context(WorkflowDefinition.class);
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewNodeOp.class) != null) {
        NewNodeOp newNodeOp = context(NewNodeOp.class);
        ElementHandle<WorkflowDefinition> workflowDef = newNodeOp.getWorkflowDefinition();
        WorkflowDefinition workflowDefinition = workflowDef.content();
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewWorkflowDefinitionOp.class) != null) {
        NewWorkflowDefinitionOp newWorkflowDenitionOp = context(NewWorkflowDefinitionOp.class);
        ReferenceValue<String, IProject> opProject = newWorkflowDenitionOp.getProject();
        IProject project = opProject.target();
        ILiferayProject liferayProj = LiferayCore.create(project);
        ILiferayPortal portal = liferayProj.adapt(ILiferayPortal.class);
        if (portal != null) {
            schemaVersion = new Version(portal.getVersion());
        }
    }
    return schemaVersion;
}
Also used : Version(org.eclipse.sapphire.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) NewNodeOp(com.liferay.ide.kaleo.core.op.NewNodeOp) ReferenceValue(org.eclipse.sapphire.ReferenceValue) Value(org.eclipse.sapphire.Value) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ElementHandle(org.eclipse.sapphire.ElementHandle) NewWorkflowDefinitionOp(com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Example 30 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class VersionsTests method testFindLiferayVersionByDeps.

@Test
public void testFindLiferayVersionByDeps() throws Exception {
    IProject project = importProject("projects/versions/deps-portlet/pom.xml");
    assertNotNull(project);
    IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project, monitor);
    assertNotNull(facade);
    final ILiferayProject lrproject = LiferayCore.create(project);
    assertNotNull(lrproject);
    final ILiferayPortal portal = lrproject.adapt(ILiferayPortal.class);
    assertNotNull(portal);
    assertEquals("6.2.1", portal.getVersion());
}
Also used : ILiferayProject(com.liferay.ide.core.ILiferayProject) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

ILiferayPortal (com.liferay.ide.core.ILiferayPortal)32 ILiferayProject (com.liferay.ide.core.ILiferayProject)29 IPath (org.eclipse.core.runtime.IPath)13 IFile (org.eclipse.core.resources.IFile)10 IProject (org.eclipse.core.resources.IProject)10 CoreException (org.eclipse.core.runtime.CoreException)8 IOException (java.io.IOException)7 Version (org.osgi.framework.Version)7 ArrayList (java.util.ArrayList)4 IWebProject (com.liferay.ide.core.IWebProject)3 Hook (com.liferay.ide.hook.core.model.Hook)3 File (java.io.File)3 Properties (java.util.Properties)3 JarFile (java.util.jar.JarFile)3 Path (org.eclipse.core.runtime.Path)3 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 ZipEntry (java.util.zip.ZipEntry)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2