You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by es...@apache.org on 2012/02/22 18:29:26 UTC

svn commit: r1292408 - in /incubator/openmeetings/branches/jira-plugin/src: main/java/org/openmeetings/jira/plugin/gateway/ main/java/org/openmeetings/jira/plugin/jira/customfields/ main/java/org/openmeetings/jira/plugin/servlet/ main/resources/templat...

Author: eschwert
Date: Wed Feb 22 17:29:26 2012
New Revision: 1292408

URL: http://svn.apache.org/viewvc?rev=1292408&view=rev
Log:
OPENMEETINGS-60 setUserObjectAndGenerateRoomHash method + roomlink in jira Issue-Default-View + Room-Select-List for issues as custom field.

Added:
    incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/enter.vm
Removed:
    incubator/openmeetings/branches/jira-plugin/src/test/java/org/openmeetings/jira/plugin/jira/customfields/RoomNameFieldTest.java
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/jira/customfields/RoomSelectList.java
    incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/servlet/RoomsServlet.java
    incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/edit.vm
    incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/view.vm

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=1292408&r1=1292407&r2=1292408&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 Wed Feb 22 17:29:26 2012
@@ -77,7 +77,7 @@ public class OmGateway {
 																			SAXException, 
 																			ParserConfigurationException, DocumentException{
     			
-    	String testURL = "http://localhost:5080/openmeetings/services/RoomService/addRoomWithModerationExternalTypeAndTopBarOption?" +
+    	String restURL = "http://localhost:5080/openmeetings/services/RoomService/addRoomWithModerationExternalTypeAndTopBarOption?" +
 			    			"SID="+this.getSessionId()+
 			    			"&name="+name+
 							"&roomtypes_id="+roomType.toString()+
@@ -95,7 +95,7 @@ public class OmGateway {
 							"&allowRecording="+isAllowedRecording.toString()+
 							"&hideTopBar=false";
     	    	
-		LinkedHashMap<String, Element> result = omRestService.call(testURL, null);		
+		LinkedHashMap<String, Element> result = omRestService.call(restURL, null);		
 		
 		String roomId = result.get("return").getStringValue();
 		
@@ -117,7 +117,7 @@ public class OmGateway {
 																	DocumentException{
 
 	
-		String testURL = "http://localhost:5080/openmeetings/services/RoomService/updateRoomWithModerationAndQuestions?" +
+		String restURL = "http://localhost:5080/openmeetings/services/RoomService/updateRoomWithModerationAndQuestions?" +
 							"SID="+this.getSessionId()+
 							"&room_id="+roomId.toString()+
 							"&name="+roomname.toString()+
@@ -138,7 +138,7 @@ public class OmGateway {
 //							"&allowRecording="+isAllowedRecording+
 //							"&hideTopBar=false";
 		
-		LinkedHashMap<String, Element> result = omRestService.call(testURL, null);		
+		LinkedHashMap<String, Element> result = omRestService.call(restURL, null);		
 		
 		log.info("addRoomWithModerationExternalTypeAndTopBarOption with ID: ",result.get("return").getStringValue());
 		
@@ -146,6 +146,39 @@ public class OmGateway {
 		
 		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?" +
+				"SID="+this.getSessionId()+
+				"&username="+username+
+				"&firstname="+firstname+
+				"&lastname="+lastname+
+				"&profilePictureUrl="+profilePictureUrl+
+				"&email="+email+
+				"&externalUserId="+externalUserId+
+				"&externalUserType="+externalUserType+
+				"&room_id="+room_id+
+				"&becomeModeratorAsInt="+becomeModeratorAsInt+
+				"&showAudioVideoTestAsInt="+showAudioVideoTestAsInt;
+				
+	
+				LinkedHashMap<String, Element> result = omRestService.call(restURL, null);		
+				
+				String roomHash = result.get("return").getStringValue();
+				
+				return roomHash;
+		
+	}
 
 	public String getSessionId() {
 		return sessionId;

Modified: incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/jira/customfields/RoomSelectList.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/jira/customfields/RoomSelectList.java?rev=1292408&r1=1292407&r2=1292408&view=diff
==============================================================================
--- incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/jira/customfields/RoomSelectList.java (original)
+++ incubator/openmeetings/branches/jira-plugin/src/main/java/org/openmeetings/jira/plugin/jira/customfields/RoomSelectList.java Wed Feb 22 17:29:26 2012
@@ -5,39 +5,60 @@ import org.openmeetings.jira.plugin.ao.o
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.atlassian.jira.issue.context.JiraContextNode;
-import com.atlassian.jira.issue.customfields.converters.SelectConverter;
-import com.atlassian.jira.issue.customfields.converters.StringConverter;
-import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
-import com.atlassian.jira.issue.customfields.manager.OptionsManager;
-import com.atlassian.jira.issue.customfields.option.Options;
-import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
-import com.atlassian.jira.issue.customfields.persistence.PersistenceFieldType;
-import com.atlassian.jira.issue.customfields.view.CustomFieldParams;
-import com.atlassian.jira.issue.Issue;
-import com.atlassian.jira.issue.fields.CustomField;
-import com.atlassian.jira.issue.fields.config.FieldConfig;
-import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
+//import com.atlassian.jira.issue.context.JiraContextNode;
+//import com.atlassian.jira.issue.customfields.converters.SelectConverter;
+//import com.atlassian.jira.issue.customfields.converters.StringConverter;
+//import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
+//import com.atlassian.jira.issue.customfields.manager.OptionsManager;
+//import com.atlassian.jira.issue.customfields.option.Options;
+//import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
+//import com.atlassian.jira.issue.customfields.persistence.PersistenceFieldType;
+//import com.atlassian.jira.issue.customfields.view.CustomFieldParams;
+//import com.atlassian.jira.issue.Issue;
+//import com.atlassian.jira.issue.fields.CustomField;
+//import com.atlassian.jira.issue.fields.config.FieldConfig;
+//import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
 
 import java.util.List;
 import java.util.Map;
 
+//import com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType;
+import com.atlassian.jira.issue.Issue;
 import com.atlassian.jira.issue.customfields.impl.SelectCFType;
 import com.atlassian.jira.util.ErrorCollection;
 
-public class RoomSelectList extends SelectCFType {
-    private static final Logger log = LoggerFactory.getLogger(RoomSelectList.class);
-	//private final OptionsManager optionsManager;
-	//private static SelectConverter selectConverter;
-	private final RoomService roomService;
-
-    public RoomSelectList(CustomFieldValuePersister customFieldValuePersister, StringConverter stringConverter, SelectConverter selectConverter, OptionsManager optionsManager, GenericConfigManager genericConfigManager, RoomService roomService) {
-    super(customFieldValuePersister, stringConverter, selectConverter, optionsManager, genericConfigManager);
-    this.roomService = roomService;
-    //this.optionsManager = optionsManager;
-}
+
+
+import com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType;
+import com.atlassian.jira.issue.customfields.impl.FieldValidationException;
+import com.atlassian.jira.issue.customfields.impl.TextCFType;
+import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
+import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
+import com.atlassian.jira.issue.customfields.persistence.PersistenceFieldType;
+import com.atlassian.jira.issue.fields.CustomField;
+import com.atlassian.jira.issue.fields.config.FieldConfig;
+import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
+
+	public class RoomSelectList extends TextCFType {
+	    private static final Logger log = LoggerFactory.getLogger(RoomSelectList.class);
+		//private final OptionsManager optionsManager;
+		//private static SelectConverter selectConverter;
+		private final RoomService roomService;
+	
+//	    public RoomSelectList(CustomFieldValuePersister customFieldValuePersister, StringConverter stringConverter, SelectConverter selectConverter, OptionsManager optionsManager, GenericConfigManager genericConfigManager, RoomService roomService) {
+//	    super(customFieldValuePersister, stringConverter, selectConverter, optionsManager, genericConfigManager);
+//	    this.roomService = roomService;
+//	    //this.optionsManager = optionsManager;
+		
     
-    @Override
+	    
+		public RoomSelectList(CustomFieldValuePersister customFieldValuePersister,
+	            GenericConfigManager genericConfigManager, RoomService roomService) {
+	        super(customFieldValuePersister, genericConfigManager);
+	        this.roomService = roomService;
+	    }  
+	
+	@Override
     public Map<String, Object> getVelocityParameters(final Issue issue,
                                                      final CustomField field,
                                                      final FieldLayoutItem fieldLayoutItem) {
@@ -67,33 +88,48 @@ public class RoomSelectList extends Sele
     }
     
     @Override
-    public PersistenceFieldType getDatabaseType()
-	{
-		return PersistenceFieldType.TYPE_LIMITED_TEXT;
-	}
+    protected PersistenceFieldType getDatabaseType()
+    {
+        return PersistenceFieldType.TYPE_LIMITED_TEXT;
+    } 
     
+ 
     @Override
-    public void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)
+    protected Integer getObjectFromDbValue(final Object databaseValue)
+            throws FieldValidationException
     {
-
+        return getSingularObjectFromString((String) databaseValue);
     }
-    
-//    @Override
-//    public Options getOptions(FieldConfig config, JiraContextNode jiraContextNode)
-//    {
-//      return this.optionsManager.getOptions(config);
-//    }
-    
-//    @Override
-//    public Object getValueFromIssue(CustomField field, Issue issue){
-//		
-//    	issue.getCustomFieldValue(field);
-//    	return issue;
-//    	
-//    }
-//    
-//    public Options getOptions(FieldConfig config, JiraContextNode jiraContextNode)
-//    {
-//      return this.optionsManager.getOptions(config);
-//    }
+ 
+    @Override
+    public Integer getSingularObjectFromString(final String string)
+            throws FieldValidationException
+    {
+        if (string == null)
+            return null;
+        try
+        {
+            final Integer decimal = new Integer(string);
+            
+            return decimal;
+        }
+        catch (NumberFormatException ex)
+        {
+            throw new FieldValidationException("Not a valid number: "+string);
+        }
+    }
+
+	@Override
+	public String getStringFromSingularObject(Object singularObject) {
+		if (singularObject == null)
+            return "";
+        // format
+        return singularObject.toString();
+	}
+
+	@Override
+	protected Object getDbValueFromObject(Object customFieldObject) {
+		// TODO Auto-generated method stub
+		return getStringFromSingularObject(customFieldObject);
+	}
 }
\ No newline at end of file

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=1292408&r1=1292407&r2=1292408&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 Wed Feb 22 17:29:26 2012
@@ -36,10 +36,12 @@ public final class RoomsServlet extends 
     private OmGateway omGateway;
     private UserManager userManager;
     private com.atlassian.jira.user.util.UserManager jiraUserManager;
+	private String roomURL;
     
     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";
+    private static final String ENTER_BROWSER_TEMPLATE = "/templates/omrooms/enter.vm";
  
     public RoomsServlet(RoomService roomService, TemplateRenderer templateRenderer, OmGateway omGateway, com.atlassian.jira.user.util.UserManager jiraUserManager, UserManager userManager)
     {
@@ -109,6 +111,78 @@ public final class RoomsServlet extends 
         	Integer id = Integer.valueOf(req.getParameter("key"));
     		roomService.delete(id);
     		res.sendRedirect(req.getContextPath() + "/plugins/servlet/openmeetingsrooms");
+        }else if("y".equals(req.getParameter("enter"))){
+        	String iframe_d;
+        	try {
+				if(omGateway.loginUser()){
+					
+//					roomId = omGateway.setUserObjectAndGenerateRoomHash(
+//							username, 
+//							firstname, 
+//							lastname, 
+//							profilePictureUrl, 
+//							email, 
+//							externalUserId, 
+//							externalUserType, 
+//							room_id, 
+//							becomeModeratorAsInt, 
+//							showAudioVideoTestAsInt);
+					Long roomId = Long.valueOf(req.getParameter("roomId"));
+					
+					String roomHash = omGateway.setUserObjectAndGenerateRoomHash( 
+							"username", 
+							"firstname", 
+							"lastname", 
+							"profilePictureUrl", 
+							"email@test.de", 
+							1L, 
+							"externalUserType", 
+							roomId, 
+							1, 
+							1);
+					
+					if(!roomHash.isEmpty()){
+						
+						String url = "localhost"; 
+				    	String port = "5080"; 
+						
+						this.roomURL = "http://"+url+":"+port+
+								"/openmeetings/?"+
+								"scopeRoomId=" + roomId +
+								"&secureHash=" +roomHash+								
+								"&language=1"+
+								"&lzproxied=solo";					
+								
+								
+//						printf("<iframe src='%s' width='%s' height='600px' />",$iframe_d,
+//								"100%");
+						
+					}
+					
+				}
+			} 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();
+			} catch (DocumentException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+        	
+	        // Render the list of issues (list.vm) if no params are passed in
+	        //List<Room> rooms =  roomService.all();
+	        //List<Room> rooms =  roomService.allNotDeleted();
+	        Map<String, Object> context = Maps.newHashMap();
+	       
+			context.put("roomURL", this.roomURL);
+	        res.setContentType("text/html;charset=utf-8");
+	        // Pass in the list of rooms as the context
+	        templateRenderer.render(ENTER_BROWSER_TEMPLATE, context, res.getWriter());
         }else {
             // Render the list of issues (list.vm) if no params are passed in
             //List<Room> rooms =  roomService.all();

Modified: incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/edit.vm
URL: http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/edit.vm?rev=1292408&r1=1292407&r2=1292408&view=diff
==============================================================================
--- incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/edit.vm (original)
+++ incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/edit.vm Wed Feb 22 17:29:26 2012
@@ -6,7 +6,7 @@
         <option value="">$i18n.getText("common.words.none")</option>
     #end
     #foreach ($option in $rooms)
-        <option value=$option.getRoomId()>$option.getName()</option>
+        <option #if ($value == $option.getRoomId().toString()) selected="selected"#end value=$textutils.htmlEncode($option.getRoomId().toString()) >$option.getName()</option>
     #end
 </select>
 #customControlFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)
\ No newline at end of file

Modified: incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/view.vm
URL: http://svn.apache.org/viewvc/incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/view.vm?rev=1292408&r1=1292407&r2=1292408&view=diff
==============================================================================
--- incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/view.vm (original)
+++ incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/customfields/room-select-list/view.vm Wed Feb 22 17:29:26 2012
@@ -1,6 +1,4 @@
 #if ($value)
- RoomURL: "$!value.toString()"
-#else
-undefined
-System.out.println("value view.vm", $value)
+##$!value.toString() 
+ <a href="$requestContext.baseUrl/plugins/servlet/openmeetingsrooms?enter=y&roomId=$textutils.htmlEncode($value.toString())">Link to room</a>
 #end
\ No newline at end of file

Added: 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=1292408&view=auto
==============================================================================
--- incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/enter.vm (added)
+++ incubator/openmeetings/branches/jira-plugin/src/main/resources/templates/omrooms/enter.vm Wed Feb 22 17:29:26 2012
@@ -0,0 +1,8 @@
+<html>
+<head>
+    <title>Edit Issue &mdash; Issue CRUD Tutorial</title>
+    <meta name="decorator" content="atl.general">
+</head>
+<body class="page-type-admin">
+<iframe name="IframeName" src=$roomURL width='100%' height='600px'></iframe>
+</body>
\ No newline at end of file