geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r492105 - in /geronimo/server: branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/repository/ branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/ trunk/applications/console/ge...
Date Wed, 03 Jan 2007 11:17:08 GMT
Author: vamsic007
Date: Wed Jan  3 03:17:04 2007
New Revision: 492105

URL: http://svn.apache.org/viewvc?view=rev&rev=492105
Log:
GERONIMO-2283 Common libs portlet guesses wrong group ID, gives no usage advice
  o Updated the javascript to use RegularExpression processing on the filename to come up
with artifact, version and type suggestion.
  o Updated the code to suggest groupId if the file path is in a Maven1 or Maven2 repository
structure.

Modified:
    geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/repository/normal.jsp
    geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp

Modified: geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/repository/normal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/repository/normal.jsp?view=diff&rev=492105&r1=492104&r2=492105
==============================================================================
--- geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/repository/normal.jsp
(original)
+++ geronimo/server/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/repository/normal.jsp
Wed Jan  3 03:17:04 2007
@@ -48,53 +48,43 @@
 }
 
 function <portlet:namespace/>parse(localFile) {
-   // Check for windows file delim
-   fileChar = "\\";
-   fileNameIndex = localFile.lastIndexOf(fileChar);
-   if (fileNameIndex == -1) {
-      // if not found check for *nix delim
-      fileChar = "/";
-      fileNameIndex = localFile.lastIndexOf(fileChar);
-   }
-
-   if (fileNameIndex != -1) {
-      basename = localFile.substring(fileNameIndex + 1);
-
-      prefix = localFile.substring(0 , fileNameIndex );
-
-      groupIndex = prefix.lastIndexOf(fileChar);
-      if (groupIndex != -1) {
-          group = prefix.substring(groupIndex + 1 );
-          document.<portlet:namespace/>fileSelect.group.value = group;        
-      }
-   }
-   else {
-      basename = localFile;
-   }
-
-   // Attempt to get the artifact and type from the basename
-   typeIndex = basename.lastIndexOf(".");
-   if (typeIndex != -1) {
-       fileType = basename.substring(typeIndex + 1);
-       document.<portlet:namespace/>fileSelect.fileType.value = fileType;
-
-       artifact = basename.substring(0 , typeIndex ); 
-
-       versionIndex = artifact.lastIndexOf("-");
-       if (versionIndex != -1) {
-           version = artifact.substring(versionIndex + 1); 
-           document.<portlet:namespace/>fileSelect.version.value = version;
-
-           artifact = artifact.substring(0 , versionIndex );
-           document.<portlet:namespace/>fileSelect.artifact.value = artifact;
-       }
-       else {
-          version = artifact = "";
-       }
-   }
-   else {
-      fileType = "";
-   }
+    // Split the path
+    var pathParts = localFile.split("\\"); // Assuming windows file delim
+    if(localFile.indexOf("/") > 0) // May be *nix delim
+        pathParts = localFile.split("\\");
+    basename = pathParts[pathParts.length - 1]; // Last part is the base file name
+
+    // Attempt to get the artifact and type from the basename
+    // This regular expression for repository filename is taken from Maven1Repository.MAVEN_1_PATTERN
+    regExpStr = "(.+)-([0-9].+)\\.([^0-9]+)";
+    var fileRegExp = new RegExp(regExpStr, "g");
+    if(basename.match(fileRegExp) != null) {
+        // base file name matches the regular expression
+        fileRegExp.compile(regExpStr, "g");
+        var fileParts = fileRegExp.exec(basename);
+        fileType = fileParts[fileParts.length - 1];
+        version = fileParts[fileParts.length - 2];
+        artifact = fileParts[fileParts.length - 3];
+        document.<portlet:namespace/>fileSelect.fileType.value = fileType;
+        document.<portlet:namespace/>fileSelect.version.value = version;
+        document.<portlet:namespace/>fileSelect.artifact.value = artifact;
+
+        // Attempt to suggest the group
+        if(pathParts.length >= 3 && pathParts[pathParts.length-2] == fileType
+'s') {
+            // Maven1Repository
+            document.<portlet:namespace/>fileSelect.group.value = pathParts[pathParts.length-3];
+        } else if(pathParts.length >= 4 && pathParts[pathParts.length-2] == version
&& pathParts[pathParts.length-3] == artifact) {
+            // Maven2Repository
+            document.<portlet:namespace/>fileSelect.group.value = pathParts[pathParts.length-4];
+        } else {
+            document.<portlet:namespace/>fileSelect.group.value = '';
+        }
+    } else {
+        document.<portlet:namespace/>fileSelect.fileType.value = '';
+        document.<portlet:namespace/>fileSelect.version.value = '';
+        document.<portlet:namespace/>fileSelect.artifact.value = '';
+        document.<portlet:namespace/>fileSelect.group.value = '';
+    }
 }
 
 </script>

