// productTypeRepo/productName/fileName.productionDateTime
// we'll use the format: yyyy.dd.MM.HH.mm.ss
for (Iterator<Reference> i = product.getProductReferences().iterator(); i
.hasNext();) {
Reference r = i.next();
String dataStoreRef = null;
try {
dataStoreRef = new File(new URI(product.getProductType()
.getProductRepositoryPath())).toURL()
.toExternalForm()
+ "/"
+ product.getProductName()
+ "/"
+ new File(new URI(r.getOrigReference())).getName()
+ "." + productionDateTime;
LOG.log(Level.FINER,
"DateTimeVersioner: Generated dataStoreRef: "
+ dataStoreRef + " from original ref: "
+ r.getOrigReference());
r.setDataStoreReference(dataStoreRef);
} catch (URISyntaxException e) {
LOG
.log(
Level.WARNING,
"DateTimeVersioner: Error generating URI to get name "
+ "of original ref while generating data store ref for orig ref: "
+ r.getOrigReference()
+ ": Message: " + e.getMessage());
// try and keep generating
} catch (MalformedURLException e) {
LOG.log(Level.WARNING,
"DateTimeVersioner: Error getting URL for product repository path "
+ product.getProductType()
.getProductRepositoryPath()
+ ": Message: " + e.getMessage());
// try and keep generating
}
}
} else if (product.getProductStructure().equals(
Product.STRUCTURE_HIERARCHICAL)) {
// if its heirarchical, then we'll version the files within the
// directory
// first, we need to get a list of all the references from the
// original dir
Reference origDirRef = (Reference) product.getProductReferences()
.get(0);
try {
String dataStoreRef = new File(new URI(product.getProductType()
.getProductRepositoryPath())).toURL().toExternalForm()
+ URLEncoder.encode(product.getProductName(), "UTF-8")
+ "/";
LOG.log(Level.INFO,
"DateTimeVersioner: generated DataStore ref: "
+ dataStoreRef + " from origDirRef: "
+ origDirRef.getOrigReference());
origDirRef.setDataStoreReference(dataStoreRef);
} catch (MalformedURLException e) {
LOG.log(Level.WARNING,
"DateTimeVersioner: MalformedURLException while generating "
+ "initial data store ref for origRef: "
+ origDirRef.getOrigReference());
throw new VersioningException(e);
} catch (URISyntaxException e) {
LOG.log(Level.WARNING,
"DateTimeVersioner: Error creating File reference from original dir URI: "
+ origDirRef.getOrigReference() + ": Message: "
+ e.getMessage());
throw new VersioningException(
"Unable to generate references from original dir reference for product: "
+ product.getProductName() + ": Message: "
+ e.getMessage());
} catch (UnsupportedEncodingException e) {
LOG.log(Level.WARNING,
"DateTimeVersioner: UnsupportedEncodingException while generating "
+ "initial data store ref for origRef: "
+ origDirRef.getOrigReference());
throw new VersioningException(e);
}
// create the basic data store refs
VersioningUtils.createBasicDataStoreRefsHierarchical(product