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