use of com.liferay.ide.core.ILiferayProject 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.ILiferayProject in project liferay-ide by liferay.
the class AddResourceBundleFileMarkerResolution method resolve.
@Override
protected void resolve(IMarker marker) {
IProject project = marker.getResource().getProject();
if ((getResourceKey(marker) == null) || (project == null)) {
return;
}
try {
_checkResourceBundleElement(project);
ILiferayProject liferayProject = LiferayCore.create(project);
if (liferayProject == null) {
return;
}
IFolder folder = liferayProject.getSourceFolder("resources").getFolder(_resourceBundlePackage);
if (!folder.exists()) {
CoreUtil.makeFolders(folder);
}
IFile resourceBundle = folder.getFile(_resourceBundleName + ".properties");
String resourceKey = getResourceKey(marker);
if (CoreUtil.isNullOrEmpty(resourceKey)) {
return;
}
String resourceValue = getDefaultResourceValue(resourceKey);
String resourcePropertyLine = resourceKey + "=" + resourceValue + "\n";
int contentOffset = 0;
int resourcePropertyLineOffset = resourcePropertyLine.getBytes().length;
if (!resourceBundle.exists()) {
IFolder parent = (IFolder) resourceBundle.getParent();
CoreUtil.prepareFolder(parent);
resourceBundle.create(new ByteArrayInputStream(resourcePropertyLine.getBytes("UTF-8")), IResource.FORCE, null);
contentOffset = resourcePropertyLineOffset;
} else {
String contents = CoreUtil.readStreamToString(resourceBundle.getContents());
StringBuffer sb = new StringBuffer();
sb.append(contents);
sb.append(resourcePropertyLine);
String string = sb.toString();
byte[] bytes = string.trim().getBytes("UTF-8");
contentOffset = bytes.length;
resourceBundle.setContents(new ByteArrayInputStream(bytes), IResource.FORCE, new NullProgressMonitor());
}
openEditor(resourceBundle, contentOffset - resourcePropertyLineOffset, contentOffset - 1);
} catch (Exception e) {
LiferayXMLSearchUI.logError(e);
}
}
use of com.liferay.ide.core.ILiferayProject 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.ILiferayProject in project liferay-ide by liferay.
the class LiferayMavenProjectTests method testNewLiferayRemoteServiceBuilderProject.
@Test
public void testNewLiferayRemoteServiceBuilderProject() throws Exception {
if (shouldSkipBundleTests())
return;
NewLiferayPluginProjectOp op = NewLiferayPluginProjectOp.TYPE.instantiate();
op.setProjectName("servicebuilder");
op.setProjectProvider("maven");
op.setPluginType(PluginType.servicebuilder);
createTestBundleProfile(op);
final IProject project = base.createProject(op, op.getProjectName() + "-portlet");
assertEquals(project.getName(), op.getProjectName() + "-portlet");
assertNotNull(project);
String pomContents = CoreUtil.readStreamToString(project.getFile("pom.xml").getContents());
assertTrue(pomContents.contains("<artifactId>servicebuilder-portlet</artifactId>"));
assertTrue(pomContents.contains("<artifactId>liferay-maven-plugin</artifactId>"));
assertTrue(pomContents.contains("<name>servicebuilder Portlet</name>"));
waitForJobsToComplete();
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
waitForJobsToComplete();
IVirtualComponent projectComponent = ComponentCore.createComponent(project);
assertEquals("servicebuilder-portlet", projectComponent.getDeployedName());
final ILiferayProject liferayProject = LiferayCore.create(project);
final IRemoteServerPublisher publisher = liferayProject.adapt(IRemoteServerPublisher.class);
final IPath warPath = publisher.publishModuleFull(monitor);
assertTrue(warPath.toFile().exists());
}
use of com.liferay.ide.core.ILiferayProject 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