Search in sources :

Example 16 with ILiferayProject

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

the class LiferayPropertiesSourceViewerConfiguration method getContentAssistant.

@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    if (_propKeys == null) {
        IEditorInput input = getEditor().getEditorInput();
        // first fine runtime location to get properties definitions
        IPath appServerPortalDir = _getAppServerPortalDir(input);
        String propertiesEntry = _getPropertiesEntry(input);
        PropKey[] keys = null;
        if ((appServerPortalDir != null) && appServerPortalDir.toFile().exists()) {
            try {
                JarFile jar = new JarFile(appServerPortalDir.append("WEB-INF/lib/portal-impl.jar").toFile());
                ZipEntry lang = jar.getEntry(propertiesEntry);
                keys = _parseKeys(jar.getInputStream(lang));
                jar.close();
            } catch (Exception e) {
                LiferayUIPlugin.logError("Unable to get portal properties file", e);
            }
        } else {
            return _assitant;
        }
        Object adapter = input.getAdapter(IFile.class);
        if (adapter instanceof IFile && _isHookProject(((IFile) adapter).getProject())) {
            ILiferayProject liferayProject = LiferayCore.create(((IFile) adapter).getProject());
            ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
            if (portal != null) {
                Set<String> hookProps = new HashSet<>();
                Collections.addAll(hookProps, portal.getHookSupportedProperties());
                List<PropKey> filtered = new ArrayList<>();
                for (PropKey pk : keys) {
                    if (hookProps.contains(pk.getKey())) {
                        filtered.add(pk);
                    }
                }
                keys = filtered.toArray(new PropKey[0]);
            }
        }
        _propKeys = keys;
    }
    if ((_propKeys != null) && (_assitant == null)) {
        ContentAssistant ca = new ContentAssistant() {

            @Override
            public IContentAssistProcessor getContentAssistProcessor(String contentType) {
                return new LiferayPropertiesContentAssistProcessor(_propKeys, contentType);
            }
        };
        ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));
        _assitant = ca;
    }
    return _assitant;
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ZipEntry(java.util.zip.ZipEntry) ArrayList(java.util.ArrayList) JarFile(java.util.jar.JarFile) IContentAssistant(org.eclipse.jface.text.contentassist.IContentAssistant) ContentAssistant(org.eclipse.jface.text.contentassist.ContentAssistant) IOException(java.io.IOException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) ILiferayProject(com.liferay.ide.core.ILiferayProject) PropKey(com.liferay.ide.ui.editor.LiferayPropertiesContentAssistProcessor.PropKey) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IEditorInput(org.eclipse.ui.IEditorInput) HashSet(java.util.HashSet)

Example 17 with ILiferayProject

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

the class RemoteServerBehavior method publishModuleDelta.

protected int publishModuleDelta(IModule[] module, IProgressMonitor monitor) throws CoreException {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    IProject moduleProject = module[0].getProject();
    IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
    if (shouldPublishModuleFull(delta)) {
        return publishModuleFull(module, CHANGED, monitor);
    }
    final String appName = ComponentUtilities.getServerContextRoot(moduleProject);
    // $NON-NLS-1$ //$NON-NLS-2$
    monitor.subTask("Creating partial " + moduleProject.getName() + " update archive...");
    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.publishModuleDelta(appName + ".war", delta, "liferay", true);
    monitor.worked(25);
    if (monitor != null && monitor.isCanceled()) {
        return IServer.PUBLISH_STATE_UNKNOWN;
    }
    monitor.subTask(Msgs.gettingLiferayConnection);
    IServerManagerConnection connection = getServerManagerConnection();
    monitor.subTask(NLS.bind(Msgs.updatingModuleProject, moduleProject.getName()));
    Object error = null;
    try {
        error = connection.updateApplication(appName, warPath.toOSString(), monitor);
    } catch (APIException e) {
        error = e.getMessage();
    }
    monitor.worked(90);
    if (error != null) {
        throw new CoreException(LiferayServerCore.error(error.toString()));
    }
    monitor.done();
    return IServer.PUBLISH_STATE_NONE;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) APIException(com.liferay.ide.core.remote.APIException) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) IModuleResourceDelta(org.eclipse.wst.server.core.model.IModuleResourceDelta) IProject(org.eclipse.core.resources.IProject)

Example 18 with ILiferayProject

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

the class ServerUtil method getPortalDir.

public static IPath getPortalDir(IProject project) {
    IPath retval = null;
    final ILiferayProject liferayProject = LiferayCore.create(project);
    if (liferayProject != null) {
        final ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        if (portal != null) {
            retval = portal.getAppServerPortalDir();
        }
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Example 19 with ILiferayProject

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

the class MavenModuleProjectTests method testMavenDependencyUpdate.

@Test
public void testMavenDependencyUpdate() throws Exception {
    String[][] dependency = new String[][] { { "com.liferay.portal", "com.liferay.portal.kernel", "2.6.0" } };
    Dependency mavenDependency = new Dependency();
    mavenDependency.setGroupId(dependency[0][0]);
    mavenDependency.setArtifactId(dependency[0][1]);
    mavenDependency.setVersion(dependency[0][2]);
    final URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/MavenDependencyTestProject.zip");
    final File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
    File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
    ZipUtil.unzip(wsZipFile, eclipseWorkspaceLocation);
    File mavenDependencyTestProjectFolder = new File(eclipseWorkspaceLocation, "MavenDependencyTestProject");
    MavenUtil.importProject(mavenDependencyTestProjectFolder.getAbsolutePath(), monitor);
    waitForJobsToComplete(monitor);
    IProject mavenDependencyTestProject = CoreUtil.getProject("MavenDependencyTestProject");
    assertNotNull(mavenDependencyTestProject);
    assertTrue(mavenDependencyTestProject.exists());
    IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(mavenDependencyTestProject, new NullProgressMonitor());
    assertNotNull(projectFacade);
    MavenProject mavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
    List<Dependency> existedDependencies = mavenProject.getDependencies();
    assertFalse(checkDependency(existedDependencies, mavenDependency));
    ILiferayProject liferayMavenDependencyProject = LiferayCore.create(mavenDependencyTestProject);
    IProjectBuilder projectBuilder = liferayMavenDependencyProject.adapt(IProjectBuilder.class);
    projectBuilder.updateProjectDependency(mavenDependencyTestProject, Arrays.asList(dependency));
    waitForJobsToComplete(monitor);
    MavenProject updateMavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
    List<Dependency> updateDependencies = updateMavenProject.getDependencies();
    assertTrue(checkDependency(updateDependencies, mavenDependency));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) ILiferayProject(com.liferay.ide.core.ILiferayProject) Dependency(org.apache.maven.model.Dependency) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 20 with ILiferayProject

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

the class VersionsTests method testFindLiferayVersionByProperties.

@Test
public void testFindLiferayVersionByProperties() throws Exception {
    IProject project = importProject("projects/versions/properties-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

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