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();
}
}
});
}
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);
}
}
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());
}
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());
}
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;
}
Aggregations