use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class PropertiesUtil method hasNonDefaultEncodingLanguagePropertiesFile.
public static boolean hasNonDefaultEncodingLanguagePropertiesFile(IProject project) {
if (!CoreUtil.isLiferayProject(project)) {
project = CoreUtil.getLiferayProject(project);
}
if (project == null) {
return false;
}
try {
IWebProject webProject = LiferayCore.create(IWebProject.class, project);
if (webProject == null) {
return false;
}
IFile[] resourceFiles = getLanguagePropertiesFromPortletXml(webProject.getDescriptorFile(ILiferayConstants.PORTLET_XML_FILE));
for (IFile file : resourceFiles) {
if (!ILiferayConstants.LANGUAGE_PROPERTIES_FILE_ENCODING_CHARSET.equals(file.getCharset())) {
return true;
}
}
IFile[] languageFiles = getLanguagePropertiesFromLiferayHookXml(webProject.getDescriptorFile(ILiferayConstants.LIFERAY_HOOK_XML_FILE));
for (IFile file : languageFiles) {
if (!ILiferayConstants.LANGUAGE_PROPERTIES_FILE_ENCODING_CHARSET.equals(file.getCharset())) {
return true;
}
}
} catch (CoreException ce) {
LiferayCore.logError(ce);
}
return false;
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class PortalSourceLookupParticipant method getSourceName.
public String getSourceName(Object object) throws CoreException {
String retval = null;
if (object instanceof FMStackFrame) {
try {
FMStackFrame frame = (FMStackFrame) object;
String templateName = getTemplateName(frame);
// if( templateName.matches( "^\\d+#\\d+#\\d+$" ) ) //$NON-NLS-1$
// {
// retval = templateName + ".ftl"; //$NON-NLS-1$
// }
// else
// {
// we need to figure out how to map this back to a valid project path.
// first if it contains a path that points to an existing plugin project
IPath templatePath = new Path(templateName);
final String firstSegment = templatePath.segment(0);
final String resourcePath = templatePath.removeFirstSegments(1).toPortableString();
IProject project = ServerUtil.findProjectByContextName(firstSegment);
final IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if (webproject != null) {
// first lets see if we can find
final String diffsPath = "_diffs/" + resourcePath;
final IResource diffsResourceFile = webproject.findDocrootResource(new Path(diffsPath));
if (diffsResourceFile.exists()) {
retval = diffsPath;
} else {
final IResource resourceFile = webproject.findDocrootResource(new Path(resourcePath));
if (resourceFile.exists()) {
retval = resourcePath;
}
}
}
} catch (Exception e) {
}
}
return retval;
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class SDKProjectRemoteServerPublisher method publishModuleFull.
@Override
public IPath publishModuleFull(IProgressMonitor monitor) throws CoreException {
IPath deployPath = LiferayServerCore.getTempLocation("direct-deploy", StringPool.EMPTY);
File warFile = deployPath.append(getProject().getName() + ".war").toFile();
warFile.getParentFile().mkdirs();
Map<String, String> properties = new HashMap<>();
properties.put(ISDKConstants.PROPERTY_AUTO_DEPLOY_UNPACK_WAR, "false");
ILiferayRuntime runtime = ServerUtil.getLiferayRuntime(getProject());
String appServerDeployDirProp = ServerUtil.getAppServerPropertyKey(ISDKConstants.PROPERTY_APP_SERVER_DEPLOY_DIR, runtime);
properties.put(appServerDeployDirProp, deployPath.toOSString());
// IDE-1073 LPS-37923
properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE_DEFAULT, warFile.getAbsolutePath());
properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE, warFile.getAbsolutePath());
String fileTimeStamp = System.currentTimeMillis() + "";
// IDE-1491
properties.put(ISDKConstants.PROPERTY_LP_VERSION, fileTimeStamp);
properties.put(ISDKConstants.PROPERTY_LP_VERSION_SUFFIX, ".0");
IStatus status = _sdk.validate();
if (!status.isOK()) {
throw new CoreException(status);
}
IStatus directDeployStatus = _sdk.war(getProject(), properties, true, new String[] { "-Duser.timezone=GMT" }, monitor);
if (!directDeployStatus.isOK() || !warFile.exists()) {
String pluginVersion = "1";
IPath pluginPropertiesPath = new Path("WEB-INF/liferay-plugin-package.properties");
IWebProject webproject = LiferayCore.create(IWebProject.class, getProject());
if (webproject != null) {
IResource propsRes = webproject.findDocrootResource(pluginPropertiesPath);
if (propsRes instanceof IFile && propsRes.exists()) {
try {
PropertiesConfiguration pluginPackageProperties = new PropertiesConfiguration();
InputStream is = ((IFile) propsRes).getContents();
pluginPackageProperties.load(is);
pluginVersion = pluginPackageProperties.getString("module-incremental-version");
is.close();
} catch (Exception e) {
LiferayCore.logError("error reading module-incremtnal-version. ", e);
}
}
IPath distPath = _sdk.getLocation().append("dist");
String fullName = getProject().getName() + "-" + fileTimeStamp + "." + pluginVersion + ".0.war";
warFile = distPath.append(fullName).toFile();
if (!warFile.exists()) {
throw new CoreException(directDeployStatus);
}
}
}
return new Path(warFile.getAbsolutePath());
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class PortletPluginFacetInstall method execute.
/**
* IDE-815 Now with contributed portlet_2_0 uri we no longer need to copy TLD to
* user's project
*/
@Override
public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException {
super.execute(project, fv, config, monitor);
IDataModel model = (IDataModel) config;
IDataModel masterModel = (IDataModel) model.getProperty(FacetInstallDataModelProvider.MASTER_PROJECT_DM);
if ((masterModel != null) && masterModel.getBooleanProperty(CREATE_PROJECT_OPERATION)) {
// IDE-1122 SDK creating project has been moved to Class NewPluginProjectWizard
String portletName = this.masterModel.getStringProperty(PORTLET_NAME);
IPath projectTempPath = (IPath) masterModel.getProperty(PROJECT_TEMP_PATH);
processNewFiles(projectTempPath.append(portletName + ISDKConstants.PORTLET_PLUGIN_PROJECT_SUFFIX));
FileUtil.deleteDir(projectTempPath.toFile(), true);
try {
this.project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (Exception e) {
ProjectCore.logError(e);
}
if (masterModel.getBooleanProperty(PLUGIN_FRAGMENT_ENABLED)) {
IDataModel fragmentModel = masterModel.getNestedModel(PLUGIN_FRAGMENT_DM);
if (fragmentModel != null) {
try {
if (fragmentModel.getBooleanProperty(IPluginWizardFragmentProperties.REMOVE_EXISTING_ARTIFACTS)) {
// IDE-110 IDE-648
IWebProject lrproject = LiferayCore.create(IWebProject.class, project);
IFolder webappRoot = lrproject.getDefaultDocrootFolder();
if (FileUtil.exists(webappRoot)) {
IFile viewJsp = webappRoot.getFile(new Path("view.jsp"));
if (FileUtil.exists(viewJsp)) {
viewJsp.delete(true, monitor);
}
}
}
} catch (Exception ex) {
ProjectCore.logError("Error deleting view.jsp", ex);
}
}
}
} else if (shouldSetupDefaultOutputLocation()) {
setupDefaultOutputLocation();
}
/*
* IDE-815 Now with contributed portlet_2_0 uri we no longer need to copy TLD to
* user's project
*/
try {
this.project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (Exception e1) {
ProjectCore.logError(e1);
}
try {
Bundle bundle = JSPCorePlugin.getDefault().getBundle();
IEclipsePreferences node = new ProjectScope(this.project).getNode(bundle.getSymbolicName());
node.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, false);
node.putBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, true);
node.flush();
} catch (Exception e) {
ProjectCore.logError("Could not store jsp fragment validation preference", e);
}
if (shouldConfigureDeploymentAssembly()) {
// IDE-565
configureDeploymentAssembly(IPluginFacetConstants.PORTLET_PLUGIN_SDK_SOURCE_FOLDER, DEFAULT_DEPLOY_PATH);
}
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class NewLiferayPluginProjectOpMethods method _removeSampleCodeAndFiles.
private static IStatus _removeSampleCodeAndFiles(NewLiferayPluginProjectOp op) {
IStatus status = org.eclipse.core.runtime.Status.OK_STATUS;
boolean includeSampleCode = op.getIncludeSampleCode().content();
if (includeSampleCode) {
return status;
}
IProject project = CoreUtil.getLiferayProject(op.getFinalProjectName().content());
if (FileUtil.exists(project)) {
ProjectCore.operate(project, RemoveSampleElementsOperation.class);
try {
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if (webproject == null) {
return status;
}
IFolder docroot = webproject.getDefaultDocrootFolder();
IFile[] sampleFiles = { docroot.getFile("view.jsp"), docroot.getFile("css/main.css"), docroot.getFile("js/main.js") };
for (IFile file : sampleFiles) {
if (FileUtil.exists(file)) {
file.delete(true, new NullProgressMonitor());
if (file.getParent().members().length == 0) {
CoreUtil.deleteResource(file.getParent());
}
}
}
} catch (CoreException ce) {
ProjectCore.logError("Error deleting sample files.", ce);
}
}
return status;
}
Aggregations