Author: reinhard
Date: Sun Oct 10 05:13:30 2004
New Revision: 54250
Modified:
cocoon/whiteboard/block-deployer/src/impl/org/apache/cocoon/blockdeployer/utils/LocatorUtils.java
Log:
hack to get a random string for block deployment
Modified:
cocoon/whiteboard/block-deployer/src/impl/org/apache/cocoon/blockdeployer/utils/LocatorUtils.java
==============================================================================
---
cocoon/whiteboard/block-deployer/src/impl/org/apache/cocoon/blockdeployer/utils/LocatorUtils.java
(original)
+++
cocoon/whiteboard/block-deployer/src/impl/org/apache/cocoon/blockdeployer/utils/LocatorUtils.java
Sun Oct 10 05:13:30 2004
@@ -21,6 +21,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Random;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -98,7 +99,7 @@
* of the base directory. After computing the directory containing the
.cob file
* the first .cob file is returned as @link File.
*/
- public static File getCobAsFile(File basedir, String blockPath)
+ public static File getBlockAsFile(File basedir, String blockPath)
throws FileNotFoundException, IllegalArgumentException {
if(basedir == null || blockPath == null) {
@@ -126,4 +127,18 @@
absoluteBlockBasedir + " for the first available COB file.");
}
+ // FIXME hack (synchronization, already created directories, alghoritmus)
+ // FIXME replace with syncronized counter starting with 0001, 0002, ...
+ public static String createRandomString() {
+ String rand = null;
+ do {
+ Random random = new Random();
+ long l = random.nextLong();
+ if(l < 0) {
+ l = l * -1;
+ }
+ rand = Long.toString(l);
+ } while(rand.length() < 4);
+ return rand.substring(0,4);
+ }
}