Author: eschwert
Date: Fri Feb 24 20:42:55 2012
New Revision: 1293406

URL: http://svn.apache.org/viewvc?rev=1293406&view=rev
Log:
OPENMEETINGS-60 Add Exception handling and error messages

Modified:
    
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/main/java/org/openmeetings/jira/plugin/servlet/RoomsServlet.java
    
incubator/openmeetings/branches/jira-plugin/src/main/resources/i18n.properties
    
incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/enter.vm
    
incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/list.vm
    
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmGatawayTest.java
    
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmRestServiceTest.java

Modified: 
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=1293406&r1=1293405&r2=1293406&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmGateway.java
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmGateway.java
 Fri Feb 24 20:42:55 2012
@@ -26,31 +26,39 @@ public class OmGateway {
                this.omPluginSettings = omPluginSettings;
        }       
        
-       public Boolean loginUser() throws XPathExpressionException, 
IOException, ServletException, SAXException, ParserConfigurationException, 
DocumentException{
+       public Boolean loginUser() throws Exception{
                
-               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";;
-       
-       LinkedHashMap<String,Element> elementMap = 
omRestService.call(sessionURL, null);
-               
-       Element item = elementMap.get("return");
-       
-       this.setSessionId(item.elementText("session_id"));
-       
-               log.info(item.elementText("session_id"));
+               LinkedHashMap<String, Element> result=null;
                
-               LinkedHashMap<String, Element> result = 
omRestService.call("http://"+url+":"+port+"/openmeetings/services/UserService/loginUser?SID="+this.getSessionId()+"&username="+omusername+"&userpass="+userpass,
 null);
+               try{
+                       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";;
+               
+               LinkedHashMap<String,Element> elementMap = 
omRestService.call(sessionURL, null);
+                       
+               Element item = elementMap.get("return");
+               
+               this.setSessionId(item.elementText("session_id"));
+               
+                       log.info(item.elementText("session_id"));
+                       
+                       result = 
omRestService.call("http://"+url+":"+port+"/openmeetings/services/UserService/loginUser?SID="+this.getSessionId()+"&username="+omusername+"&userpass="+userpass,
 null);
+                       
+               }catch(Exception e){
+                       throw new Exception(e);
+               }
                
                if (Integer.valueOf(result.get("return").getStringValue())>0){
                return true; 
                } else {
                        return false;
                }
+               
        }
        
        public Long addRoomWithModerationExternalTypeAndTopBarOption(   Boolean 
isAllowedRecording,
@@ -59,34 +67,33 @@ public class OmGateway {
                                                                                
                                                        String name,
                                                                                
                                                        Long 
numberOfParticipent,
                                                                                
                                                        Long roomType 
-                                                                               
                                                ) throws        
XPathExpressionException, 
-                                                                               
                                                                        
IOException, 
-                                                                               
                                                                        
ServletException, 
-                                                                               
                                                                        
SAXException, 
-                                                                               
                                                                        
ParserConfigurationException, DocumentException{
-                       
-       String restURL = 
"http://localhost:5080/openmeetings/services/RoomService/addRoomWithModerationExternalTypeAndTopBarOption?";
 +
-                                               "SID="+this.getSessionId()+
-                                               "&name="+name+
-                                                       
"&roomtypes_id="+roomType.toString()+
-                                                       "&comment=jira"+
-                                                       
"&numberOfPartizipants="+numberOfParticipent.toString()+
-                                                       "&ispublic=false"+
-                                                       "&appointment=false"+
-                                                       "&isDemoRoom=false"+
-                                                       "&demoTime="+
-                                                       
"&isModeratedRoom="+isModeratedRoom.toString()+
-                                                       
"&externalRoomType=jira"+
-                                                       "&allowUserQuestions="+
-                                                       
"&isAudioOnly="+isAudioOnly.toString()+
-                                                       
"&waitForRecording=false"+
-                                                       
"&allowRecording="+isAllowedRecording.toString()+
-                                                       "&hideTopBar=false";
-               
-               LinkedHashMap<String, Element> result = 
omRestService.call(restURL, null);              
-               
-               String roomId = result.get("return").getStringValue();
-               
+                                                                               
                                                ) throws        Exception{
+               String roomId ="";
+               try{            
+               String restURL = 
"http://localhost:5080/openmeetings/services/RoomService/addRoomWithModerationExternalTypeAndTopBarOption?";
 +
+                                                       
"SID="+this.getSessionId()+
+                                                       "&name="+name+
+                                                               
"&roomtypes_id="+roomType.toString()+
+                                                               "&comment=jira"+
+                                                               
"&numberOfPartizipants="+numberOfParticipent.toString()+
+                                                               
"&ispublic=false"+
+                                                               
"&appointment=false"+
+                                                               
"&isDemoRoom=false"+
+                                                               "&demoTime="+
+                                                               
"&isModeratedRoom="+isModeratedRoom.toString()+
+                                                               
"&externalRoomType=jira"+
+                                                               
"&allowUserQuestions="+
+                                                               
"&isAudioOnly="+isAudioOnly.toString()+
+                                                               
"&waitForRecording=false"+
+                                                               
"&allowRecording="+isAllowedRecording.toString()+
+                                                               
"&hideTopBar=false";
+                       
+                       LinkedHashMap<String, Element> result = 
omRestService.call(restURL, null);              
+                       
+                       roomId = result.get("return").getStringValue();
+               }catch(Exception e){
+                       throw new Exception(e);
+               }
        return Long.valueOf(roomId);
     }
        
@@ -97,56 +104,52 @@ public class OmGateway {
                                                                                
                                Long numberOfParticipent,
                                                                                
                                Long roomType,
                                                                                
                                Long roomId
-                                                                               
                                ) throws        XPathExpressionException, 
-                                                                               
                                                        IOException, 
-                                                                               
                                                        ServletException, 
-                                                                               
                                                        SAXException, 
-                                                                               
                                                        
ParserConfigurationException, 
-                                                                               
                                                        DocumentException{
-
-       
-               String restURL = 
"http://localhost:5080/openmeetings/services/RoomService/updateRoomWithModerationAndQuestions?";
 +
-                                                       
"SID="+this.getSessionId()+
-                                                       
"&room_id="+roomId.toString()+
-                                                       
"&name="+roomname.toString()+
-                                                       
"&roomtypes_id="+roomType.toString()+
-                                                       "&comment="+
-                                                       
"&numberOfPartizipants="+numberOfParticipent.toString()+
-                                                       "&ispublic=false"+
-                                                       "&appointment=false"+
-                                                       "&isDemoRoom=false"+
-                                                       "&demoTime="+
-                                                       
"&isModeratedRoom="+isModeratedRoom.toString()+                                 
                
-                                                       "&allowUserQuestions=";
-               
-                                               //Is not available for update 
method    
-//                                                     
"&externalRoomType=jira"+
-//                                                     
"&isAudioOnly="+isAudioOnly+
-//                                                     
"&waitForRecording=false"+
-//                                                     
"&allowRecording="+isAllowedRecording+
-//                                                     "&hideTopBar=false";
-               
-               LinkedHashMap<String, Element> result = 
omRestService.call(restURL, null);              
-               
-               log.info("addRoomWithModerationExternalTypeAndTopBarOption with 
ID: ",result.get("return").getStringValue());
-               
-               String updateRoomId = result.get("return").getStringValue();
+                                                                               
                                ) throws        Exception{
                
+               String updateRoomId = "";
+               try{
+       
+                       String restURL = 
"http://localhost:5080/openmeetings/services/RoomService/updateRoomWithModerationAndQuestions?";
 +
+                                                               
"SID="+this.getSessionId()+
+                                                               
"&room_id="+roomId.toString()+
+                                                               
"&name="+roomname.toString()+
+                                                               
"&roomtypes_id="+roomType.toString()+
+                                                               "&comment="+
+                                                               
"&numberOfPartizipants="+numberOfParticipent.toString()+
+                                                               
"&ispublic=false"+
+                                                               
"&appointment=false"+
+                                                               
"&isDemoRoom=false"+
+                                                               "&demoTime="+
+                                                               
"&isModeratedRoom="+isModeratedRoom.toString()+                                 
                
+                                                               
"&allowUserQuestions=";
+                       
+                                                       //Is not available for 
update method    
+       //                                                      
"&externalRoomType=jira"+
+       //                                                      
"&isAudioOnly="+isAudioOnly+
+       //                                                      
"&waitForRecording=false"+
+       //                                                      
"&allowRecording="+isAllowedRecording+
+       //                                                      
"&hideTopBar=false";
+                       
+                       LinkedHashMap<String, Element> result = 
omRestService.call(restURL, null);              
+                       
+                       
log.info("addRoomWithModerationExternalTypeAndTopBarOption with ID: 
",result.get("return").getStringValue());
+                       
+                       updateRoomId = result.get("return").getStringValue();
+                        
+               }catch(Exception e){
+                       throw new Exception(e);
+               }
                return Long.valueOf(updateRoomId);
        }
        
        public String setUserObjectAndGenerateRoomHash (String username , 
String firstname , 
                        String lastname , String profilePictureUrl , String 
email , Long externalUserId , 
                        String externalUserType , Long room_id , int 
becomeModeratorAsInt , int showAudioVideoTestAsInt ) 
-                                                                               
                                                        throws 
XPathExpressionException, 
-                                                                               
                                                        IOException, 
-                                                                               
                                                        ServletException, 
-                                                                               
                                                        SAXException, 
-                                                                               
                                                        
ParserConfigurationException, 
-                                                                               
                                                        DocumentException 
-       {               
-               
-               String restURL = 
"http://localhost:5080/openmeetings/services/UserService/setUserObjectAndGenerateRoomHash?";
 +
+                                                                               
                                                        throws Exception 
+       {       
+               String roomHash = null; 
+               try{            
+                       String restURL = 
"http://localhost:5080/openmeetings/services/UserService/setUserObjectAndGenerateRoomHash?";
 +
                                "SID="+this.getSessionId()+
                                "&username="+username+
                                "&firstname="+firstname+
@@ -162,10 +165,14 @@ public class OmGateway {
        
                                LinkedHashMap<String, Element> result = 
omRestService.call(restURL, null);              
                                
-                               String roomHash = 
result.get("return").getStringValue();
+                                roomHash = 
result.get("return").getStringValue();
                                
-                               return roomHash;
+                               //return roomHash;
+               }catch(Exception e){
+                       throw new Exception(e);
+               }
                
+               return roomHash;
        }
 
        public String getSessionId() {

Modified: 
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=1293406&r1=1293405&r2=1293406&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmRestService.java
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/gateway/OmRestService.java
 Fri Feb 24 20:42:55 2012
@@ -5,6 +5,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
@@ -17,6 +18,7 @@ import javax.xml.parsers.ParserConfigura
 import javax.xml.xpath.XPathExpressionException;
 
 import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.dom4j.Document;
 import org.dom4j.DocumentException;
@@ -40,77 +42,121 @@ public class OmRestService {
                return new URL(url).toString().replaceAll(" ","%20");
        }       
        
-       public LinkedHashMap<String, Element> call(String request, Object 
param)throws IOException, ServletException, SAXException, 
ParserConfigurationException, XPathExpressionException, DocumentException
+       public LinkedHashMap<String, Element> call(String request, Object 
param) throws Exception
        {                               
                HttpClient client = new HttpClient();
-
-        GetMethod method = new GetMethod(getEncodetURI(request).toString());
-               int statusCode = client.executeMethod(method);
+        GetMethod method = null;
+        
+               try {
+                       method = new 
GetMethod(getEncodetURI(request).toString());
+               } catch (MalformedURLException 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();
+                       throw new Exception("Connection to OpenMeetings 
refused. Please check your OpenMeetings configuration. HttpException");
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       //e.printStackTrace();
+                       throw new Exception("Connection to OpenMeetings 
refused. Please check your OpenMeetings configuration. IOException");
+               }
+               
                
                switch (statusCode) {
            
-           case 200: {
+                   case 200: {                 
+                           System.out.println("Success connection");           
            
+                           break;      
+                   }
+                   case 400: {                 
+                               throw new Exception("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("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;
-
-           }
+                           //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."); 
+                    
+                               //break;
        
+                   }   
                    case 403: {
+                               throw new Exception("Forbidden. You do not have 
permission to access this resource, or are over your rate limit.");
        
-                   System.out.println("Forbidden. You do not have permission 
to access this resource, or are over your rate limit.");
-       
-                   break;
-       
-           }
+                               //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 OpenMeetings! Web 
Services returned an unexpected  HTTP status of: " + statusCode);
-       
+                               throw new Exception("Service unavailable. An 
internal problem prevented us from returning data to you.");
+
+                               //System.out.println("Service unavailable. An 
internal problem prevented us from returning data to you.");
+               
+                           //break;
+               
+                   }                       
+                   default:{ 
+                                       throw new Exception("Your call to 
OpenMeetings! Web Services returned an unexpected  HTTP status of: " + 
statusCode);
+       
+                               //System.out.println("Your call to 
OpenMeetings! Web Services returned an unexpected  HTTP status of: " + 
statusCode);
+                   }
+                   
            }
         
+               
         InputStream rstream = null;
 
-        rstream = method.getResponseBodyAsStream();
+        try {
+                       rstream = method.getResponseBodyAsStream();
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+                       throw new Exception("No Response Body");
+
+               }
 
         BufferedReader br = new BufferedReader(new InputStreamReader(rstream));
         
         SAXReader reader = new SAXReader();
            String line;
            Document document = null;
-           while ((line = br.readLine()) != null) {
-               document = reader.read(new 
ByteArrayInputStream(line.getBytes("UTF-8")));
-               //System.out.println("line"+line);
-           
-           }
+           try {
+                       while ((line = br.readLine()) != null) {
+                               document = reader.read(new 
ByteArrayInputStream(line.getBytes("UTF-8")));
+                               //System.out.println("line"+line);
+                       
+                       }
+               } catch (UnsupportedEncodingException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+                       throw new Exception("UnsupportedEncodingException by 
SAXReader");
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+                       throw new Exception("IOException by SAXReader in REST 
Service");
+               } catch (DocumentException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+                       throw new Exception("DocumentException by SAXReader in 
REST Service");
+               }
            
         Element root = document.getRootElement(); 
         
         LinkedHashMap<String,Element> elementMap = new 
LinkedHashMap<String,Element>();                            
         
-        for ( @SuppressWarnings("unchecked")
-            
-               Iterator<Element> i = root.elementIterator(); i.hasNext(); ) {  
                
-                   Element item = i.next();            
-                   String nodeVal = item.getName();
-                   elementMap.put(nodeVal, item);
+        for ( @SuppressWarnings("unchecked")Iterator<Element> i = 
root.elementIterator(); i.hasNext(); ) {
+               
+               
+                   Element item = i.next();
+                   
+                   if(item.getNamespacePrefix()=="soapenv"){
+                       throw new Exception(item.getData().toString());
+                   }else{
+                       String nodeVal = item.getName();
+                           elementMap.put(nodeVal, item);
+                   }
                }
                
                return elementMap;

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=1293406&r1=1293405&r2=1293406&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 24 20:42:55 2012
@@ -5,6 +5,7 @@ import static com.google.common.base.Pre
 
 import java.io.IOException;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -39,11 +40,12 @@ public final class RoomsServlet extends 
     private TemplateRenderer templateRenderer;
     private OmGateway omGateway;
     private UserManager userManager;
-    private com.atlassian.jira.user.util.UserManager jiraUserManager;
-       private String roomURL;
+    private com.atlassian.jira.user.util.UserManager jiraUserManager;  
        protected final VelocityRequestContextFactory requestContextFactory;
        private OmPluginSettings omPluginSettings;      
-       private final AvatarManager avatarManager;      
+       private final AvatarManager avatarManager;
+       
+       private ArrayList<Exception> errors = new ArrayList<Exception>();;
        
        
     
@@ -81,6 +83,9 @@ public final class RoomsServlet extends 
     protected void doGet(HttpServletRequest req, HttpServletResponse res) 
throws ServletException, IOException
     {
        User currentUser = getCurrentUser(req);         
+       //ArrayList<Exception> errors = new ArrayList<Exception>();
+       String roomURL = "";            
+       
                //User currentUser2 = 
ComponentManager.getInstance().getJiraAuthenticationContext().getLoggedInUser();
                        
         if ("y".equals(req.getParameter("new"))) {
@@ -136,7 +141,7 @@ public final class RoomsServlet extends 
                                        
                                        if(!roomHash.isEmpty()){
                                
-                                               this.roomURL = 
"http://"+url+":"+port+
+                                               roomURL = 
"http://"+url+":"+port+
                                                                
"/openmeetings/?"+
                                                                "scopeRoomId=" 
+ roomId +
                                                                "&secureHash=" 
+roomHash+                                                               
@@ -145,36 +150,53 @@ public final class RoomsServlet extends 
                                                                                
                        
                                        }
                                        
+                               }else{
+                                       
+                                       this.errors.add(new Exception("Could 
not login User to OpenMeetings, check your OpenMeetings plugin configuration"));
                                }
+                               
+                               
                        } catch (XPathExpressionException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
                        } catch (SAXException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
                        } catch (ParserConfigurationException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
                        } catch (DocumentException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
+                       } catch (Exception e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                               this.errors.add(e);
                        }
      
-               Map<String, Object> context = Maps.newHashMap();
+               Map<String, Object> context = Maps.newHashMap();                
               
-                       context.put("roomURL", this.roomURL);
-               res.setContentType("text/html;charset=utf-8");
+                       context.put("roomURL", roomURL);
+                       context.put("errors", this.errors);
+               res.setContentType("text/html;charset=utf-8");          
                // Pass in the list of rooms as the context
                templateRenderer.render(ENTER_BROWSER_TEMPLATE, context, 
res.getWriter());
+               this.errors.clear();
         }else {
             // Render the list of issues (list.vm) if no params are passed in
             //List<Room> rooms =  roomService.allNotDeleted();
             List<Room> rooms =  
roomService.allNotDeletedByUserName(currentUser.getName());
             Map<String, Object> context = Maps.newHashMap();
+            context.put("errors", this.errors);
             context.put("rooms", rooms);
             res.setContentType("text/html;charset=utf-8");
             // Pass in the list of rooms as the context
             templateRenderer.render(LIST_BROWSER_TEMPLATE, context, 
res.getWriter());
+            this.errors.clear();
         }      
        
     }
@@ -214,23 +236,34 @@ public final class RoomsServlet extends 
                                                        roomType, 
                                                        roomId);
                                        
+                               roomService.update(id, isAllowedRecording, 
isAudioOnly, isModeratedRoom, roomName, numberOfParticipent, roomType);
+
+                               }else{
+                                       this.errors.add(new Exception("Could 
not login User to OpenMeetings, check your OpenMeetings plugin configuration"));
                                }
                        } catch (XPathExpressionException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
                        } catch (SAXException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
                        } catch (ParserConfigurationException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        } catch (DocumentException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
+                       } catch (Exception e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                               this.errors.add(e);
                        }
                
-               roomService.update(id, isAllowedRecording, isAudioOnly, 
isModeratedRoom, roomName, numberOfParticipent, roomType);
-            res.sendRedirect(req.getContextPath() + 
"/plugins/servlet/openmeetingsrooms");
+            
+               res.sendRedirect(req.getContextPath() + 
"/plugins/servlet/openmeetingsrooms");
                
        }else if("y".equals(req.getParameter("delete"))){               
                Integer id = Integer.valueOf(req.getParameter("key"));
@@ -258,22 +291,33 @@ public final class RoomsServlet extends 
                                                        roomType
                                                        );
                                        
+                               roomService.add(isAllowedRecording, 
isAudioOnly, isModeratedRoom, roomName, numberOfParticipent, roomType, roomId, 
currentUser.getName());
+
+                               }else{
+                                       this.errors.add(new Exception("Could 
not login User to OpenMeetings, check your OpenMeetings plugin configuration"));
                                }
                        } catch (XPathExpressionException e) {
                                // TODO Auto-generated catch block
+                               this.errors.add(e);
                                e.printStackTrace();
                        } catch (SAXException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
                        } catch (ParserConfigurationException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
                        } catch (DocumentException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
+                               this.errors.add(e);
+                       } catch (Exception e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                               this.errors.add(e);
                        }
                
-               roomService.add(isAllowedRecording, isAudioOnly, 
isModeratedRoom, roomName, numberOfParticipent, roomType, roomId, 
currentUser.getName());
             //roomService.add(description, true, true, true, "name", 4L, 1L);
                
             res.sendRedirect(req.getContextPath() + 
"/plugins/servlet/openmeetingsrooms");

Modified: 
incubator/openmeetings/branches/jira-plugin/src/main/resources/i18n.properties
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/resources/i18n.properties?rev=1293406&r1=1293405&r2=1293406&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/resources/i18n.properties 
(original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/resources/i18n.properties 
Fri Feb 24 20:42:55 2012
@@ -34,6 +34,7 @@ openmeetings.rooms.edit.titel.label=Edit
 openmeetings.rooms.cancel.label=Cancel
 
 openmeetings.rooms.enter.label=Link to Web-Conferencing
+openmeetings.rooms.enter.titel.label=Link to Web-Conferencing
 
 openmeetings.config.titel.label=Edit OpenMeetings Configuration
 openmeetings.config.titel.h1.label=OpenMeetings Configuration

Modified: 
incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/enter.vm
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/enter.vm?rev=1293406&r1=1293405&r2=1293406&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/enter.vm
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/enter.vm
 Fri Feb 24 20:42:55 2012
@@ -1,8 +1,19 @@
 <html>
 <head>
-    <title>$i18n.getText("openmeetings.rooms.edit.titel.label")</title>
+    <title>$i18n.getText("openmeetings.rooms.enter.titel.label")</title>
     <meta name="decorator" content="atl.general">
 </head>
 <body class="page-type-admin">
-<iframe name="IframeName" src=$roomURL width='100%' height='600px'></iframe>
+       #if ($errors.size()>0)
+           <div class="aui-message error shadowed">
+               #foreach($error in $errors)
+                   <p class="title">
+                       <span class="aui-icon icon-error"></span>
+                       <strong>$error</strong>
+                   </p>
+               #end
+           </div>           
+       #else
+               <iframe name="IframeName" src=$roomURL width='100%' 
height='600px'></iframe>
+       #end
 </body>
\ No newline at end of file

Modified: 
incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/list.vm
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/list.vm?rev=1293406&r1=1293405&r2=1293406&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/list.vm
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/list.vm
 Fri Feb 24 20:42:55 2012
@@ -25,7 +25,6 @@
 </head>
 <body class="page-type-admin">
 <div class="content-container">
-
     <div class="content-body">
         <h1>You've Got #if($rooms.size()==0)<span 
style="color:red">NO</span>#end Rooms!</h1>
         #if ($errors.size()>0)
@@ -39,8 +38,7 @@
             </div>
             <!-- .aui-message -->
         #end
-
-        #if ($rooms.size() > 0)
+        #if($rooms.size() > 0)
             <div class="rooms">
                 <table class="aui">
                     <thead>

Modified: 
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmGatawayTest.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmGatawayTest.java?rev=1293406&r1=1293405&r2=1293406&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmGatawayTest.java
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmGatawayTest.java
 Fri Feb 24 20:42:55 2012
@@ -48,7 +48,7 @@ public class OmGatawayTest {
        }
 
     //@Test
-    public void testLogin() throws SAXException, IOException, 
ParserConfigurationException, XPathExpressionException, ServletException, 
DocumentException {
+    public void testLogin() throws Exception {
 //        String expected = "test";
 //        
when(mockRequest.getParameter(Mockito.anyString())).thenReturn(expected);
 //        assertEquals(expected,mockRequest.getParameter("some string"));

Modified: 
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=1293406&r1=1293405&r2=1293406&view=diff
==============================================================================
--- 
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmRestServiceTest.java
 (original)
+++ 
incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/gateway/OmRestServiceTest.java
 Fri Feb 24 20:42:55 2012
@@ -117,95 +117,124 @@ new OmRestService();
     @Test
     public void testCallApacheCommons() throws SAXException, IOException, 
ParserConfigurationException, XPathExpressionException, DocumentException {
         
-               
-//     String request= 
"http://localhost:5080/openmeetings/services/UserService/getSession";;
-//             HttpClient client = new HttpClient();
-//
-//        GetMethod method = new GetMethod(request);
-//
-//
-//             // Send GET request
-//
-//        int statusCode = client.executeMethod(method);
-//        
-//             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);
-//     
-//         }
-//        
-//        InputStream rstream = null;
-//
-//        rstream = method.getResponseBodyAsStream();
-//
-//        BufferedReader br = new BufferedReader(new 
InputStreamReader(rstream));
-//        
-//        SAXReader reader = new SAXReader();
-//         String line;
-//         Document document = null;
-//         while ((line = br.readLine()) != null) {
-//             document = reader.read(new 
ByteArrayInputStream(line.getBytes("UTF-8")));
-//             System.out.println("line"+line);
-//         
-//         }
-//     
-//         //System.out.println("line2"+document.asXML());
-//                       
-//        Element root = document.getRootElement();
-//       
-//        log.error(root.asXML());
-//        
-//        
-//        for ( @SuppressWarnings("unchecked")
-//            
-//             Iterator<Element> i = root.elementIterator(); i.hasNext(); ) {
-//                
-//            Element item = i.next();
-//            
-//            log.debug(item.getName());
-//            //log.error(item.getNamespacePrefix());
-//            //log.error(item.getPath());
-//            
//log.error(item.getXPathResult(10).getName());//.getPath("/ns:getSessionResponse/ns:return/ax24:session_id"));
-//            log.error(item.elementText("session_id"));
-//            
-//            String nodeVal = item.getName();
-//        }
-//
-//        br.close();
-//                     
+       try{    
+       String request= 
"http://localhost:5080/openmeetings/services/UserService/getSession";;
+               HttpClient client = new HttpClient();
+
+        GetMethod method = new GetMethod(request);
+
+
+               // Send GET request
+
+        int statusCode = client.executeMethod(method);
+        
+               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);
+       
+           }
+        
+        InputStream rstream = null;
+
+        rstream = method.getResponseBodyAsStream();
+
+        BufferedReader br = new BufferedReader(new InputStreamReader(rstream));
+        
+        SAXReader reader = new SAXReader();
+           String line;
+           Document document = null;
+           while ((line = br.readLine()) != null) {
+               document = reader.read(new 
ByteArrayInputStream(line.getBytes("UTF-8")));
+               System.out.println("line"+line);
+           
+           }
+       
+           //System.out.println("line2"+document.asXML());
+                         
+        Element root = document.getRootElement();
+       
+        log.error(root.asXML());
+        
+        
+        for ( @SuppressWarnings("unchecked")
+            
+               Iterator<Element> i = root.elementIterator(); i.hasNext(); ) {
+            
+               
+               
+            Element item = i.next();
+            
+            if(item.getNamespacePrefix()=="soapenv"){
+               
+               System.out.println("Data:"+item.getData().toString());
+               
+//                 log.debug(item.getName());
+//                 //log.error(item.getNamespacePrefix());
+//                 //log.error(item.getPath());
+//                 
//log.error(item.getXPathResult(10).getName());//.getPath("/ns:getSessionResponse/ns:return/ax24:session_id"));
+//                 log.error(item.elementText("session_id"));
+//                 log.error("Error: ",item.elementText("Text"));
+//                 log.error(item.attributeValue("soapenv:Reason"));
+//                 log.error(item.asXML());
+//                 log.error(item.getPath());
+//                 log.error(item.getData().toString());
+//                 log.error(item.getName());
+//                 log.error(item.getNamespacePrefix());
+                   
+                   
+                   String nodeVal = item.getName();
+               }else{
+                       log.debug(item.getName());
+                   //log.error(item.getNamespacePrefix());
+                   //log.error(item.getPath());
+                   
//log.error(item.getXPathResult(10).getName());//.getPath("/ns:getSessionResponse/ns:return/ax24:session_id"));
+                   log.error(item.elementText("session_id"));
+                   log.error("Error: ",item.elementText("Text"));
+                   log.error(item.attributeValue("soapenv:Reason"));
+                       
+               }
+        }
+
+        br.close();
+               
+       }catch(Exception e){
+               
+               e.getStackTrace();
+               System.out.println("Exeption: "+ e);
+       }
     }
     
 }


Reply via email to