}
}
try {
WriteableRepository repo = PortletManager.getCurrentServer(actionRequest).getWritableRepositories()[0];
File uploadFile = null;
File file = null;
String name = null;
String basename = null;
String fileType = null;
String artifact = null;
String version = null;
String group = null;
String jarName = null;
PortletFileUpload uploader = new PortletFileUpload(new DiskFileItemFactory());
try {
List items = uploader.parseRequest(actionRequest);
for (Iterator i = items.iterator(); i.hasNext();) {
FileItem item = (FileItem) i.next();
if (!item.isFormField()) {
String fieldName = item.getFieldName().trim();
name = item.getName().trim();
if (name.length() == 0) {
file = null;
} else {
// IE sends full path while Firefox sends just basename
// in the case of "FullName" we may be able to infer the group
// Note, we can't use File.separatorChar because the file separator
// is dependent upon the client and not the server.
String fileChar = "\\";
int fileNameIndex = name.lastIndexOf(fileChar);
if (fileNameIndex == -1) {
fileChar = "/";
fileNameIndex = name.lastIndexOf(fileChar);
}
if (fileNameIndex != -1) {
basename = name.substring(fileNameIndex + 1);
} else {
basename = name;
}
// Create the temporary file to be used for import to the server
file = File.createTempFile("geronimo-import", "");
file.deleteOnExit();
log.debug("Writing repository import file to " + file.getAbsolutePath());
}
if ("local".equals(fieldName)) {
uploadFile = file;
}
if (file != null) {
try {
item.write(file);
} catch (Exception e) {
throw new PortletException(e);
}
}
// This is not the file itself, but one of the form fields for the URI
} else {
String fieldName = item.getFieldName().trim();
if ("group".equals(fieldName)) {
group = item.getString().trim();
} else if ("artifact".equals(fieldName)) {
artifact = item.getString().trim();
} else if ("version".equals(fieldName)) {
version = item.getString().trim();
} else if ("fileType".equals(fieldName)) {
fileType = item.getString().trim();
} else if ("jarName".equals(fieldName)) {
jarName = item.getString().trim();
}
}
}
if (jarName != null && jarName.length() > 0) {
ExplicitDefaultArtifactResolver instance = KernelRegistry.getSingleKernel().getGBean(ExplicitDefaultArtifactResolver.class);
Properties set = new Properties();
set.put(jarName, group + "/" + artifact + "/" + version + "/" + fileType);
instance.addAliases(set);
}
repo.copyToRepository(file, new Artifact(group, artifact, version, fileType), new FileWriteMonitor() {
public void writeStarted(String fileDescription, int fileSize) {
log.info("Copying into repository " + fileDescription + "...");
}
public void writeProgress(int bytes) {