share.setDescription(description);
share.setCreated(new Date());
share.setModified(new Date());
// Create DocumentLocationPojo and add to the share
DocumentLocationPojo documentLocation = new DocumentLocationPojo();
setRefLocation(location, documentLocation);
share.setDocumentLocation(documentLocation);
if (null == documentLocation.getDatabase()) { // (local file)
// Check, need to be admin:
if (!RESTTools.adminLookup(ownerIdStr, false)) {
rp.setResponse(new ResponseObject("Share", false, "Permission denied: you need to be admin to create a local file ref"));
return rp;
}
if ((null != type) && (type.equalsIgnoreCase("binary") || type.startsWith("binary:"))) {
String[] binaryType = type.split(":", 2);
if (binaryType.length > 1) {
share.setMediaType(binaryType[1]);
share.setType("binary");
}
else {
share.setMediaType(MimeUtils.getMimeType(FilenameUtils.getExtension(idStr)));
}
}
documentLocation.setCollection(idStr); // collection==file, database==id==null
}//TESTED
else {
documentLocation.set_id(new ObjectId(idStr));
}
// Get ShareOwnerPojo object
PersonPojo owner = getPerson(new ObjectId(ownerIdStr));
share.setOwner(getOwner(owner));