use of com.liferay.ide.server.core.portal.PortalBundle in project liferay-ide by liferay.
the class ServerUtil method getPortalBundle.
public static PortalBundle getPortalBundle(IProject project) throws CoreException {
SDK sdk = SDKUtil.getSDKFromProjectDir(project.getLocation().toFile());
if (sdk == null || !sdk.validate().isOK()) {
return null;
}
final Map<String, Object> appServerProperties = sdk.getBuildProperties();
final String appServerType = (String) (appServerProperties.get("app.server.type"));
PortalBundleFactory factory = LiferayServerCore.getPortalBundleFactories(appServerType);
if (factory != null) {
final IPath path = factory.canCreateFromPath(appServerProperties);
if (path != null) {
PortalBundle bundle = factory.create(path);
return bundle;
}
}
return null;
}
use of com.liferay.ide.server.core.portal.PortalBundle 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;
}
Aggregations