Search in sources :

Example 1 with PortalRuntime

use of com.liferay.ide.server.core.portal.PortalRuntime in project liferay-ide by liferay.

the class PortalRuntimeComposite method createFields.

private void createFields() {
    this.nameField = createTextField(Msgs.name);
    this.nameField.addModifyListener(this);
    this.dirField = createTextField(Msgs.liferayPortalRuntimeDirectory);
    this.dirField.addModifyListener(this);
    SWTUtil.createButton(this, Msgs.browse).addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final DirectoryDialog dd = new DirectoryDialog(getShell());
            dd.setMessage(Msgs.selectLiferayPortalDirectory);
            final String selectedDir = dd.open();
            if (selectedDir != null) {
                dirField.setText(selectedDir);
            }
        }
    });
    this.typeField = createReadOnlyTextField(Msgs.detectedPortalBundleType);
    jreLabel = createLabel(Msgs.selecteRuntimeJRE);
    jreCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
    jreCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    jreCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            int sel = jreCombo.getSelectionIndex();
            IVMInstall vmInstall = null;
            if (sel > 0) {
                vmInstall = installedJREs.get(sel - 1);
            }
            PortalRuntime portalRuntime = getPortalRuntime();
            if (portalRuntime != null) {
                portalRuntime.setVMInstall(vmInstall);
            }
            validate();
        }
    });
    jreButton = SWTUtil.createButton(this, Msgs.installedJREs);
    jreButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (SWTUtil.showPreferencePage("org.eclipse.jdt.debug.ui.preferences.VMPreferencePage", getShell())) {
                updateJREs();
                validate();
            }
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) PortalRuntime(com.liferay.ide.server.core.portal.PortalRuntime) ModifyListener(org.eclipse.swt.events.ModifyListener) IVMInstall(org.eclipse.jdt.launching.IVMInstall) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) Combo(org.eclipse.swt.widgets.Combo) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 2 with PortalRuntime

use of com.liferay.ide.server.core.portal.PortalRuntime in project liferay-ide by liferay.

the class PortalRuntimeComposite method updateFields.

private void updateFields() {
    final PortalRuntime portalRuntime = getPortalRuntime();
    if (portalRuntime != null) {
        final PortalBundle portalBundle = portalRuntime.getPortalBundle();
        setFieldValue(this.typeField, portalBundle != null ? portalBundle.getDisplayName() : StringPool.BLANK);
    }
}
Also used : PortalRuntime(com.liferay.ide.server.core.portal.PortalRuntime) PortalBundle(com.liferay.ide.server.core.portal.PortalBundle)

Example 3 with PortalRuntime

use of com.liferay.ide.server.core.portal.PortalRuntime in project liferay-ide by liferay.

the class PortalBundleTests method testPortalBundleTypeCorrection.

@Test
public void testPortalBundleTypeCorrection() throws Exception {
    if (shouldSkipBundleTests())
        return;
    IProgressMonitor npm = new NullProgressMonitor();
    final String name = "correctionTest";
    final IRuntimeWorkingCopy runtimeWC = ServerCore.findRuntimeType(getRuntimeId()).createRuntime(name, npm);
    assertNotNull(runtimeWC);
    runtimeWC.setName(name);
    runtimeWC.setLocation(getLiferayRuntimeDir().append(".."));
    PortalRuntime portalRuntime = (PortalRuntime) runtimeWC.loadAdapter(PortalRuntime.class, npm);
    assertNotNull(portalRuntime);
    assertNotNull(portalRuntime.getPortalBundle());
    assertEquals("tomcat", portalRuntime.getPortalBundle().getType());
    assertEquals(getLiferayRuntimeDir().append(".."), portalRuntime.getPortalBundle().getLiferayHome());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) PortalRuntime(com.liferay.ide.server.core.portal.PortalRuntime) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) Test(org.junit.Test)

Example 4 with PortalRuntime

use of com.liferay.ide.server.core.portal.PortalRuntime in project liferay-ide by liferay.

the class PortalBundleTests method testPortalBundleTypeNotFound.

