Author: bfitzpat
Date: 2010-08-31 10:34:41 -0400 (Tue, 31 Aug 2010)
New Revision: 24575
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossRSGenerateWizardPage.java
Log:
OPEN - issue JBIDE-6752: [restwizard] provide warning if selected web project does not
have configured runtime
https://jira.jboss.org/browse/JBIDE-6752
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2010-08-31
12:14:24 UTC (rev 24574)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2010-08-31
14:34:41 UTC (rev 24575)
@@ -38,6 +38,7 @@
Error_Create_Client_Sample=When create a client sample, a error comes up. Please check
the generated files.
Error_No_Package=The service implementation selected does not follow Java naming
conventions. This may result in not being able to generate your WebService.
Error_JBossWS_GenerateWizard_WSName_Same=The Web Service Name has been used in the
web.xml of the web project.
+RestEasyLibUtils_Error_UnableToFindRuntimeForProject=Unable to find runtime associated
with selected project.
RSMergeWebXMLCommand_REST_App_Exists=Rest Application exists with same name
RSMergeWebXMLCommand_REST_Servlet_Exists=RestEasy servlet already exists.
RSMergeWebXMLCommand_REST_Servlet_Mapping_Exists=RestEasy servlet mapping already
exists.
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2010-08-31
12:14:24 UTC (rev 24574)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2010-08-31
14:34:41 UTC (rev 24575)
@@ -45,6 +45,8 @@
public static String Error_Message_No_Runtime_Specified;
public static String Error_JBossWS_GenerateWizard_WSName_Same;
+ public static String RestEasyLibUtils_Error_UnableToFindRuntimeForProject;
+
public static String RSMergeWebXMLCommand_REST_App_Exists;
public static String RSMergeWebXMLCommand_REST_Servlet_Exists;
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java 2010-08-31
14:34:41 UTC (rev 24575)
@@ -0,0 +1,123 @@
+/**
+ * JBoss by Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.tools.ws.creation.core.utils;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+import org.jboss.tools.ws.creation.core.JBossWSCreationCorePlugin;
+import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
+
+/**
+ * @author bfitzpat
+ *
+ */
+public class RestEasyLibUtils {
+
+ private static final String REST_EASY = "RestEasy"; //$NON-NLS-1$
+ private static final String JAXRS_API_JAR = "jaxrs-api.jar"; //$NON-NLS-1$
+ private static final String LIB = "lib"; //$NON-NLS-1$
+
+ /**
+ * Simple check to see if the JBoss WS runtime associated with a project
+ * actually includes the RESTEasy jars. If so, returns Status.OK_STATUS.
+ * If not, returns null.
+ *
+ * @param project
+ * @return
+ */
+ public static IStatus doesRuntimeSupportRestEasy ( IProject project ) {
+ try {
+ String path =
+ JBossWSCreationUtils.getJBossWSRuntimeLocation(project);
+ File runtime = new File(path);
+ if (runtime.exists()) {
+ File findJar = findLibDir(runtime);
+ if (findJar == null) {
+ File parent = runtime.getParentFile();
+ if (parent.exists() && parent.isDirectory()) {
+ File[] restEasyDir = parent.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ if (name.equalsIgnoreCase(REST_EASY)) {
+ return true;
+ }
+ return false;
+ }
+ });
+ if (restEasyDir != null && restEasyDir.length > 0) {
+ findJar = findLibDir(restEasyDir[0]);
+ }
+ }
+ }
+ if (findJar == null) {
+ // if it's still null, resteasy's not installed
+ return
StatusUtils.errorStatus(JBossWSCreationCoreMessages.AddRestEasyJarsCommand_RestEasy_JARS_Not_Found);
+ }
+ }
+ } catch (CoreException ce) {
+ return
StatusUtils.errorStatus(JBossWSCreationCoreMessages.RestEasyLibUtils_Error_UnableToFindRuntimeForProject);
+ }
+ return Status.OK_STATUS;
+ }
+
+ /*
+ * Finds the RESTEasy lib in the runtime path
+ * @param in
+ * @return
+ */
+ private static File findLibDir ( File in ) {
+ File[] children =
+ in.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ if (dir.isDirectory() && name.equals(LIB)) {
+ return true;
+ }
+ return false;
+ }
+ });
+ if (children != null ) {
+ for (int i = 0; i < children.length; i++) {
+ File libDir = (File) children[i];
+ if (libDir.exists() && libDir.isDirectory()) {
+ File[] jars = libDir.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ if (name.equalsIgnoreCase(JAXRS_API_JAR)) {
+ return true;
+ }
+ return false;
+ }
+ });
+ if (jars != null && jars.length > 0) {
+ return libDir;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/RestEasyLibUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-08-31
12:14:24 UTC (rev 24574)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-08-31
14:34:41 UTC (rev 24575)
@@ -7,6 +7,7 @@
# END NON-TRANSLATABLE
JBossRSGenerateWizard_RS_Wizard_Window_Title=Generate a Sample RESTful Web Service
+JBossRSGenerateWizardPage_Error_RestEasyJarsNotFoundInRuntime=RESTEasy jars not found in
the runtime associated with the selected project. Make sure RESTEasy is installed and try
again.
JBossRSGenerateWizardPage_Label_Application_Class_Name=Application Class Name:
JBossRSGenerateWizardPage_Page_title=Specify the Dynamic Web Project, service, package
and class name for the sample web service and web service classes.
JBossRSGenerateWizardValidator_ERROR_Can_Only_Add_Sample_Once=Project already has the
sample RESTful service installed. Cannot be added a second time.
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-08-31
12:14:24 UTC (rev 24574)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-08-31
14:34:41 UTC (rev 24575)
@@ -39,6 +39,7 @@
public static String Endorsed;
public static String JBossRSGenerateWizard_RS_Wizard_Window_Title;
+ public static String JBossRSGenerateWizardPage_Error_RestEasyJarsNotFoundInRuntime;
public static String JBossRSGenerateWizardPage_Label_Application_Class_Name;
public static String JBossRSGenerateWizardPage_Page_title;
public static String JBossRSGenerateWizardValidator_ERROR_Can_Only_Add_Sample_Once;
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossRSGenerateWizardPage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossRSGenerateWizardPage.java 2010-08-31
12:14:24 UTC (rev 24574)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/wizards/JBossRSGenerateWizardPage.java 2010-08-31
14:34:41 UTC (rev 24575)
@@ -36,6 +36,7 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
+import org.jboss.tools.ws.creation.core.utils.RestEasyLibUtils;
import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
public class JBossRSGenerateWizardPage extends WizardPage {
@@ -324,6 +325,13 @@
setErrorMessage(JBossWSUIMessages.Error_JBossWS_GenerateWizard_NotDynamicWebProject);
return false;
}
+
+ IStatus reInstalledStatus =
+ RestEasyLibUtils.doesRuntimeSupportRestEasy(((JBossRSGenerateWizard)
this.getWizard()).getProject());
+ if (reInstalledStatus.getSeverity() != IStatus.OK){
+ setErrorMessage(JBossWSUIMessages.JBossRSGenerateWizardPage_Error_RestEasyJarsNotFoundInRuntime);
+ return false;
+ }
// no source folder in web project
try {