name1 = name.substring(0, index);
name2 = name.substring(index + 1);
}
String resultsAsStr;
DocType type = XRegClientConstants.DocType.valueOf(docTypeStr);
switch (type) {
case AppDesc:
System.out.println(name1 + " " + name2);
resultsAsStr = context.getRegService().getAppDesc(name1, name2);
break;
case ServiceDesc:
resultsAsStr = context.getRegService().getServiceMap(name1);
break;
case HostDesc:
resultsAsStr = context.getRegService().getHostDesc(name1);
break;
default:
throw new ServletException("Unknown document Type");
}
System.out.println("I got it" + resultsAsStr);
response.setContentType("text/xml");
// response.getWriter().write(resultsAsStr);
} else {
boolean isMultipart = ServletFileUpload
.isMultipartContent(new ServletRequestContext(request));
if (isMultipart) {
DiskFileItemFactory factory = new DiskFileItemFactory();
// Set factory constraints
factory.setSizeThreshold(0);
File tempDir = new File("/tmp/fileupload" + System.currentTimeMillis());
if (!tempDir.exists()) {
tempDir.mkdir();
}
factory.setRepository(tempDir);
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Set overall request size constraint
// upload.setSizeMax(yourMaxRequestSize);
// Parse the request
List items = upload.parseRequest(request);
FileItem file = null;
for (int i = 0; i < items.size(); i++) {
FileItem item = (FileItem) items.get(i);
System.out.println(item.getFieldName() + " = " + item.getString() + " "
+ item.getName());
if (!item.isFormField()) {
file = item;
} else if ("docType".equals(item.getFieldName())) {
docTypeStr = item.getString();
}
}
if (docTypeStr != null && file != null) {
DocType type = XRegClientConstants.DocType.valueOf(docTypeStr);
switch (type) {
case AppDesc:
context.getRegService().registerAppDesc(file.getString());
break;
case ServiceDesc: