.getProperty("org.apache.oodt.cas.filemgr.mime.type.repository"));
String productName = null;
String productRepo = null;
String transferType = null;
Reference dirReference = null;
List<Reference> fileReferences = null;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("--dir")) {
transferType = "dir";
dirReference = new Reference();
dirReference.setOrigReference(new File(new URI(args[++i]))
.toURI().toString());
LOG.log(Level.FINER,
"LocalFileTransfer.main: Generated orig reference: "
+ dirReference.getOrigReference());
} else if (args[i].equals("--files")) {
transferType = "files";
fileReferences = new Vector<Reference>();
for (int j = i + 1; j < args.length; j++) {
LOG.log(Level.FINER,
"LocalFileTransfer.main: Adding file ref: "
+ args[j]);
fileReferences.add(new Reference(args[j], null, new File(
args[j]).length(), mimeTypeRepo
.getMimeType(args[j])));
}
} else if (args[i].equals("--productName")) {
productName = args[++i];
} else if (args[i].equals("--productRepo")) {
productRepo = args[++i];
}
}
if (transferType == null
|| (transferType != null && ((transferType.equals("dir") && dirReference == null)
|| (transferType.equals("files") && fileReferences == null)
|| (transferType != null && !(transferType
.equals("dir") || transferType.equals("files")))
|| productName == null || productRepo == null))) {
System.err.println(usage);
System.exit(1);
}
// construct a new Product
Product p = new Product();
p.setProductName(productName);
if (transferType.equals("dir")) {
p.setProductStructure(Product.STRUCTURE_HIERARCHICAL);
dirReference.setDataStoreReference(new File(new URI(productRepo))
.toURL().toExternalForm()
+ URLEncoder.encode(p.getProductName(), "UTF-8") + "/");
p.getProductReferences().add(dirReference);
/* we'll do a simple versioning scheme ourselves: no versioning! */
p.getProductReferences().addAll(
VersioningUtils.getReferencesFromDir(new File(new URI(
dirReference.getOrigReference()))));
VersioningUtils.createBasicDataStoreRefsHierarchical(p
.getProductReferences());
} else if (transferType.equals("files")) {
p.setProductStructure("Flat");
p.getProductReferences().addAll(fileReferences);