/* (non-Javadoc) * @see uk.ac.ox.oucs.oxam.logic.PaperFileService#deposit(uk.ac.ox.oucs.oxam.logic.PaperFile, uk.ac.ox.oucs.oxam.logic.Callback) */ public void deposit(PaperFile paperFile, InputStream in) { PaperFileImpl impl = castToImpl(paperFile); String path = impl.getPath(); ContentResourceEdit resource = null; try { try { contentHostingService.checkResource(path); resource = contentHostingService.editResource(path); // Ignore PermissionException, IdUnusedException, TypeException // As they are too serious to continue. } catch (IdUnusedException iue) { // Will attempt to create containing folders. resource = contentHostingService.addResource(path); // Like the basename function. String filename = StringUtils.substringAfterLast(path, "/"); ResourceProperties props = resource.getPropertiesEdit(); props.addProperty(ResourceProperties.PROP_DISPLAY_NAME, filename); resource.setContentType(mimeTypes.getContentType(filename)); } resource.setContent(in); contentHostingService.commitResource(resource, NotificationService.NOTI_NONE); LOG.debug("Sucessfully copied file to: " + path); } catch (OverQuotaException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ServerOverloadException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (PermissionException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TypeException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IdUsedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IdInvalidException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InconsistentException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { // Close the stream here as this is where it's created. if (resource.isActiveEdit()) { contentHostingService.cancelResource(resource); } } }
public static void cancelResource(org.sakaiproject.content.api.ContentResourceEdit param0) { org.sakaiproject.content.api.ContentHostingService service = getInstance(); if (service == null) return; service.cancelResource(param0); }