/** * @see org.sakaiproject.content.api.ContentHostingService#addAttachmentResource(java.lang.String, java.lang.String, InputStream, org.sakaiproject.entity.api.ResourceProperties) */ public ContentResource addAttachmentResource(String name, String type, InputStream content, ResourceProperties properties) throws IdInvalidException, InconsistentException, IdUsedException, PermissionException, OverQuotaException, ServerOverloadException { // make sure the name is valid Validator.checkResourceId(name); // resource must also NOT end with a separator characters (we fix it) if (name.endsWith(Entity.SEPARATOR)) { name = name.substring(0, name.length() - 1); } // form a name based on the attachments collection, a unique folder id, and the given name String collection = ATTACHMENTS_COLLECTION + idManager.createUuid() + Entity.SEPARATOR; String id = collection + name; if (id.length() > MAXIMUM_RESOURCE_ID_LENGTH) { throw new RuntimeException(ID_LENGTH_EXCEPTION); } // add this collection addAndCommitAttachmentCollection(collection, name, null); // and add the resource return addResource(id, type, content, properties, new ArrayList(), NotificationService.NOTI_NONE); } // addAttachmentResource
Validator.checkResourceId(name);
Validator.checkResourceId(name); checkCollection(collectionId);
Validator.checkResourceId(name);
badId = !Validator.checkResourceId(submissionId); submissionId = IdManager.createUuid();
badId = !Validator.checkResourceId(contentId); contentId = IdManager.createUuid();
Validator.checkResourceId(justName);
badId = !Validator.checkResourceId(assignmentId); assignmentId = IdManager.createUuid();
Validator.checkResourceId(justName);
if (!Validator.checkResourceId(submissionFromXml.getId())) throw new IdInvalidException(submissionFromXml.getId());
Validator.checkResourceId(alias);
if (!Validator.checkResourceId(id)) { throw new IdInvalidException("Id " + id + " is not a valid id format");
if (!Validator.checkResourceId(assignmentFromXml.getId())) throw new IdInvalidException(assignmentFromXml.getId());
if (!Validator.checkResourceId(contentFromXml.getId())) throw new IdInvalidException(contentFromXml.getId());
Validator.checkResourceId(userFromXml.getEid());
if (!Validator.checkResourceId(id)) { throw new IdInvalidException("Id " + id + " is not valid");