@Test
public void testPortalBundleTypeNotFound() throws Exception {
    if (shouldSkipBundleTests())
        return;
    IProgressMonitor npm = new NullProgressMonitor();
    final String name = "notfoundTest";
    final IRuntimeWorkingCopy runtimeWC = ServerCore.findRuntimeType(getRuntimeId()).createRuntime(name, npm);
    assertNotNull(runtimeWC);
    runtimeWC.setName(name);
    runtimeWC.setLocation(getLiferayRuntimeDir().append("../.."));
    PortalRuntime portalRuntime = (PortalRuntime) runtimeWC.loadAdapter(PortalRuntime.class, npm);
    assertNotNull(portalRuntime);
    assertNull(portalRuntime.getPortalBundle());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) PortalRuntime(com.liferay.ide.server.core.portal.PortalRuntime) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) Test(org.junit.Test)

Example 5 with PortalRuntime

use of com.liferay.ide.server.core.portal.PortalRuntime in project liferay-ide by liferay.

the class ServiceWrapperCommand method _getDynamicServiceWrapper.

private Map<String, String[]> _getDynamicServiceWrapper() throws IOException {
    PortalRuntime portalRuntime = (PortalRuntime) _server.getRuntime().loadAdapter(PortalRuntime.class, null);
    IPath bundleLibPath = portalRuntime.getAppServerLibGlobalDir();
    IPath bundleServerPath = portalRuntime.getAppServerDir();
    Map<String, String[]> map = new LinkedHashMap<>();
    List<File> libFiles;
    File portalkernelJar = null;
    try {
        libFiles = FileListing.getFileListing(new File(bundleLibPath.toOSString()));
        for (File lib : libFiles) {
            if (FileUtil.exists(lib) && lib.getName().endsWith("portal-kernel.jar")) {
                portalkernelJar = lib;
                break;
            }
        }
        libFiles = FileListing.getFileListing(new File(bundleServerPath.append("../osgi").toOSString()));
        libFiles.add(portalkernelJar);
        if (ListUtil.isNotEmpty(libFiles)) {
            for (File lib : libFiles) {
                if (lib.getName().endsWith(".lpkg")) {
                    try (JarFile jar = new JarFile(lib)) {
                        Enumeration<JarEntry> enu = jar.entries();
                        while (enu.hasMoreElements()) {
                            JarInputStream jarInputStream = null;
                            try {
                                JarEntry entry = enu.nextElement();
                                String name = entry.getName();
                                if (name.contains(".api-")) {
                                    JarEntry jarentry = jar.getJarEntry(name);
                                    InputStream inputStream = jar.getInputStream(jarentry);
                                    jarInputStream = new JarInputStream(inputStream);
                                    JarEntry nextJarEntry;
                                    while ((nextJarEntry = jarInputStream.getNextJarEntry()) != null) {
                                        String entryName = nextJarEntry.getName();
                                        _getServiceWrapperList(map, entryName, jarInputStream);
                                    }
                                }
                            } catch (Exception e) {
                            } finally {
                                if (jarInputStream != null) {
                                    jarInputStream.close();
                                }
                            }
                        }
                    }
                } else if (lib.getName().endsWith("api.jar") || lib.getName().equals("portal-kernel.jar")) {
                    JarInputStream jarinput = null;
                    try (JarFile jar = new JarFile(lib)) {
                        jarinput = new JarInputStream(Files.newInputStream(lib.toPath()));
                        Enumeration<JarEntry> enu = jar.entries();
                        while (enu.hasMoreElements()) {
                            JarEntry entry = enu.nextElement();
                            String name = entry.getName();
                            _getServiceWrapperList(map, name, jarinput);
                        }
                    } catch (IOException ioe) {
                    } finally {
                        if (jarinput != null) {
                            jarinput.close();
                        }
                    }
                }
            }
        }
    } catch (FileNotFoundException fnfe) {
    }
    return map;
}
Also used : PortalRuntime(com.liferay.ide.server.core.portal.PortalRuntime) Enumeration(java.util.Enumeration) IPath(org.eclipse.core.runtime.IPath) JarInputStream(java.util.jar.JarInputStream) JarInputStream(java.util.jar.JarInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) LinkedHashMap(java.util.LinkedHashMap) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

PortalRuntime (com.liferay.ide.server.core.portal.PortalRuntime)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Test (org.junit.Test)4 IVMInstall (org.eclipse.jdt.launching.IVMInstall)2 PortalBundle (com.liferay.ide.server.core.portal.PortalBundle)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Enumeration (java.util.Enumeration)1 LinkedHashMap (java.util.LinkedHashMap)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 JarInputStream (java.util.jar.JarInputStream)1 IPath (org.eclipse.core.runtime.IPath)1 IVMInstallType (org.eclipse.jdt.launching.IVMInstallType)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1