Index: /MDService2/trunk/MDService2/WebContent/index.jsp
===================================================================
--- /MDService2/trunk/MDService2/WebContent/index.jsp	(revision 1434)
+++ /MDService2/trunk/MDService2/WebContent/index.jsp	(revision 1435)
@@ -159,4 +159,5 @@
 				<span id="bts_add" class="cmd cmd_add" ></span> 
 				<span id="bts_delete" class="cmd cmd_del" ></span>
+				<span id="bts_publish" class="cmd cmd_publish" ></span>
 			</div>
 			
Index: /MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js
===================================================================
--- /MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js	(revision 1434)
+++ /MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js	(revision 1435)
@@ -95,9 +95,9 @@
 		if (type == "bookmarkset"){
 			name = "new_bookmarkset";
-			json  = {"name":name, "id":0, "created":str_time , "Bookmarks" : "null"};
+			json  = {"name":name, "id":0, "vcrid":0, "created":str_time , "Bookmarks" : "null"};
 		} 
 		if (type == "queryset"){
 			name = "new_queryset";
-			json  = {"name":name, "id":0, "created":str_time , "Queries" : "null"};
+			json  = {"name":name, "id":0, "vcrid":0, "created":str_time , "Queries" : "null"};
 		}
 	}
@@ -235,8 +235,8 @@
 			query.id = $(data).text();
 			if (query.bookmark == 0){
-				this.addelement("query", json, query);
+				workspace.addelement("query", json, qsid);
 				appendQueryUI(json,qsid, $('#userqueries'));
 			} else {
-				this.addelement("bookmark", json, query);
+				workspace.addelement("bookmark", json, qsid);
 				appendBookmarkUI(json,qsid, $('#bookmarks'));
 			}
Index: /MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui.js
===================================================================
--- /MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui.js	(revision 1434)
+++ /MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui.js	(revision 1435)
@@ -231,5 +231,19 @@
 	$('.cmd_publish').live('click', function(event){
 		var query = $(this).parent().data('query');
-		query.publish();
+		if (query != undefined){ // query
+			query.publish();
+		} else { // bookmarksets
+			var json = workspace.getTypedElement('user','bookmarkset');
+			var id = parseInt($('#bts_select').find("option:selected").val());
+			var bsjson = json[id];
+			$.get("/MDService2/virtualcollection/USER/" + bsjson.id,"", function(data){
+				if (bsjson.vcrid == 0){
+					var id = parseInt($(data).children().children('virtualcollectionid').text());
+					bsjson.vcrid = id;
+					workspace.savequeryset(bsjson, 1);
+				}
+			});
+		}
+
 	});
 	
Index: /MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_load.js
===================================================================
--- /MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_load.js	(revision 1434)
+++ /MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_load.js	(revision 1435)
@@ -405,5 +405,5 @@
 	var del = '';
 	var name = '';
-	var id = $(qs).parent().attr('id');
+	var id = $(bs).parent().attr('id');
 	
 	del = '<span class="cmd cmd_del" ><xsl:text> </xsl:text></span>';
@@ -422,8 +422,8 @@
 		qq = "";
 	}
-	var x = '<div class="cmds-elem-plus" ><span class="cmd cmd_load"></span><span class="detail-caller-inline" ><a href="'+id + '_'+ i+'" >' + 
+	var x = '<div class="cmds-elem-plus" ><span class="cmd cmd_load"></span><span class="detail-caller-inline" ><a href="'+ id + '_'+ i+'" >' + 
 	json.name + '</a></span>' + 
 	del +
-	'<span class="cmd cmd_publish"></span><div class="detail" >' +
+	'<div class="detail" >' +
 	name +
 	'<div class="cmds-elem-prop"><span class="label">squery:</span><span class="value">' + squery + '</span></div>' +
@@ -454,17 +454,5 @@
 			$(this).data("query").name = $(this).val();
 			workspace.save("user");
