/* (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); } } }
/** {@inheritDoc} */ public ContentResourceEdit putResource(String id) { ContentEntity ce = getVirtualChild(id, getRealParent(id), false); if (ce != null) { ContentHostingHandler chh = ce.getContentHandler(); if (chh != null) { ContentResourceEdit cre = chh.getContentResourceEdit(id); cre.setVirtualContentEntity( getVirtualChild(id, getRealParent(id), false).getVirtualContentEntity()); return cre; } } return storage.putResource(id); }
public void commitResource(ContentResourceEdit edit) throws ServerOverloadException { // keep the body out of the XML boolean goin = in(); try { if (resolver != null && goin) { resolver.commitResource(edit); } else { BaseResourceEdit redit = (BaseResourceEdit) edit; if (redit.m_contentStream != null) { } else if (redit.m_body != null) { } else { } m_resourceStore.commitResource(edit); } resourceCache.remove(edit.getId()); } finally { out(); } }
/** {@inheritDoc} */ public void removeResource(ContentResourceEdit edit) { ContentHostingHandler chh = edit.getContentHandler(); if (chh != null) { chh.removeResource(edit); } else { storage.removeResource(edit); } }
/** {@inheritDoc} */ public void commitResource(ContentResourceEdit edit) throws ServerOverloadException { ContentHostingHandler chh = edit.getContentHandler(); if (chh != null) { chh.commit(edit); } else { storage.commitResource(edit); } }
/** {@inheritDoc} */ public void commitDeleteResource(ContentResourceEdit edit, String uuid) { ContentHostingHandler chh = edit.getContentHandler(); if (chh != null) { chh.commitDeleted(edit, uuid); } else { storage.commitDeleteResource(edit, uuid); } }
/** update xml and store the body of file TODO storing of body content is not used now. */ public void commitDeleteResource(ContentResourceEdit edit, String uuid) { resourceCache.remove(edit.getId()); boolean goin = in(); try { if (resolver != null && goin) { resolver.commitDeleteResource(edit, uuid); } else { m_resourceDeleteStore.commitDeleteResource(edit, uuid); } } finally { out(); } }
public void removeResource(ContentResourceEdit edit) { // delete the body boolean goin = in(); try { if (resolver != null && goin) { resolver.removeResource(edit); } else { m_resourceStore.removeResource(edit); } resourceCache.remove(edit.getId()); } finally { out(); } }
public void cancelResource(ContentResourceEdit edit) { boolean goin = in(); try { if (resolver != null && goin) { resolver.cancelResource(edit); } else { // clear the memory image of the body byte[] body = ((BaseResourceEdit) edit).m_body; ((BaseResourceEdit) edit).m_body = null; m_resourceStore.cancelResource(edit); } resourceCache.remove(edit.getId()); } finally { out(); } }