Author: eschwert
Date: Fri Feb 17 20:15:42 2012
New Revision: 1245735

URL: http://svn.apache.org/viewvc?rev=1245735&view=rev
Log:
OPENMEETINGS-60 Add Gateway, RestServiceTest classes and clean code. 

Added:
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/OmPluginSettings.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmGateway.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmRestService.java
    
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/
    
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmRestServiceTest.java
Removed:
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/AdminConfiguration.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/AdminConfigurationService.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/AdminConfigurationServiceImpl.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/OmConfiguration.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/Backup2AdminServlet.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/BackupAdminServlet.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/ConfigResource.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/OmConfig.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/OpenmeetingsCRUD.java
    
incubator/openmeetings/branches/jira-plugin/src/main/resources/backup_atlassian-plugin.xml
Modified:
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/AdminServlet.java
    
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/RoomsServlet.java
    
incubator/openmeetings/branches/jira-plugin/src/main/resources/atlassian-plugin.xml

Added: 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/OmPluginSettings.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/OmPluginSettings.java?rev=1245735&view=auto
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/OmPluginSettings.java
 (added)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/ao/adminconfiguration/OmPluginSettings.java
 Fri Feb 17 20:15:42 2012
@@ -0,0 +1,39 @@
+package org.openmeetings.jira.plugin.ao.adminconfiguration;
+
+import org.openmeetings.jira.plugin.servlet.AdminServlet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory;
+
+
+public class OmPluginSettings {
+       
+       private static final Logger log = 
LoggerFactory.getLogger(OmPluginSettings.class);
+       
+    final PluginSettingsFactory pluginSettingsFactory;
+ 
+    public OmPluginSettings(PluginSettingsFactory pluginSettingsFactory) {
+        this.pluginSettingsFactory = pluginSettingsFactory;
+    }
+ 
+    public void storeSomeInfo(String key, String value) {
+        // createGlobalSettings is nice and fast, so there's no need to cache 
it (it's memoised when necessary).
+        pluginSettingsFactory.createGlobalSettings().put("my-plugin-namespace" 
+ key, value);
+    }
+ 
+    public Object getSomeInfo(String key) {
+        return 
pluginSettingsFactory.createGlobalSettings().get("my-plugin-namespace" + key);
+    }
+ 
+    public void storeSomeInfo(String projectKey, String key, String value) {
+        // createSettingsForKey is nice and fast, so there's no need to cache 
it (it's memoised when necessary).
+        
pluginSettingsFactory.createSettingsForKey(projectKey).put("my-plugin-namespace"
 + key, value);
+    }
+ 
+    public Object getSomeInfo(String projectKey, String key) {
+        return 
pluginSettingsFactory.createSettingsForKey(projectKey).get("my-plugin-namespace"
 + key);
+    }
+ 
+     
+}
\ No newline at end of file

Added: 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmGateway.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmGateway.java?rev=1245735&view=auto
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmGateway.java
 (added)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmGateway.java
 Fri Feb 17 20:15:42 2012
@@ -0,0 +1,42 @@
+package org.openmeetings.jira.plugin.gateway;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.openmeetings.jira.plugin.ao.adminconfiguration.OmPluginSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
+
+import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory;
+
+public class OmGateway {
+       
+       private static final Logger log = 
LoggerFactory.getLogger(OmGateway.class);
+       
+       private OmRestService omRestService;
+       private OmPluginSettings omPluginSettings;
+
+       public OmGateway(OmRestService omRestService,
+                       OmPluginSettings omPluginSettings) {            
+               this.omRestService = omRestService;
+               this.omPluginSettings = omPluginSettings;
+       }       
+       
+       public void loginUser() throws XPathExpressionException, IOException, 
ServletException, SAXException, ParserConfigurationException{
+               
+               String url = (String)omPluginSettings.getSomeInfo("url"); 
+       String port = (String)omPluginSettings.getSomeInfo("port");             
+       String userpass = (String)omPluginSettings.getSomeInfo("userpass");  
+       String omusername = (String)omPluginSettings.getSomeInfo("username"); 
+       String key = (String)omPluginSettings.getSomeInfo("key"); 
+               
+       String sessionURL = 
"http://"+url+":"+port+"/openmeetings/services/UserService/getSession";;
+       
+               omRestService.call(sessionURL, null);
+       }
+       
+}

Added: 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmRestService.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmRestService.java?rev=1245735&view=auto
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmRestService.java
 (added)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmRestService.java
 Fri Feb 17 20:15:42 2012
@@ -0,0 +1,137 @@
+package org.openmeetings.jira.plugin.gateway;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.*;
+
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.openmeetings.jira.plugin.ao.adminconfiguration.OmPluginSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OmRestService {
+       
+       private static final Logger log = 
LoggerFactory.getLogger(OmRestService.class);
+       
+       
+       public String call(String request, Object param)throws IOException, 
ServletException, SAXException, ParserConfigurationException, 
XPathExpressionException
+       {
+               //String request = 
"http://api.search.yahoo.com/WebSearchService/V1/webSearch";;
+           HttpClient client = new HttpClient();
+       
+           PostMethod method = new PostMethod(request);
+       
+           // Add POST parameters
+           
+           method.addParameter("roomId","1");
+//     
+//         method.addParameter("query","umbrella");
+//     
+//         method.addParameter("results","10");            
+           
+           // Send POST request
+
+       
+           InputStream rstream = null;
+       
+           
+           // Get the response body
+       
+           try {
+                       rstream = method.getResponseBodyAsStream();
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+           
+           int statusCode = 0;
+               try {
+                       statusCode = client.executeMethod(method);
+               } catch (HttpException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+
+           
+
+           switch (statusCode) {
+           
+                   case 200: {
+                       
+                   System.out.println("Success connection");
+       
+                   break;
+       
+                   }
+                   case 400: {
+       
+                   System.out.println("Bad request. The parameters passed to 
the service did not match as expected. The Message should tell you what was 
missing or incorrect."); 
+       
+                   System.out.println("Change the parameter appcd to appid and 
this error message will go away.");
+       
+                   break;
+
+           }
+
+                   case 403: {
+       
+                   System.out.println("Forbidden. You do not have permission 
to access this resource, or are over your rate limit.");
+       
+                   break;
+
+           }
+
+                   case 503: {
+       
+                   System.out.println("Service unavailable. An internal 
problem prevented us from returning data to you.");
+       
+                   break;
+
+           }
+
+                   default: System.out.println("Your call to Yahoo! Web 
Services returned an unexpected  HTTP status of: " + statusCode);
+
+           }
+           
+           
+        // Process response
+//        Document response = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(rstream);      
+//
+//        
+//        XPathFactory factory = XPathFactory.newInstance();
+//        XPath xPath=factory.newXPath();
+//        
+//        //Get all search Result nodes
+//        NodeList nodes = (NodeList)xPath.evaluate("/ResultSet/Result", 
response, XPathConstants.NODESET);
+//        int nodeCount = nodes.getLength();
+//        
+//        //iterate over search Result nodes
+//        for (int i = 0; i < nodeCount; i++) {
+//            //Get each xpath expression as a string
+//             String title = (String)xPath.evaluate("Title", nodes.item(i), 
XPathConstants.STRING);
+//            String summary = (String)xPath.evaluate("Summary", 
nodes.item(i), XPathConstants.STRING);
+//            String url = (String)xPath.evaluate("Url", nodes.item(i), 
XPathConstants.STRING);
+//            //print out the Title, Summary, and URL for each search result
+//            System.out.println("Title: " + title);
+//            System.out.println("Summary: " + summary);
+//            System.out.println("URL: " + url);
+//            System.out.println("--");
+//            
+//        }
+//        System.out.println(rstream);
+               return rstream.toString();
+           
+       }
+}

Modified: 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/AdminServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/AdminServlet.java?rev=1245735&r1=1245734&r2=1245735&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/AdminServlet.java
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/AdminServlet.java
 Fri Feb 17 20:15:42 2012
@@ -12,9 +12,7 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.openmeetings.jira.plugin.ao.adminconfiguration.AdminConfiguration;
-import 
org.openmeetings.jira.plugin.ao.adminconfiguration.AdminConfigurationService;
-import 
org.openmeetings.jira.plugin.ao.adminconfiguration.AdminConfigurationServiceImpl;
+import org.openmeetings.jira.plugin.ao.adminconfiguration.OmPluginSettings;
 import org.openmeetings.jira.plugin.ao.omrooms.Room;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,10 +43,7 @@ public class AdminServlet extends HttpSe
     private TemplateRenderer templateRenderer;
     private com.atlassian.jira.user.util.UserManager jiraUserManager;
    
-
-    //private final ActiveObjects ao;
-    private final AdminConfigurationService adminOmConfigurationService;
-    final PluginSettingsFactory pluginSettingsFactory;
+    private OmPluginSettings omPluginSettings;    
     
     private static final String NEW_BROWSER_TEMPLATE = 
"/templates/adminnew.vm";
     private static final String EDIT_BROWSER_TEMPLATE = 
"/templates/adminedit.vm";
@@ -59,15 +54,15 @@ public class AdminServlet extends HttpSe
 //    }
     
     public AdminServlet(com.atlassian.jira.user.util.UserManager 
jiraUserManager, 
-                                               TemplateRenderer 
templateRenderer,
-                                               AdminConfigurationService 
adminOmConfigurationService,
-                                               UserManager userManager, 
PluginSettingsFactory pluginSettingsFactory)
+                                               TemplateRenderer 
templateRenderer,                                              
+                                               UserManager userManager,
+                                               OmPluginSettings 
omPluginSettings)
     {
-        this.userManager = userManager;              
-        this.adminOmConfigurationService = 
checkNotNull(adminOmConfigurationService);
+        this.userManager = userManager;
         this.templateRenderer = templateRenderer;
         this.jiraUserManager = jiraUserManager;
-        this.pluginSettingsFactory = pluginSettingsFactory;
+        //this.pluginSettingsFactory = pluginSettingsFactory;
+        this.omPluginSettings = omPluginSettings;
        
         
     }
@@ -96,48 +91,33 @@ public class AdminServlet extends HttpSe
         } else if ("y".equals(request.getParameter("edit"))) {
             // Renders edit.vm template if the "edit" parameter is passed
      
-            // Retrieve issue with the specified key
-               AdminConfiguration omConfig =  
adminOmConfigurationService.get(request.getParameter("key"));// 
req.getParameter("key"));
-            Map<String, Object> context = Maps.newHashMap();
-            context.put("omConfig", omConfig);
-            response.setContentType("text/html;charset=utf-8");
-            // Render the template with the issue inside the context
-            templateRenderer.render(EDIT_BROWSER_TEMPLATE, context, 
response.getWriter());
-        } else {
-//            // Render the list of issues (list.vm) if no params are passed in
-//            List<Issue> issues = getIssues(request);
+//            // Retrieve issue with the specified key
+//             AdminConfiguration omConfig =  
adminOmConfigurationService.get(request.getParameter("key"));// 
req.getParameter("key"));
 //            Map<String, Object> context = Maps.newHashMap();
-//            context.put("issues", issues);
+//            context.put("omConfig", omConfig);
 //            response.setContentType("text/html;charset=utf-8");
-//            // Pass in the list of issues as the context
-//            templateRenderer.render(LIST_BROWSER_TEMPLATE, context, 
response.getWriter());
-                //Retrieve issue with the specified key
-               //String url = getSomeInfo("url").toString();
-               
-//             String url = request.getParameter("url"); 
-//             String port = request.getParameter("port");             
-//             String userpass = request.getParameter("userpass"); 
-//             String omusername = request.getParameter("username"); 
-//             String key = request.getParameter("key");
-               
+//            // Render the template with the issue inside the context
+//            templateRenderer.render(EDIT_BROWSER_TEMPLATE, context, 
response.getWriter());
+        } else {
+                               
                String url; 
                String port;            
                String userpass;
                String omusername;
                String key; 
                
-               if( getSomeInfo("url").equals(null)){
+               if( omPluginSettings.getSomeInfo("url") == null){
                        url = "localhost"; 
                        port = "5080";          
                        userpass = "admin";  
                        omusername = "admin"; 
                        key = "Jira";                   
                }else{
-                       url = (String)getSomeInfo("url"); 
-                       port = (String)getSomeInfo("port");             
-                       userpass = (String)getSomeInfo("userpass");  
-                       omusername = (String)getSomeInfo("username"); 
-                       key = (String)getSomeInfo("key"); 
+                       url = (String)omPluginSettings.getSomeInfo("url"); 
+                       port = (String)omPluginSettings.getSomeInfo("port");    
        
+                       userpass = 
(String)omPluginSettings.getSomeInfo("userpass");  
+                       omusername = 
(String)omPluginSettings.getSomeInfo("username"); 
+                       key = (String)omPluginSettings.getSomeInfo("key"); 
                }
                
             Map<String, Object> context = Maps.newHashMap();
@@ -151,41 +131,7 @@ public class AdminServlet extends HttpSe
             response.setContentType("text/html;charset=utf-8");
             // Render the template with the issue inside the context
             templateRenderer.render(OM_CONFIG_TEMPLATE, context, 
response.getWriter());
-        }
-        /////////////
-       // response.setContentType("text/html;charset=utf-8");
-        //renderer.render("admin.vm", response.getWriter());
-        
-//        final PrintWriter w = response.getWriter();
-//        w.write("<h1>Test Admin Key-Values</h1>");
-// 
-//        
-//     // the form to post more TODOs
-//        w.write("<form method=\"post\">");
-//        w.write("<input type=\"text\" name=\"url\" size=\"25\"/>");
-//        w.write("<input type=\"text\" name=\"port\" size=\"25\"/>");
-//        w.write("<input type=\"text\" name=\"username\" size=\"25\"/>");
-//        w.write("<input type=\"text\" name=\"userpass\" size=\"25\"/>");
-//        w.write("<input type=\"text\" name=\"key\" size=\"25\"/>");
-//        w.write("&nbsp;&nbsp;");
-//        w.write("<input type=\"submit\" name=\"submit\" value=\"Add\"/>");
-//        w.write("</form>");
-//        
-// 
-//        w.write("<ol>");
-// 
-//        //getSomeInfo("url");
-//            w.printf("<li> %s </li>", getSomeInfo("url"));
-//            w.printf("<li><%2$s> %s </%2$s></li>", getSomeInfo("port"), true 
? "strong" : "strong");
-//            w.printf("<li> %s </li>", getSomeInfo("userpass"));
-//            w.printf("<li> %s </li>", getSomeInfo("username"));
-//            w.printf("<li> %s </li>", getSomeInfo("key"));
-//       
-// 
-//        w.write("</ol>");
-//        w.write("<script 
language='javascript'>document.forms[0].elements[0].focus();</script>");
-// 
-//        w.close();
+        }     
 
     }
     