-			//var query = new Query();
-			//query.load($(this).data("queryjson"));
-			//query.save();
-			/*
-			var id = parseInt( $("#qts_select option:selected").val());
-			$(this).parent().parent().parent().find('a').text($(this).val());
-			var str = $(this).parent().parent().parent().find('a').attr("href");
-			var iq = parseInt(str.substring(7));
-			
-			jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq].name = $(this).val();
-			//saveWorkspace("USER");
-			Workspace.save("USER");
-			*/
+			
 			evStop();
 		}
Index: /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/VirtualCollectionProxyAction.java
===================================================================
--- /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/VirtualCollectionProxyAction.java	(revision 1434)
+++ /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/VirtualCollectionProxyAction.java	(revision 1435)
@@ -108,5 +108,5 @@
 		//"http://clarin.ids-mannheim.de/vcr/service/virtualcollection";
 		String urlstring = Admin.getConfig().getProperty("virtualcollection.uri");
-		String vcrstr = (String)getQueryVcrid();
+		String vcrstr = (String)getVcrid();//getQueryVcrid();
 		if (!vcrstr.equals("0")){
 			urlstring = urlstring + "/" + vcrstr;
Index: /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/WorkspaceAction.java
===================================================================
--- /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/WorkspaceAction.java	(revision 1434)
+++ /MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/WorkspaceAction.java	(revision 1435)
@@ -459,5 +459,6 @@
 	    nodelist.item(0).setTextContent(to_id);
 	}
-	public String createNewId(String name){
+	public String createNewId(){//String name){
+		String name = "maxid";
 		String id = workspace_doc.getElementsByTagName(name).item(0).getTextContent();
 		Integer i = Integer.parseInt(id) + 1;
@@ -545,5 +546,5 @@
 			Node node = new_doc.getFirstChild();
 			if (this.qid.equals("0")){
-				newid = createNewId("maxqid");	 
+				newid = createNewId();//"maxqid");	 
 				new_doc.getElementsByTagName("id").item(0).setTextContent(newid);
 	 	        Element root = workspace_doc.getDocumentElement();
@@ -582,5 +583,5 @@
 						Node node = new_doc.getFirstChild();
 						if (this.qid.equals("0")){
-							newid = createNewId("maxbid");	 
+							newid = createNewId();//"maxbid");	 
 							new_doc.getElementsByTagName("id").item(0).setTextContent(newid);
 				 	        Element root = workspace_doc.getDocumentElement();
@@ -620,5 +621,5 @@
 						Node node = new_doc.getFirstChild();
 						if (this.qsid.equals("0")){
-							newid = createNewId("maxqsid");	 
+							newid = createNewId();//"maxqsid");	 
 							new_doc.getElementsByTagName("id").item(0).setTextContent(newid);
 				 	        Element root = workspace_doc.getDocumentElement();
@@ -659,5 +660,5 @@
 						Node node = new_doc.getFirstChild();
 						if (this.qsid.equals("0")){
-							newid = createNewId("maxbsid");	 
+							newid = createNewId();//"maxbsid");	 
 							new_doc.getElementsByTagName("id").item(0).setTextContent(newid);
 				 	        Element root = workspace_doc.getDocumentElement();
@@ -935,4 +936,30 @@
 		}
 
+     return result;
+}
+
+public Object getVcrid() throws XPathExpressionException{
+	
+	XPathFactory factory = XPathFactory.newInstance(); 
+    XPath xpath = factory.newXPath(); 
+    XPathExpression expr1, expr2;
+		//expr = xpath.compile("item[id='" + this.qid + "']/vcrid");
+		expr1 = xpath.compile("//Profiles/WorkspaceProfiles/WorkspaceProfile/Querysets/item/Queries/item[id='" + this.qid + "']/vcrid");
+		expr2 = xpath.compile("//Profiles/WorkspaceProfiles/WorkspaceProfile/Bookmarksets/item[id='" + this.qid + "']/vcrid");
+	    
+		//expression is evaluated with respect to a certain context node which is doc.
+		Object result = null;
+		try{
+	        result = expr1.evaluate(workspace_doc, XPathConstants.STRING);
+		} catch(Exception e){
+			
+		}
+		if (result.equals("")){
+			try{
+		        result = expr2.evaluate(workspace_doc, XPathConstants.STRING);
+			} catch(Exception e){
+				
+			}
+		}
      return result;
 }
