Author: keith
Date: Fri Apr  4 02:04:54 2008
New Revision: 15550

Log:

Fixing the deployment part for Mashup-644. Now if there is a serviceName.tags 
file (This is an XML file) these tage gate applied to the resource. This file 
is deleted after service deployment.


Modified:
   trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
   
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
Fri Apr  4 02:04:54 2008
@@ -141,4 +141,6 @@
 
     public static String MASHUP_PRIVATE_FOLDER_NAME = "_private";
     public static String UNDISPATCHED_OPERATION = "undispatched";
+    public static String TAGS_ELEMENT = "tag";
+    public static String TAGS_File = ".tags";
 }

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java   
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java   
Fri Apr  4 02:04:54 2008
@@ -90,6 +90,7 @@
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Properties;
+import java.util.Iterator;
 import java.nio.channels.FileChannel;
 import java.nio.ByteBuffer;
 
@@ -868,6 +869,32 @@
             ac.authorizeUser(username, path1, AccessControlConstants.EDIT);
             ac.authorizeUser(username, path1, AccessControlConstants.DELETE);
 
+            // we get the filename without the extension
+            String shortFileName = 
DescriptionBuilder.getShortFileName(currentFile.getName());
+            File tagsFile = new File(currentFile.getFile().getParentFile(),
+                                     shortFileName + 
MashupConstants.TAGS_File);
+
+            // This enables us to migrate tags associated with a mashup during 
sharing. When a 
+            // mashup is shared tags associated with that mashup are put into 
a file and sent along
+            // with that mashup. This filw format looks as follows,
+            // <tags>
+            //      <tag>test</tag>
+            //      <tag>fun</tag>
+            // </tags>
+            if (tagsFile.exists() && tagsFile.isFile()) {
+                FileInputStream inputStream = new FileInputStream(tagsFile);
+                StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(inputStream);
+                OMElement documentElement = stAXOMBuilder.getDocumentElement();
+                Iterator localName =
+                        
documentElement.getChildrenWithLocalName(MashupConstants.TAGS_ELEMENT);
+                while (localName.hasNext()) {
+                    OMElement tagElement = (OMElement) localName.next();
+                    String tag = tagElement.getText();
+                    secureRegistry.applyTag(path1, tag);
+                }
+                tagsFile.delete();
+            }
+
             return path1;
         } catch (RegistryException e) {
             throw new DeploymentException(e);
@@ -875,6 +902,8 @@
             throw new DeploymentException(e);
         } catch (UserStoreException e) {
             throw new DeploymentException(e);
+        } catch (XMLStreamException e) {
+            throw new DeploymentException(e);
         }
     }
 

Modified: 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
==============================================================================
--- 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
   (original)
+++ 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
   Fri Apr  4 02:04:54 2008
@@ -16,6 +16,8 @@
 
 package org.wso2.mashup.deployer;
 
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axis2.AxisFault;
@@ -83,6 +85,7 @@
 import org.wso2.wsas.admin.service.UserAdmin;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -571,15 +574,15 @@
             if (undispatched != null) {
                 
axisService.addParameter(MashupConstants.UNDISPATCHED_OPERATION, undispatched);
             }
+
             ArrayList serviceList = new ArrayList();
             serviceList.add(axisService);
-
             return serviceList;
         } catch (FileNotFoundException e) {
             throw new DeploymentException("JS Service File Not Found", e);
         } catch (IOException e) {
             throw new DeploymentException(e);
-        }
+        } 
     }
 
     //processing the a function present in the deploying javascript file.

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to