now, don't worry about that. The rest of this will be written assuming it's part of the deploy
workflow and we'll deal with the refactoring later.
jdobies, Feb 27, 2008
*/
try {
ContentManagerLocal contentManager = LookupUtil.getContentManager();
//store information about uploaded file for packageDetails as most of it is already available
Map<String, String> packageUploadDetails = new HashMap<String, String>();
packageUploadDetails.put(ContentManagerLocal.UPLOAD_FILE_SIZE,
String.valueOf(fileItem.getFileSize()));
packageUploadDetails.put(ContentManagerLocal.UPLOAD_FILE_INSTALL_DATE,
String.valueOf(System.currentTimeMillis()));
packageUploadDetails.put(ContentManagerLocal.UPLOAD_OWNER, subject.getName());
packageUploadDetails.put(ContentManagerLocal.UPLOAD_FILE_NAME, fileItem.getFileName());
String sha = null;
String md5 = null;
try {//Easier to implement here than in server side bean. Shouldn't affect performance too much.
md5 = new MessageDigestGenerator(MessageDigestGenerator.MD5).calcDigestString(fileItem
.getFile());
sha = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(fileItem
.getFile());
} catch (IOException e1) {
log.warn("Error calculating file digest(s)", e1);
}
packageUploadDetails.put(ContentManagerLocal.UPLOAD_MD5, md5);
packageUploadDetails.put(ContentManagerLocal.UPLOAD_SHA256, sha);
packageUploadDetails.put(ContentManagerLocal.UPLOAD_DISPLAY_VERSION, displayVersion);
//For package types that handle their own versioning, etc. let's use what the user passed in
//as a version. For the standard, i.e. agent-plugin defined, package types use what we want
//to use for them - sha-based versions to deal with improper versions discovered/declared by
//the packages (i.e. versions in MANIFEST.MF not properly updated)
//
//Did I say I can't wait for all this to disappear with the new provisioning? :)
boolean nonStandardPackageType = ContentManagerHelper.getPackageTypePluginContainer().getPluginManager().getBehavior(packageTypeId) != null;
String versionToUse = nonStandardPackageType ? displayVersion : formatVersion(sha);
Integer iRepoId = usingARepo ? Integer.parseInt(repoId) : null;
packageVersion = contentManager.getUploadedPackageVersion(subject, packageName, packageTypeId,
versionToUse, architectureId, packageStream, packageUploadDetails, iRepoId);
} catch (NoResultException nre) {
//eat the exception. Some of the queries return no results if no package yet exists which is fine.
} catch (Exception e) {