int collectionId;
try {
if (inputVar instanceof HashMap) { //xml
collectionId = Integer.parseInt((String)((HashMap) inputVar).get("collectionId"));
if (collectionId > 0) {
Collection col = Collection.find(context, collectionId);
if (col != null) {
Item item = prepareItem(context, col, (HashMap) inputVar);
return String.valueOf(item.getID());
} else {
throw new EntityException("Internal server error", "Could not create item", 500);
}
} else {
throw new EntityException("Internal server error", "Could not create item", 500);
}
} else if(inputVar instanceof InputStream) { //zip
Map<String, InputStream> fileMap = new HashMap<String, InputStream>();
Map xmlMap = new HashMap();
ZipInputStream zipInputStream = new ZipInputStream((InputStream) inputVar);
ZipEntry zipEntry = zipInputStream.getNextEntry();
while (zipEntry != null) {
if ("package.xml".equalsIgnoreCase(zipEntry.getName())) {
xmlMap = (Map) Utils.translateFormattedData("xml", zipInputStream);
} else {
InputStream nis = Utils.transferInputStream(zipInputStream);
fileMap.put(zipEntry.getName(), nis);
}
zipEntry = zipInputStream.getNextEntry();
}
collectionId = Integer.parseInt((String) xmlMap.get("collectionId"));
if (collectionId > 0) {
Collection col = Collection.find(context, collectionId);
if (col != null) {
Item item = prepareItem(context, col, xmlMap);
List<Map> bundleList = getNodeList(xmlMap, "bundles", "bundle");