protected IStatus validateServer(IProgressMonitor monitor) { String host = serverWC.getHost(); if (CoreUtil.isNullOrEmpty(host)) { return LiferayServerUI.createErrorStatus(Msgs.specifyHostname); } String username = remoteServerWC.getUsername(); if (CoreUtil.isNullOrEmpty(username)) { return LiferayServerUI.createErrorStatus(Msgs.specifyUsernamePassword); } String port = remoteServerWC.getHTTPPort(); if (CoreUtil.isNullOrEmpty(port)) { return LiferayServerUI.createErrorStatus(Msgs.specifyHTTPPort); } IStatus status = remoteServerWC.validate(monitor); if (status != null && status.getSeverity() == IStatus.ERROR) { fragment.lastServerStatus = new Status( IStatus.WARNING, status.getPlugin(), status.getMessage(), status.getException()); } else { fragment.lastServerStatus = status; } return status; }
public static Set<String> getPossibleProfileIds( NewLiferayPluginProjectOp op, boolean includeNewProfiles) { final String activeProfilesValue = op.getActiveProfilesValue().content(); final Path currentLocation = op.getLocation().content(); final File param = currentLocation != null ? currentLocation.toFile() : null; final List<String> systemProfileIds = op.getProjectProvider().content().getData("profileIds", String.class, param); final ElementList<NewLiferayProfile> newLiferayProfiles = op.getNewLiferayProfiles(); final Set<String> possibleProfileIds = new HashSet<String>(); if (!CoreUtil.isNullOrEmpty(activeProfilesValue)) { final String[] vals = activeProfilesValue.split(","); if (!CoreUtil.isNullOrEmpty(vals)) { for (String val : vals) { if (!possibleProfileIds.contains(val) && !val.contains(StringPool.SPACE)) { possibleProfileIds.add(val); } } } } if (!CoreUtil.isNullOrEmpty(systemProfileIds)) { for (Object systemProfileId : systemProfileIds) { if (systemProfileId != null) { final String val = systemProfileId.toString(); if (!possibleProfileIds.contains(val) && !val.contains(StringPool.SPACE)) { possibleProfileIds.add(val); } } } } if (includeNewProfiles) { for (NewLiferayProfile newLiferayProfile : newLiferayProfiles) { final String newId = newLiferayProfile.getId().content(); if ((!CoreUtil.isNullOrEmpty(newId)) && (!possibleProfileIds.contains(newId)) && (!newId.contains(StringPool.SPACE))) { possibleProfileIds.add(newId); } } } return possibleProfileIds; }
protected boolean shouldFullBuild(Map args) throws CoreException { if (args != null && args.get("force") != null && args.get("force").equals("true")) { return true; } // check to see if there is any files in the _diffs folder // IDE-110 IDE-648 final IWebProject lrproject = LiferayCore.create(IWebProject.class, getProject()); if (lrproject != null && lrproject.getDefaultDocrootFolder() != null) { final IFolder webappRoot = lrproject.getDefaultDocrootFolder(); if (webappRoot != null) { IFolder diffs = webappRoot.getFolder(new Path("_diffs")); if (diffs != null && diffs.exists()) { IResource[] diffMembers = diffs.members(); if (!CoreUtil.isNullOrEmpty(diffMembers)) { return true; } } } } return false; }
protected void updateStubs() { ILiferayRuntimeStub[] stubs = LiferayServerCore.getRuntimeStubs(); if (CoreUtil.isNullOrEmpty(stubs)) { return; } String[] names = new String[stubs.length]; LiferayRuntimeStubDelegate delegate = getStubDelegate(); String stubId = delegate.getRuntimeStubTypeId(); int stubIndex = -1; for (int i = 0; i < stubs.length; i++) { names[i] = stubs[i].getName(); if (stubs[i].getRuntimeStubTypeId().equals(stubId)) { stubIndex = i; } } comboRuntimeStubType.setItems(names); if (stubIndex >= 0) { comboRuntimeStubType.select(stubIndex); } }
public static PortletLayoutElement createFromElement( IDOMElement portletLayoutElement, ILayoutTplDiagramFactory factory) { if (portletLayoutElement == null) { return null; } PortletLayoutElement newPortletLayout = factory.newPortletLayout(); String existingClassName = portletLayoutElement.getAttribute("class"); // $NON-NLS-1$ if ((!CoreUtil.isNullOrEmpty(existingClassName)) && existingClassName.contains("portlet-layout")) // $NON-NLS-1$ { newPortletLayout.setClassName(existingClassName); } else { newPortletLayout.setClassName("portlet-layout"); // $NON-NLS-1$ } IDOMElement[] portletColumnElements = LayoutTplUtil.findChildElementsByClassName( portletLayoutElement, "div", "portlet-column"); // $NON-NLS-1$ //$NON-NLS-2$ for (IDOMElement portletColumnElement : portletColumnElements) { PortletColumnElement newPortletColumn = factory.newPortletColumnFromElement(portletColumnElement); newPortletLayout.addColumn(newPortletColumn); } return newPortletLayout; }
@Override public void setupLaunchConfiguration( ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException { super.setupLaunchConfiguration(workingCopy, monitor); workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, "UTF-8"); // $NON-NLS-1$ String existingVMArgs = workingCopy.getAttribute( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String) null); if (null != existingVMArgs) { String[] parsedVMArgs = DebugPlugin.parseArguments(existingVMArgs); List<String> memoryArgs = new ArrayList<String>(); if (!CoreUtil.isNullOrEmpty(parsedVMArgs)) { for (String pArg : parsedVMArgs) { if (pArg.startsWith("-Xm") || pArg.startsWith("-XX:")) // $NON-NLS-1$ //$NON-NLS-2$ { memoryArgs.add(pArg); } } } String argsWithoutMem = mergeArguments( existingVMArgs, getRuntimeVMArguments(), memoryArgs.toArray(new String[0]), false); String fixedArgs = mergeArguments(argsWithoutMem, getRuntimeVMArguments(), null, false); workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, fixedArgs); } }
protected void handleNewImplClassButton(Text text) { if (CoreUtil.isNullOrEmpty(texts[0].getText())) { MessageDialog.openWarning(getParentShell(), Msgs.addService, Msgs.specifyServiceType); return; } String serviceType = texts[0].getText(); String wrapperType = StringPool.EMPTY; if (serviceType.endsWith("Service")) // $NON-NLS-1$ { wrapperType = serviceType + "Wrapper"; // $NON-NLS-1$ } NewEventActionClassDialog dialog = new NewServiceWrapperClassDialog(getShell(), model, serviceType, wrapperType); if (dialog.open() == Window.OK) { String qualifiedClassname = dialog.getQualifiedClassname(); text.setText(qualifiedClassname); } }
@Override public Object getDefaultProperty(String propertyName) { if (LAYOUT_TEMPLATE_NAME.equals(propertyName)) { return "New Template"; //$NON-NLS-1$ } else if (LAYOUT_TEMPLATE_ID.equals(propertyName)) { String name = getStringProperty(LAYOUT_TEMPLATE_NAME); if (!CoreUtil.isNullOrEmpty(name)) { return name.replaceAll("[^a-zA-Z0-9]+", StringPool.EMPTY).toLowerCase(); // $NON-NLS-1$ } } else if (LAYOUT_TEMPLATE_FILE.equals(propertyName)) { return "/" + getStringProperty(LAYOUT_TEMPLATE_ID) + ".tpl"; // $NON-NLS-1$//$NON-NLS-2$ } else if (LAYOUT_WAP_TEMPLATE_FILE.equals(propertyName)) { return "/" + getStringProperty(LAYOUT_TEMPLATE_ID) + ".wap.tpl"; // $NON-NLS-1$//$NON-NLS-2$ } else if (LAYOUT_THUMBNAIL_FILE.equals(propertyName)) { return "/" + getStringProperty(LAYOUT_TEMPLATE_ID) + ".png"; // $NON-NLS-1$//$NON-NLS-2$ } else if (LAYOUT_IMAGE_BLANK_COLUMN.equals(propertyName)) { return true; } else if (LAYOUT_IMAGE_1_COLUMN.equals(propertyName) || LAYOUT_IMAGE_1_2_1_COLUMN.equals(propertyName) || LAYOUT_IMAGE_1_2_I_COLUMN.equals(propertyName) || LAYOUT_IMAGE_1_2_II_COLUMN.equals(propertyName) || LAYOUT_IMAGE_2_2_COLUMN.equals(propertyName) || LAYOUT_IMAGE_2_I_COLUMN.equals(propertyName) || LAYOUT_IMAGE_2_II_COLUMN.equals(propertyName) || LAYOUT_IMAGE_2_III_COLUMN.equals(propertyName) || LAYOUT_IMAGE_3_COLUMN.equals(propertyName)) { return false; } return super.getDefaultProperty(propertyName); }
public <T> T adapt(ILiferayProject liferayProject, Class<T> adapterType) { if (liferayProject instanceof LiferayMavenProject && IProjectBuilder.class.equals(adapterType)) { // only use this builder for versions of Liferay less than 6.2 final LiferayMavenProject liferayMavenProject = LiferayMavenProject.class.cast(liferayProject); final String version = liferayMavenProject.getLiferayMavenPluginVersion(); if (!CoreUtil.isNullOrEmpty(version)) { // we only need to match the first 2 characters final Matcher matcher = majorMinor.matcher(version); String matchedVersion = null; if (matcher.find() && matcher.groupCount() == 2) { matchedVersion = matcher.group(1) + "." + matcher.group(2) + ".0"; } final Version portalVersion = new Version(matchedVersion != null ? matchedVersion : version); if (CoreUtil.compareVersions(portalVersion, ILiferayConstants.V620) < 0) { MavenUIProjectBuilder builder = new MavenUIProjectBuilder((LiferayMavenProject) liferayProject); return adapterType.cast(builder); } } } return null; }
private boolean isError(JSONObject jsonObject) { try { final String error = jsonObject.getString("error"); // $NON-NLS-1$ return !CoreUtil.isNullOrEmpty(error); } catch (JSONException e) { } return false; }
protected void handleSelectImplClassButton(Text text) { if (CoreUtil.isNullOrEmpty(texts[0].getText())) { MessageDialog.openWarning(getParentShell(), Msgs.addService, Msgs.specifyServiceType); return; } IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model.getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT); if (packRoot == null) { return; } IJavaSearchScope scope = null; try { // get the Service type and replace Service with Wrapper and // make it the supertype String serviceType = texts[0].getText(); if (serviceType.endsWith("Service")) // $NON-NLS-1$ { String wrapperType = serviceType + "Wrapper"; // $NON-NLS-1$ scope = BasicSearchEngine.createHierarchyScope( packRoot.getJavaProject().findType(wrapperType)); } } catch (JavaModelException e) { HookUI.logError(e); return; } FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialogEx( getShell(), false, null, scope, IJavaSearchConstants.CLASS); dialog.setTitle(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_TITLE); dialog.setMessage(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_DESC); if (dialog.open() == Window.OK) { IType type = (IType) dialog.getFirstResult(); String classFullPath = J2EEUIMessages.EMPTY_STRING; if (type != null) { classFullPath = type.getFullyQualifiedName(); } text.setText(classFullPath); } }
@Test public void testNewWebAntProjectValidation() throws Exception { IPath liferayPluginsSdkDir = super.getLiferayPluginsSdkDir(); final File liferayPluginsSdkDirFile = liferayPluginsSdkDir.toFile(); if (!liferayPluginsSdkDirFile.exists()) { final File liferayPluginsSdkZipFile = super.getLiferayPluginsSDKZip().toFile(); assertEquals( "Expected file to exist: " + liferayPluginsSdkZipFile.getAbsolutePath(), true, liferayPluginsSdkZipFile.exists()); liferayPluginsSdkDirFile.mkdirs(); final String liferayPluginsSdkZipFolder = super.getLiferayPluginsSdkZipFolder(); if (CoreUtil.isNullOrEmpty(liferayPluginsSdkZipFolder)) { ZipUtil.unzip(liferayPluginsSdkZipFile, liferayPluginsSdkDirFile); } else { ZipUtil.unzip( liferayPluginsSdkZipFile, liferayPluginsSdkZipFolder, liferayPluginsSdkDirFile, new NullProgressMonitor()); } } assertEquals(true, liferayPluginsSdkDirFile.exists()); SDK sdk = null; final SDK existingSdk = SDKManager.getInstance().getSDK(liferayPluginsSdkDir); if (existingSdk == null) { sdk = SDKUtil.createSDKFromLocation(liferayPluginsSdkDir); } else { sdk = existingSdk; } final String projectName = "test-web-project-sdk"; final NewLiferayPluginProjectOp op = newProjectOp(projectName); op.setPluginsSDKName(sdk.getName()); op.setPluginType(PluginType.web); assertEquals( "The selected Plugins SDK does not support creating new web type plugins. Please configure version 7.0.0 or greater.", op.getPluginType().validation().message()); }
@Override public IStatus validate(String propertyName) { if (LAYOUT_TEMPLATE_ID.equals(propertyName)) { // first check to see if an existing property exists. LayoutTplDescriptorHelper helper = new LayoutTplDescriptorHelper(getTargetProject()); if (helper.hasTemplateId(getStringProperty(propertyName))) { return LayoutTplCore.createErrorStatus(Msgs.templateIdExists); } // to avoid marking text like "this" as bad add a z to the end of the string String idValue = getStringProperty(propertyName) + "z"; // $NON-NLS-1$ if (CoreUtil.isNullOrEmpty(idValue)) { return super.validate(propertyName); } IStatus status = JavaConventions.validateFieldName( idValue, CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5); if (!status.isOK()) { return LayoutTplCore.createErrorStatus(Msgs.templateIdInvalid); } } else if (LAYOUT_TEMPLATE_FILE.equals(propertyName)) { final IPath filePath = new Path(getStringProperty(LAYOUT_TEMPLATE_FILE)); if (checkDocrootFileExists(filePath)) { return LayoutTplCore.createWarningStatus(Msgs.templateFileExists); } } else if (LAYOUT_WAP_TEMPLATE_FILE.equals(propertyName)) { final IPath filePath = new Path(getStringProperty(LAYOUT_WAP_TEMPLATE_FILE)); if (checkDocrootFileExists(filePath)) { return LayoutTplCore.createWarningStatus(Msgs.wapTemplateFileExists); } } else if (LAYOUT_THUMBNAIL_FILE.equals(propertyName)) { final IPath filePath = new Path(getStringProperty(LAYOUT_THUMBNAIL_FILE)); if (checkDocrootFileExists(filePath)) { return LayoutTplCore.createWarningStatus(Msgs.thumbnailFileExists); } } return super.validate(propertyName); }
protected void initMap() { try { wsdlNameURLMap = new HashMap<String, String>(); String webServicesString = CoreUtil.readStreamToString(webServicesListURL.openStream()); List<String> wsdlUrls = pullLinks(webServicesString); for (String url : wsdlUrls) { String name = pullServiceName(url); if (!CoreUtil.isNullOrEmpty(name)) { wsdlNameURLMap.put(name, url); } } } catch (IOException e1) { LiferayServerCore.logError("Unable to initial web services list."); // $NON-NLS-1$ } }
public static Version readVersionFile(File versionInfoFile) { String versionContents = FileUtil.readContents(versionInfoFile); if (CoreUtil.isNullOrEmpty(versionContents)) { return Version.emptyVersion; } Version version = null; ; try { version = Version.parseVersion(versionContents.trim()); } catch (NumberFormatException e) { version = Version.emptyVersion; } return version; }
@Override public boolean performOk() { final String selectedRuntimeName = this.runtimeCombo.getText(); if (!CoreUtil.isNullOrEmpty(selectedRuntimeName)) { final org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime = RuntimeManager.getRuntime(selectedRuntimeName); if (runtime != null) { final IFacetedProject fProject = ProjectUtil.getFacetedProject(getProject()); final org.eclipse.wst.common.project.facet.core.runtime.IRuntime primaryRuntime = fProject.getPrimaryRuntime(); if (!runtime.equals(primaryRuntime)) { Job job = new WorkspaceJob("Setting targeted runtime for project.") // $NON-NLS-1$ { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { IStatus retval = Status.OK_STATUS; try { fProject.setTargetedRuntimes(Collections.singleton(runtime), monitor); fProject.setPrimaryRuntime(runtime, monitor); } catch (Exception e) { retval = ProjectUIPlugin.createErrorStatus( "Could not set targeted runtime", e); // $NON-NLS-1$ } return retval; } }; job.schedule(); } } else { return false; } } return true; }
private String getConfigInfoFromCache(String configType, IPath portalDir) { File configInfoFile = getConfigInfoPath(configType).toFile(); String portalDirKey = CoreUtil.createStringDigest(portalDir.toPortableString()); Properties properties = new Properties(); if (configInfoFile.exists()) { try (FileInputStream fileInput = new FileInputStream(configInfoFile)) { properties.load(fileInput); String configInfo = (String) properties.get(portalDirKey); if (!CoreUtil.isNullOrEmpty(configInfo)) { return configInfo; } } catch (IOException e) { LiferayServerCore.logError(e); } } return null; }
public static void ensureLookAndFeelFileExists(IProject project) throws CoreException { // IDE-110 IDE-648 final IWebProject lrProject = LiferayCore.create(IWebProject.class, project); if (lrProject == null) { return; } IFile lookAndFeelFile = null; final 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); final 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 { final IFile propsFile = (IFile) propertiesFileRes; final InputStream contents = propsFile.getContents(); props.load(contents); contents.close(); final String nameValue = props.getProperty("name"); // $NON-NLS-1$ if (!CoreUtil.isNullOrEmpty(nameValue)) { name = nameValue; } final ThemeDescriptorHelper themeDescriptorHelper = new ThemeDescriptorHelper(project); final ILiferayProject lProject = lrProject; final ILiferayPortal portal = lProject.adapt(ILiferayPortal.class); String version = "6.2.0"; if (portal != null) { version = portal.getVersion(); } final String themeType = lProject.getProperty("theme.type", "vm"); themeDescriptorHelper.createDefaultFile( lrProject.getDefaultDocrootFolder().getFolder("WEB-INF"), version, id, name, themeType); } catch (IOException e) { ThemeCore.logError("Unable to load plugin package properties.", e); // $NON-NLS-1$ } } } }
public IStatus doCreateNewProject(final NewLiferayPluginProjectOp op, IProgressMonitor monitor) throws CoreException { IStatus retval = null; final IMavenConfiguration mavenConfiguration = MavenPlugin.getMavenConfiguration(); final IMavenProjectRegistry mavenProjectRegistry = MavenPlugin.getMavenProjectRegistry(); final IProjectConfigurationManager projectConfigurationManager = MavenPlugin.getProjectConfigurationManager(); final String groupId = op.getGroupId().content(); final String artifactId = op.getProjectName().content(); final String version = op.getArtifactVersion().content(); final String javaPackage = op.getGroupId().content(); final String activeProfilesValue = op.getActiveProfilesValue().content(); final PluginType pluginType = op.getPluginType().content(true); final IPortletFramework portletFramework = op.getPortletFramework().content(true); final String frameworkName = getFrameworkName(op); IPath location = PathBridge.create(op.getLocation().content()); // for location we should use the parent location if (location.lastSegment().equals(artifactId)) { // use parent dir since maven archetype will generate new dir under this location location = location.removeLastSegments(1); } String archetypeType = null; if (pluginType.equals(PluginType.portlet) && portletFramework.isRequiresAdvanced()) { archetypeType = "portlet-" + frameworkName.replace("_", "-"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } else { archetypeType = pluginType.name(); } final String archetypeArtifactId = "liferay-" + archetypeType + "-archetype"; // $NON-NLS-1$ //$NON-NLS-2$ // get latest liferay archetype monitor.beginTask( "Determining latest Liferay maven plugin archetype version.", IProgressMonitor.UNKNOWN); final String archetypeVersion = AetherUtil.getLatestAvailableLiferayArtifact( LIFERAY_ARCHETYPES_GROUP_ID, archetypeArtifactId) .getVersion(); final Archetype archetype = new Archetype(); archetype.setArtifactId(archetypeArtifactId); archetype.setGroupId(LIFERAY_ARCHETYPES_GROUP_ID); archetype.setModelEncoding("UTF-8"); archetype.setVersion(archetypeVersion); final Properties properties = new Properties(); final ResolverConfiguration resolverConfig = new ResolverConfiguration(); if (!CoreUtil.isNullOrEmpty(activeProfilesValue)) { resolverConfig.setSelectedProfiles(activeProfilesValue); } final ProjectImportConfiguration configuration = new ProjectImportConfiguration(resolverConfig); final List<IProject> newProjects = projectConfigurationManager.createArchetypeProjects( location, archetype, groupId, artifactId, version, javaPackage, properties, configuration, monitor); if (CoreUtil.isNullOrEmpty(newProjects)) { retval = LiferayMavenCore.createErrorStatus("New project was not created due to unknown error"); } else { final IProject firstProject = newProjects.get(0); // add new profiles if it was specified to add to project or parent poms if (!CoreUtil.isNullOrEmpty(activeProfilesValue)) { final String[] activeProfiles = activeProfilesValue.split(","); // find all profiles that should go in user settings file final List<NewLiferayProfile> newUserSettingsProfiles = getNewProfilesToSave( activeProfiles, op.getNewLiferayProfiles(), ProfileLocation.userSettings); if (newUserSettingsProfiles.size() > 0) { final String userSettingsFile = mavenConfiguration.getUserSettingsFile(); String userSettingsPath = null; if (CoreUtil.isNullOrEmpty(userSettingsFile)) { userSettingsPath = MavenCli.DEFAULT_USER_SETTINGS_FILE.getAbsolutePath(); } else { userSettingsPath = userSettingsFile; } try { // backup user's settings.xml file final File settingsXmlFile = new File(userSettingsPath); final File backupFile = getBackupFile(settingsXmlFile); FileUtils.copyFile(settingsXmlFile, backupFile); final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document pomDocument = docBuilder.parse(settingsXmlFile.getCanonicalPath()); for (NewLiferayProfile newProfile : newUserSettingsProfiles) { MavenUtil.createNewLiferayProfileNode(pomDocument, newProfile, archetypeVersion); } TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(pomDocument); StreamResult result = new StreamResult(settingsXmlFile); transformer.transform(source, result); } catch (Exception e) { LiferayMavenCore.logError( "Unable to save new Liferay profile to user settings.xml.", e); } } // find all profiles that should go in the project pom final List<NewLiferayProfile> newProjectPomProfiles = getNewProfilesToSave( activeProfiles, op.getNewLiferayProfiles(), ProfileLocation.projectPom); // only need to set the first project as nested projects should pickup the parent setting final IMavenProjectFacade newMavenProject = mavenProjectRegistry.getProject(firstProject); final IFile pomFile = newMavenProject.getPom(); try { final IDOMModel domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(pomFile); for (final NewLiferayProfile newProfile : newProjectPomProfiles) { MavenUtil.createNewLiferayProfileNode( domModel.getDocument(), newProfile, archetypeVersion); } domModel.save(); domModel.releaseFromEdit(); } catch (IOException e) { LiferayMavenCore.logError("Unable to save new Liferay profiles to project pom.", e); } for (final IProject project : newProjects) { try { projectConfigurationManager.updateProjectConfiguration( new MavenUpdateRequest(project, mavenConfiguration.isOffline(), true), monitor); } catch (Exception e) { LiferayMavenCore.logError("Unable to update configuration for " + project.getName(), e); } } } if (op.getPluginType().content().equals(PluginType.portlet)) { final String portletName = op.getPortletName().content(false); retval = portletFramework.postProjectCreated(firstProject, frameworkName, portletName, monitor); } } if (retval == null) { retval = Status.OK_STATUS; } return retval; }
public static synchronized IPortletFramework[] getPortletFrameworks() { if (portletFrameworks == null) { IConfigurationElement[] elements = Platform.getExtensionRegistry() .getConfigurationElementsFor(IPortletFramework.EXTENSION_ID); if (!CoreUtil.isNullOrEmpty(elements)) { List<IPortletFramework> frameworks = new ArrayList<IPortletFramework>(); for (IConfigurationElement element : elements) { String id = element.getAttribute(IPortletFramework.ID); String shortName = element.getAttribute(IPortletFramework.SHORT_NAME); String displayName = element.getAttribute(IPortletFramework.DISPLAY_NAME); String description = element.getAttribute(IPortletFramework.DESCRIPTION); String requiredSDKVersion = element.getAttribute(IPortletFramework.REQUIRED_SDK_VERSION); boolean isDefault = Boolean.parseBoolean(element.getAttribute(IPortletFramework.DEFAULT)); boolean isAdvanced = Boolean.parseBoolean(element.getAttribute(IPortletFramework.ADVANCED)); boolean isRequiresAdvanced = Boolean.parseBoolean(element.getAttribute(IPortletFramework.REQUIRES_ADVANCED)); URL helpUrl = null; try { helpUrl = new URL(element.getAttribute(IPortletFramework.HELP_URL)); } catch (Exception e1) { } try { AbstractPortletFramework framework = (AbstractPortletFramework) element.createExecutableExtension("class"); // $NON-NLS-1$ framework.setId(id); framework.setShortName(shortName); framework.setDisplayName(displayName); framework.setDescription(description); framework.setRequiredSDKVersion(requiredSDKVersion); framework.setHelpUrl(helpUrl); framework.setDefault(isDefault); framework.setAdvanced(isAdvanced); framework.setRequiresAdvanced(isRequiresAdvanced); framework.setBundleId(element.getContributor().getName()); frameworks.add(framework); } catch (Exception e) { logError("Could not create portlet framework.", e); // $NON-NLS-1$ } } portletFrameworks = frameworks.toArray(new IPortletFramework[0]); // sort the array so that the default template is first Arrays.sort( portletFrameworks, 0, portletFrameworks.length, new Comparator<IPortletFramework>() { public int compare(IPortletFramework o1, IPortletFramework o2) { if (o1.isDefault() && (!o2.isDefault())) { return -1; } else if ((!o1.isDefault()) && o2.isDefault()) { return 1; } return o1.getShortName().compareTo(o2.getShortName()); } }); } } return portletFrameworks; }
public IPath createNewProject( String projectName, ArrayList<String> arguments, String type, String workingDir, IProgressMonitor monitor) throws CoreException { CreateHelper createHelper = new CreateHelper(this, monitor); final IPath pluginFolder = getLocation().append(getPluginFolder(type)); final IPath newPath = pluginFolder.append(projectName + getPluginSuffix(type)); String createScript = ISDKConstants.CREATE_BAT; if (!CoreUtil.isWindows()) { createScript = ISDKConstants.CREATE_SH; } final IPath createFilePath = pluginFolder.append(createScript); final File createFile = createFilePath.toFile(); String originalCreateConetent = ""; if (!CoreUtil.isWindows() && createFile.exists()) { originalCreateConetent = FileUtil.readContents(createFile, true); if (originalCreateConetent.contains("DisplayName=\\\"$2\\\"")) { String createContent = originalCreateConetent.replace("DisplayName=\\\"$2\\\"", "DisplayName=\"$2\""); try { FileUtil.writeFile( createFile, new ByteArrayInputStream(createContent.toString().getBytes("UTF-8")), null); } catch (Exception e) { SDKCorePlugin.logError(e); } } } createHelper.runTarget(createFilePath, arguments, workingDir); if (!newPath.toFile().exists()) { throw new CoreException( SDKCorePlugin.createErrorStatus("Create script did not complete successfully.")); } if (!CoreUtil.isNullOrEmpty(originalCreateConetent)) { try { FileUtil.writeFile( createFile, new ByteArrayInputStream(originalCreateConetent.toString().getBytes("UTF-8")), null); } catch (Exception e) { SDKCorePlugin.logError(e); } } return newPath; }