@@ -205,11 +151,11 @@ public class AdminServlet extends HttpSe
                String username = request.getParameter("username"); 
                String key = request.getParameter("key");
                
-               storeSomeInfo("url", url);
-               storeSomeInfo("port", port);
-               storeSomeInfo("userpass", userpass);
-               storeSomeInfo("username", username);
-               storeSomeInfo("key", key);
+               omPluginSettings.storeSomeInfo("url", url);
+               omPluginSettings.storeSomeInfo("port", port);
+               omPluginSettings.storeSomeInfo("userpass", userpass);
+               omPluginSettings.storeSomeInfo("username", username);
+               omPluginSettings.storeSomeInfo("key", key);
                
             
             response.sendRedirect(request.getContextPath() + 
"/plugins/servlet/openmeetingsadmin");
@@ -242,22 +188,22 @@ public class AdminServlet extends HttpSe
            return jiraUserManager.getUser(userManager.getRemoteUsername(req));
        }
     
-    public void storeSomeInfo(String key, String value) {
-        // createGlobalSettings is nice and fast, so there's no need to cache 
it (it's memoised when necessary).
-        pluginSettingsFactory.createGlobalSettings().put("openmeetings:" + 
key, value);
-        
-    }
- 
-    public Object getSomeInfo(String key) {
-        return 
pluginSettingsFactory.createGlobalSettings().get("openmeetings:" + key);
-    }
- 
-    public void storeSomeInfo(String projectKey, String key, String value) {
-        // createSettingsForKey is nice and fast, so there's no need to cache 
it (it's memoised when necessary).
-        
pluginSettingsFactory.createSettingsForKey(projectKey).put("openmeetings:" + 
key, value);
-    }
- 
-    public Object getSomeInfo(String projectKey, String key) {
-        return 
pluginSettingsFactory.createSettingsForKey(projectKey).get("openmeetings:" + 
key);
-    }
+//    public void storeSomeInfo(String key, String value) {
+//        // createGlobalSettings is nice and fast, so there's no need to 
cache it (it's memoised when necessary).
+//        pluginSettingsFactory.createGlobalSettings().put("openmeetings:" + 
key, value);
+//        
+//    }
+// 
+//    public Object getSomeInfo(String key) {
+//        return 
pluginSettingsFactory.createGlobalSettings().get("openmeetings:" + key);
+//    }
+// 
+//    public void storeSomeInfo(String projectKey, String key, String value) {
+//        // createSettingsForKey is nice and fast, so there's no need to 
cache it (it's memoised when necessary).
+//        
pluginSettingsFactory.createSettingsForKey(projectKey).put("openmeetings:" + 
key, value);
+//    }
+// 
+//    public Object getSomeInfo(String projectKey, String key) {
+//        return 
pluginSettingsFactory.createSettingsForKey(projectKey).get("openmeetings:" + 
key);
+//    }
 }

Modified: 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/RoomsServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/RoomsServlet.java?rev=1245735&r1=1245734&r2=1245735&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/RoomsServlet.java
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/RoomsServlet.java
 Fri Feb 17 20:15:42 2012
@@ -5,9 +5,13 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
 
 import org.openmeetings.jira.plugin.ao.omrooms.Room;
 import org.openmeetings.jira.plugin.ao.omrooms.RoomService;
+import org.openmeetings.jira.plugin.gateway.OmGateway;
+import org.xml.sax.SAXException;
 
 import com.atlassian.crowd.embedded.api.User;
 import com.atlassian.jira.bc.issue.IssueService;
@@ -26,15 +30,18 @@ public final class RoomsServlet extends 
 {
     private final RoomService roomService;
     private TemplateRenderer templateRenderer;
+    private OmGateway omGateway;
     
     private static final String LIST_BROWSER_TEMPLATE = 
"/templates/omrooms/list.vm";
     private static final String NEW_BROWSER_TEMPLATE = 
"/templates/omrooms/new.vm";
     private static final String EDIT_BROWSER_TEMPLATE = 
"/templates/omrooms/edit.vm";
  
-    public RoomsServlet(RoomService roomService, TemplateRenderer 
templateRenderer)
+    public RoomsServlet(RoomService roomService, TemplateRenderer 
templateRenderer, OmGateway omGateway)
     {
         this.roomService = checkNotNull(roomService);
         this.templateRenderer = templateRenderer;
+        this.omGateway = omGateway;
+        
     }
  
     @Override
@@ -131,6 +138,19 @@ public final class RoomsServlet extends 
                Long numberOfParticipent = 
Long.valueOf(req.getParameter("numberOfParticipent"));  
                Long roomType = Long.valueOf(req.getParameter("roomType")); 
                
+//             try {
+//                             omGateway.loginUser();
+//                     } catch (XPathExpressionException e) {
+//                             // TODO Auto-generated catch block
+//                             e.printStackTrace();
+//                     } catch (SAXException e) {
+//                             // TODO Auto-generated catch block
+//                             e.printStackTrace();
+//                     } catch (ParserConfigurationException e) {
+//                             // TODO Auto-generated catch block
+//                             e.printStackTrace();
+//                     }
+               
                roomService.add(isAllowedRecording, isAudioOnly, 
isModeratedRoom, name, numberOfParticipent, roomType);
             //roomService.add(description, true, true, true, "name", 4L, 1L);
 

Modified: 
incubator/openmeetings/branches/jira-plugin/src/main/resources/atlassian-plugin.xml
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/resources/atlassian-plugin.xml?rev=1245735&r1=1245734&r2=1245735&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/resources/atlassian-plugin.xml
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/resources/atlassian-plugin.xml
 Fri Feb 17 20:15:42 2012
@@ -30,16 +30,8 @@
   <web-item key="create_room_link" name="Create Room Web Site" 
section="my_links_link/my_links_section" weight="10">
     <label>Create Room</label>
     <link linkId="create_room_link" 
absolute="false">/plugins/servlet/openmeetingsrooms?new=y</link>/&gt;
-  </web-item>
-  <web-item key="test_link" name="Test Web Site" 
section="my_links_link/my_links_section" weight="10">
-    <label>Test CRUD</label>
-    <link linkId="test_link" 
absolute="false">/plugins/servlet/openmeetingscrud</link>/&gt;
-  </web-item>
+  </web-item>  
   
-  <servlet name="Openmeetings CRUD" i18n-name-key="openmeetings-crud.name" 
key="openmeetings-crud" 
class="org.openmeetings.jira.plugin.servlet.OpenmeetingsCRUD">
-    <description key="openmeetings-crud.description">The Openmeetings CRUD 
Plugin</description>
-    <url-pattern>/openmeetingscrud</url-pattern>
-  </servlet>
   <servlet name="Openmeetings admin" i18n-name-key="openmeetings-admin.name" 
key="openmeetings-admin" 
class="org.openmeetings.jira.plugin.servlet.AdminServlet">
     <description key="openmeetings-admin.description">The Openmeetings Admin 
Plugin</description>
     <url-pattern>/openmeetingsadmin</url-pattern>
@@ -62,8 +54,7 @@
   
        <!--AO to persist chosen admin configuration -->
        <ao key="openmeetings-ao-module">
-           <description>The module configuring the Active Objects service used 
by JIRA-OPENMEETINGS plugin</description>
-           
<entity>org.openmeetings.jira.plugin.ao.adminconfiguration.AdminConfiguration</entity>
+           <description>The module configuring the Active Objects service used 
by JIRA-OPENMEETINGS plugin</description>           
            <entity>org.openmeetings.jira.plugin.ao.omrooms.Room</entity>       
  
        </ao>
        
@@ -77,14 +68,14 @@
        <component key="tx-processor" name="Transactional Annotation Processor"
                   
class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor">
            <decription>Processes @Transactional annotations.</decription>
-       </component>
-       
-       <component key="adminOmConfigurationService" name="AdminOmConfiguration 
Service"
-              
class="org.openmeetings.jira.plugin.ao.adminconfiguration.AdminConfigurationServiceImpl"
 public="true">
-               
<interface>org.openmeetings.jira.plugin.ao.adminconfiguration.AdminConfigurationService</interface>
-       </component>
+       </component>    
        
        <component key="room-service" name="Room Service" 
class="org.openmeetings.jira.plugin.ao.omrooms.RoomServiceImpl"/>
-
-
+       
+       <component key="omPluginSettings" name="OpenMeetings Plugin Settings" 
class="org.openmeetings.jira.plugin.ao.adminconfiguration.OmPluginSettings"/>
+       
+       <component key="omRestService" name="OpenMeetings REST Service" 
class="org.openmeetings.jira.plugin.gateway.OmRestService"/>
+       
+       <component key="omGateway" name="OpenMeetings Gateway" 
class="org.openmeetings.jira.plugin.gateway.OmGateway"/>
+       
 </atlassian-plugin>

Added: 
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmRestServiceTest.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmRestServiceTest.java?rev=1245735&view=auto
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmRestServiceTest.java
 (added)
+++ 
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmRestServiceTest.java
 Fri Feb 17 20:15:42 2012
@@ -0,0 +1,124 @@
+package org.openmeetings.jira.plugin.gateway;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Before;
+import org.mockito.Mockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+public class OmRestServiceTest {
+       private static final Logger log = 
LoggerFactory.getLogger(OmRestServiceTest.class);
+       
+    HttpServletRequest mockRequest;
+    HttpServletResponse mockResponse;
+    
+    private OmRestService omRestService;
+
+    @Before
+    public void setup() {
+//        mockRequest = mock(HttpServletRequest.class);
+//        mockResponse = mock(HttpServletResponse.class);
+       omRestService = new OmRestService();
+    }
+
+    @After
+    public void tearDown() {
+
+    }
+    
+    private URI getBaseURI() {
+               return UriBuilder.fromUri(
+                               
"http://localhost:5080/openmeetings/services/UserService/getSession";).build();
+       }
+
+    @Test
+    public void testCall() throws SAXException, IOException, 
ParserConfigurationException, XPathExpressionException {
+//        String expected = "test";
+//        
when(mockRequest.getParameter(Mockito.anyString())).thenReturn(expected);
+//        assertEquals(expected,mockRequest.getParameter("some string"));
+       
+       ///////////
+       //String rstream = 
omRestService.call("http://localhost:5080/openmeetings/services/UserService/getSession";,
 null);
+       //log.error("error",rstream);
+       ////////////    
+       
+       
+       
+//     ClientConfig config = new DefaultClientConfig();
+//             Client client = Client.create(config);
+//             WebResource service = client.resource(getBaseURI());
+//             // Get XML
+//             System.out.println(service.path("rest").path("todo").accept(
+//                             MediaType.TEXT_XML).get(String.class));
+//             // Get XML for application
+//             System.out.println(service.path("rest").path("todo").accept(
+//                             MediaType.APPLICATION_JSON).get(String.class));
+//             // Get JSON for application
+//             System.out.println(service.path("rest").path("todo").accept(
+//                             MediaType.APPLICATION_XML).get(String.class));
+//     
+//             System.out.println(service.accept(
+//                             MediaType.APPLICATION_JSON).get(String.class));
+//             
+//             String rstream = service.accept(
+//                             MediaType.TEXT_XML).get(String.class);
+//             
+               
+               
+                       
+               
+//             Document response = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(rstream);      
+//
+//        
+//        XPathFactory factory = XPathFactory.newInstance();
+//        XPath xPath=factory.newXPath();
+//        
+//        //Get all search Result nodes
+//        NodeList nodes = 
(NodeList)xPath.evaluate("/getSessionResponse/return", response, 
XPathConstants.NODESET);
+//        int nodeCount = nodes.getLength();
+//        
+//        //iterate over search Result nodes
+//        for (int i = 0; i < nodeCount; i++) {
+//            //Get each xpath expression as a string
+//             String title = (String)xPath.evaluate("Title", nodes.item(i), 
XPathConstants.STRING);
+//            String summary = (String)xPath.evaluate("Summary", 
nodes.item(i), XPathConstants.STRING);
+//            String url = (String)xPath.evaluate("Url", nodes.item(i), 
XPathConstants.STRING);
+//            //print out the Title, Summary, and URL for each search result
+//            System.out.println("Title: " + title);
+//            System.out.println("Summary: " + summary);
+//            System.out.println("URL: " + url);
+//            System.out.println("--");
+//            
+//        }
+               
+    }
+}


Reply via email to