use of com.liferay.ide.theme.core.operation.ThemeDescriptorHelper in project liferay-ide by liferay.
the class ThemeCSSBuilder method ensureLookAndFeelFileExists.
public static void ensureLookAndFeelFileExists(IProject project) throws CoreException {
// IDE-110 IDE-648
IWebProject lrProject = LiferayCore.create(IWebProject.class, project);
if (lrProject == null) {
return;
}
IFile lookAndFeelFile = null;
IResource res = lrProject.findDocrootResource(new Path("WEB-INF/" + ILiferayConstants.LIFERAY_LOOK_AND_FEEL_XML_FILE));
if (res instanceof IFile && res.exists()) {
lookAndFeelFile = (IFile) res;
}
if (lookAndFeelFile == null) {
// need to generate a new lnf file in deafult docroot
String id = project.getName().replaceAll(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX, StringPool.EMPTY);
IResource propertiesFileRes = lrProject.findDocrootResource(new Path("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE));
String name = id;
if (propertiesFileRes instanceof IFile && propertiesFileRes.exists()) {
Properties props = new Properties();
try {
IFile propsFile = (IFile) propertiesFileRes;
InputStream contents = propsFile.getContents();
props.load(contents);
contents.close();
String nameValue = props.getProperty("name");
if (!CoreUtil.isNullOrEmpty(nameValue)) {
name = nameValue;
}
ThemeDescriptorHelper themeDescriptorHelper = new ThemeDescriptorHelper(project);
ILiferayProject lProject = lrProject;
ILiferayPortal portal = lProject.adapt(ILiferayPortal.class);
String version = "6.2.0";
if (portal != null) {
version = portal.getVersion();
}
String themeType = lProject.getProperty("theme.type", "vm");
themeDescriptorHelper.createDefaultFile(lrProject.getDefaultDocrootFolder().getFolder("WEB-INF"), version, id, name, themeType);
} catch (IOException ioe) {
ThemeCore.logError("Unable to load plugin package properties.", ioe);
}
}
}
}
Aggregations