Modified: geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp?view=diff&rev=492105&r1=492104&r2=492105
==============================================================================
--- geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp
(original)
+++ geronimo/server/branches/1.2/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp
Wed Jan  3 03:17:04 2007
@@ -48,53 +48,43 @@
 }
 
 function <portlet:namespace/>parse(localFile) {
-   // Check for windows file delim
-   fileChar = "\\";
-   fileNameIndex = localFile.lastIndexOf(fileChar);
-   if (fileNameIndex == -1) {
-      // if not found check for *nix delim
-      fileChar = "/";
-      fileNameIndex = localFile.lastIndexOf(fileChar);
-   }
-
-   if (fileNameIndex != -1) {
-      basename = localFile.substring(fileNameIndex + 1);
-
-      prefix = localFile.substring(0 , fileNameIndex );
-
-      groupIndex = prefix.lastIndexOf(fileChar);
-      if (groupIndex != -1) {
-          group = prefix.substring(groupIndex + 1 );
-          document.<portlet:namespace/>fileSelect.group.value = group;        
-      }
-   }
-   else {
-      basename = localFile;
-   }
-
-   // Attempt to get the artifact and type from the basename
-   typeIndex = basename.lastIndexOf(".");
-   if (typeIndex != -1) {
-       fileType = basename.substring(typeIndex + 1);
-       document.<portlet:namespace/>fileSelect.fileType.value = fileType;
-
-       artifact = basename.substring(0 , typeIndex ); 
-
-       versionIndex = artifact.lastIndexOf("-");
-       if (versionIndex != -1) {
-           version = artifact.substring(versionIndex + 1); 
-           document.<portlet:namespace/>fileSelect.version.value = version;
-
-           artifact = artifact.substring(0 , versionIndex );
-           document.<portlet:namespace/>fileSelect.artifact.value = artifact;
-       }
-       else {
-          version = artifact = "";
-       }
-   }
-   else {
-      fileType = "";
-   }
+    // Split the path
+    var pathParts = localFile.split("\\"); // Assuming windows file delim
+    if(localFile.indexOf("/") > 0) // May be *nix delim
+        pathParts = localFile.split("\\");
+    basename = pathParts[pathParts.length - 1]; // Last part is the base file name
+
+    // Attempt to get the artifact and type from the basename
+    // This regular expression for repository filename is taken from Maven1Repository.MAVEN_1_PATTERN
+    regExpStr = "(.+)-([0-9].+)\\.([^0-9]+)";
+    var fileRegExp = new RegExp(regExpStr, "g");
+    if(basename.match(fileRegExp) != null) {
+        // base file name matches the regular expression
+        fileRegExp.compile(regExpStr, "g");
+        var fileParts = fileRegExp.exec(basename);
+        fileType = fileParts[fileParts.length - 1];
+        version = fileParts[fileParts.length - 2];
+        artifact = fileParts[fileParts.length - 3];
+        document.<portlet:namespace/>fileSelect.fileType.value = fileType;
+        document.<portlet:namespace/>fileSelect.version.value = version;
+        document.<portlet:namespace/>fileSelect.artifact.value = artifact;
+
+        // Attempt to suggest the group
+        if(pathParts.length >= 3 && pathParts[pathParts.length-2] == fileType
+'s') {
+            // Maven1Repository
+            document.<portlet:namespace/>fileSelect.group.value = pathParts[pathParts.length-3];
+        } else if(pathParts.length >= 4 && pathParts[pathParts.length-2] == version
&& pathParts[pathParts.length-3] == artifact) {
+            // Maven2Repository
+            document.<portlet:namespace/>fileSelect.group.value = pathParts[pathParts.length-4];
+        } else {
+            document.<portlet:namespace/>fileSelect.group.value = '';
+        }
+    } else {
+        document.<portlet:namespace/>fileSelect.fileType.value = '';
+        document.<portlet:namespace/>fileSelect.version.value = '';
+        document.<portlet:namespace/>fileSelect.artifact.value = '';
+        document.<portlet:namespace/>fileSelect.group.value = '';
+    }
 }
 
 </script>

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp?view=diff&rev=492105&r1=492104&r2=492105
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/repository/normal.jsp
Wed Jan  3 03:17:04 2007
@@ -48,53 +48,43 @@
 }
 
 function <portlet:namespace/>parse(localFile) {
-   // Check for windows file delim
-   fileChar = "\\";
-   fileNameIndex = localFile.lastIndexOf(fileChar);
-   if (fileNameIndex == -1) {
-      // if not found check for *nix delim
-      fileChar = "/";
-      fileNameIndex = localFile.lastIndexOf(fileChar);
-   }
-
-   if (fileNameIndex != -1) {
-      basename = localFile.substring(fileNameIndex + 1);
-
-      prefix = localFile.substring(0 , fileNameIndex );
-
-      groupIndex = prefix.lastIndexOf(fileChar);
-      if (groupIndex != -1) {
-          group = prefix.substring(groupIndex + 1 );
-          document.<portlet:namespace/>fileSelect.group.value = group;        
-      }
-   }
-   else {
-      basename = localFile;
-   }
-
-   // Attempt to get the artifact and type from the basename
-   typeIndex = basename.lastIndexOf(".");
-   if (typeIndex != -1) {
-       fileType = basename.substring(typeIndex + 1);
-       document.<portlet:namespace/>fileSelect.fileType.value = fileType;
-
-       artifact = basename.substring(0 , typeIndex ); 
-
-       versionIndex = artifact.lastIndexOf("-");
-       if (versionIndex != -1) {
-           version = artifact.substring(versionIndex + 1); 
-           document.<portlet:namespace/>fileSelect.version.value = version;
-
-           artifact = artifact.substring(0 , versionIndex );
-           document.<portlet:namespace/>fileSelect.artifact.value = artifact;
-       }
-       else {
-          version = artifact = "";
-       }
-   }
-   else {
-      fileType = "";
-   }
+    // Split the path
+    var pathParts = localFile.split("\\"); // Assuming windows file delim
+    if(localFile.indexOf("/") > 0) // May be *nix delim
+        pathParts = localFile.split("\\");
+    basename = pathParts[pathParts.length - 1]; // Last part is the base file name
+
+    // Attempt to get the artifact and type from the basename
+    // This regular expression for repository filename is taken from Maven1Repository.MAVEN_1_PATTERN
+    regExpStr = "(.+)-([0-9].+)\\.([^0-9]+)";
+    var fileRegExp = new RegExp(regExpStr, "g");
+    if(basename.match(fileRegExp) != null) {
+        // base file name matches the regular expression
+        fileRegExp.compile(regExpStr, "g");
+        var fileParts = fileRegExp.exec(basename);
+        fileType = fileParts[fileParts.length - 1];
+        version = fileParts[fileParts.length - 2];
+        artifact = fileParts[fileParts.length - 3];
+        document.<portlet:namespace/>fileSelect.fileType.value = fileType;
+        document.<portlet:namespace/>fileSelect.version.value = version;
+        document.<portlet:namespace/>fileSelect.artifact.value = artifact;
+
+        // Attempt to suggest the group
+        if(pathParts.length >= 3 && pathParts[pathParts.length-2] == fileType
+'s') {
+            // Maven1Repository
+            document.<portlet:namespace/>fileSelect.group.value = pathParts[pathParts.length-3];
+        } else if(pathParts.length >= 4 && pathParts[pathParts.length-2] == version
&& pathParts[pathParts.length-3] == artifact) {
+            // Maven2Repository
+            document.<portlet:namespace/>fileSelect.group.value = pathParts[pathParts.length-4];
+        } else {
+            document.<portlet:namespace/>fileSelect.group.value = '';
+        }
+    } else {
+        document.<portlet:namespace/>fileSelect.fileType.value = '';
+        document.<portlet:namespace/>fileSelect.version.value = '';
+        document.<portlet:namespace/>fileSelect.artifact.value = '';
+        document.<portlet:namespace/>fileSelect.group.value = '';
+    }
 }
 
 </script>



Mime
View raw message