Author: simoneg
Date: Mon Feb 1 11:56:17 2010
New Revision: 905264
URL: http://svn.apache.org/viewvc?rev=905264&view=rev
Log:
Removed "/" from file identificatin string, causes problems with tomcat
Modified:
labs/magma/trunk/beans-file/src/main/java/org/apache/magma/beans/MagFile.java
Modified:
labs/magma/trunk/beans-file/src/main/java/org/apache/magma/beans/MagFile.java
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/beans-file/src/main/java/org/apache/magma/beans/MagFile.java?rev=905264&r1=905263&r2=905264&view=diff
==============================================================================
---
labs/magma/trunk/beans-file/src/main/java/org/apache/magma/beans/MagFile.java
(original)
+++
labs/magma/trunk/beans-file/src/main/java/org/apache/magma/beans/MagFile.java
Mon Feb 1 11:56:17 2010
@@ -65,41 +65,20 @@
char fmt = spec.charAt(0);
spec = spec.substring(1);
if (fmt == '2') {
- StringTokenizer stok = new StringTokenizer(spec, "*/",
true);
+ StringTokenizer stok = new StringTokenizer(spec, "*/",
false);
// First one is always the source, and is mandatory
this.source = stok.nextToken();
- if (stok.hasMoreTokens()) {
+ while (stok.hasMoreTokens()) {
String tok = stok.nextToken();
- // If it is already "/" then we have name and
nothing else
- if (tok.equals("/")) {
- this.originalName = stok.nextToken();
+ if (tok.startsWith("0")) {
+ // If it is "0" then it is the length
+ this.length = Long.parseLong(tok, 32);
+ } else if (tok.indexOf('$') != -1) {
+ // if contains '$' it's mime type
+ this.mimeType = tok.replace('$', '/');
} else {
- // Otherwise it must be "*", so get the
value after it
- tok = stok.nextToken();
- if (tok.startsWith("0")) {
- // If it is "0" then it is not
a mime type
- this.length =
Long.parseLong(tok, 32);
- } else {
- // Otherwise it is a mime type
- this.mimeType =
tok.replace('$', '/');
- }
- if (stok.hasMoreTokens()) {
- // Next separator is "*" is
after mime type there is length
- tok = stok.nextToken();
- if (tok.equals("/")) {
- this.originalName =
stok.nextToken();
- } else {
- // We have a length,
decode it
- tok = stok.nextToken();
- this.length =
Long.parseLong(tok, 32);
- // We have more tokens,
can be only the file name
- if
(stok.hasMoreElements()) {
- if
(stok.nextToken().equals("/")) {
-
this.originalName = stok.nextToken();
- }
- }
- }
- }
+ this.originalName = tok;
+ break;
}
}
} else if (fmt == '1') {
@@ -184,11 +163,9 @@
* <ul>
* <li>"2" to identify format
* <li>source, which is the handle code
- * <li>If there is a mime type or known length, an "*" follows.
- * <li>mime type if present, replacing "/" with "$". Otherwise "0"
- * <li>If there are both size and mime type, an "*" to separate them.
- * <li>size, a long string encoded base 32, if present
- * <li>if there is a name, "/" followed by the name
+ * <li>mime type if present, preceded by "*", replacing "/" with "$"
+ * <li>size if present, a long string encoded base 32, preceded by "*0"
+ * <li>name if present, preceded by "*", replacing "$" with "_"
* </ul>
* This encodes the four informations (handle code, mime type, size,
original name) in the lowest
* number of characters.
@@ -205,20 +182,20 @@
f2.append(this.source);
if (this.mimeType != null) {
f2.append('*');
- f2.append(this.mimeType.replace('/', '$'));
- if (this.length != 0) {
- f2.append("*");
+ String mime = this.mimeType.replace('/', '$');
+ f2.append(mime);
+ if (mime.indexOf('$') == -1) {
+ f2.append('$');
}
- } else if (this.length != 0) {
- f2.append('*');
- f2.append('0');
}
if (this.length != 0) {
+ f2.append('*');
+ f2.append('0');
f2.append(Long.toString(this.length, 32));
}
if (this.originalName != null) {
- f2.append('/');
- f2.append(this.originalName);
+ f2.append('*');
+ f2.append(this.originalName.replace('$', '_'));
}
// Old 1 format
//return "1" + this.source + "*" + this.originalName + "*" +
this.mimeType + "*" + this.length;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]