public Set copyItemAttachmentSet(ItemData newItem, Set itemAttachmentSet) { HashSet h = new HashSet(); Iterator o = itemAttachmentSet.iterator(); while (o.hasNext()) { ItemAttachment itemAttachment = (ItemAttachment) o.next(); try { // create a copy of the resource AssessmentService service = new AssessmentService(); ContentResource cr_copy = service.createCopyOfContentResource( itemAttachment.getResourceId(), itemAttachment .getFilename()); // get relative path String url = getRelativePath(cr_copy.getUrl(), ServerConfigurationService.getServerUrl()); ItemAttachment newItemAttachment = new ItemAttachment(null, newItem, cr_copy.getId(), itemAttachment.getFilename(), itemAttachment.getMimeType(), itemAttachment.getFileSize(), itemAttachment.getDescription(), url, itemAttachment.getIsLink(), itemAttachment.getStatus(), AgentFacade.getAgentString(), new Date(), AgentFacade.getAgentString(), new Date()); h.add(newItemAttachment); } catch (Exception e) { log.warn(e.getMessage()); } } return h; }
itemAttachment.getResourceId(), itemAttachment .getFilename(), toContext); newItem, cr_copy.getId(), itemAttachment.getFilename(), itemAttachment.getMimeType(), itemAttachment .getFileSize(), itemAttachment.getDescription(), url, itemAttachment .getIsLink(), itemAttachment.getStatus(), itemAttachment.getCreatedBy(), itemAttachment .getCreatedDate(), itemAttachment .getLastModifiedBy(), itemAttachment .getLastModifiedDate()); h.add(newItemAttachment); } catch (Exception e) {
private Set<ItemAttachmentIfc> makeEMIAttachments(ItemFacade item, List<String> attachList) { if(attachList == null || attachList.isEmpty()){ return null; } Set<ItemAttachmentIfc> attachSet = new TreeSet<ItemAttachmentIfc>(); for(String attach: attachList){ attach = attach.trim(); int index = attach.indexOf("["); String fileName = attach.substring(0, index); attach = attach.substring(index); index = attach.indexOf("]"); String mimeType = attach.substring(1, index); index = attach.indexOf("("); attach = attach.substring(index); index = attach.indexOf(")"); Long size = Long.valueOf(attach.substring(1, index)); attach = attach.substring(index+1); String location = attach; String resourceId = location.replace("%2B", "+").replace("%20", " ").replace("/access/content", ""); attachSet.add(new ItemAttachment(null, item, resourceId, fileName, mimeType, size, null, location, false, ItemAttachmentIfc.ACTIVE_STATUS, null, null, null, null)); } return attachSet; }
public void removeItemAttachment(Long itemAttachmentId) { ItemAttachment itemAttachment = getHibernateTemplate().load(ItemAttachment.class, itemAttachmentId); ItemDataIfc item = itemAttachment.getItem(); int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount(); while (retryCount > 0) { try { if (item != null) { Set set = item.getItemAttachmentSet(); set.remove(itemAttachment); getHibernateTemplate().delete(getHibernateTemplate().merge(itemAttachment)); retryCount = 0; } } catch (Exception e) { log.warn("Error while trying to delete itemAttachment: " + e.getMessage()); retryCount = PersistenceService.getInstance().getPersistenceHelper().retryDeadlock(e, retryCount); } } }
private Set<ItemAttachmentIfc> makeEMIAttachments(ItemFacade item, List<String> attachList) { if(attachList == null || attachList.isEmpty()){ return null; } Set<ItemAttachmentIfc> attachSet = new TreeSet<ItemAttachmentIfc>(); for(String attach: attachList){ attach = attach.trim(); int index = attach.indexOf("["); String fileName = attach.substring(0, index); attach = attach.substring(index); index = attach.indexOf("]"); String mimeType = attach.substring(1, index); index = attach.indexOf("("); attach = attach.substring(index); index = attach.indexOf(")"); Long size = Long.valueOf(attach.substring(1, index)); attach = attach.substring(index+1); String location = attach; String resourceId = location.replace("%2B", "+").replace("%20", " ").replace("/access/content", ""); attachSet.add(new ItemAttachment(null, item, resourceId, fileName, mimeType, size, null, location, false, ItemAttachmentIfc.ACTIVE_STATUS, null, null, null, null)); } return attachSet; }
itemAttachment.getResourceId(), itemAttachment .getFilename()); .getFilename(), itemAttachment.getMimeType(), itemAttachment.getFileSize(), itemAttachment .getDescription(), url, itemAttachment .getIsLink(), itemAttachment.getStatus(), itemAttachment.getCreatedBy(), itemAttachment .getCreatedDate(), itemAttachment .getLastModifiedBy(), itemAttachment .getLastModifiedDate()); h.add(publishedItemAttachment); } catch (Exception e) {
public Set copyItemAttachmentSet(ItemData newItem, Set itemAttachmentSet) { HashSet h = new HashSet(); Iterator o = itemAttachmentSet.iterator(); while (o.hasNext()) { ItemAttachment itemAttachment = (ItemAttachment) o.next(); try { // create a copy of the resource AssessmentService service = new AssessmentService(); ContentResource cr_copy = service.createCopyOfContentResource( itemAttachment.getResourceId(), itemAttachment .getFilename()); // get relative path String url = getRelativePath(cr_copy.getUrl(), ServerConfigurationService.getServerUrl()); ItemAttachment newItemAttachment = new ItemAttachment(null, newItem, cr_copy.getId(), itemAttachment.getFilename(), itemAttachment.getMimeType(), itemAttachment.getFileSize(), itemAttachment.getDescription(), url, itemAttachment.getIsLink(), itemAttachment.getStatus(), AgentFacade.getAgentString(), new Date(), AgentFacade.getAgentString(), new Date()); h.add(newItemAttachment); } catch (Exception e) { log.warn(e.getMessage()); } } return h; } }
private Set copyItemAttachmentSet(ItemData cloned, Set itemAttachmentSet) { AssessmentService service = new AssessmentService(); Set h = new HashSet(); Iterator n = itemAttachmentSet.iterator(); while (n.hasNext()) { ItemAttachmentIfc itemAttachment = (ItemAttachmentIfc) n.next(); ContentResource cr_copy = service.createCopyOfContentResource( itemAttachment.getResourceId(), itemAttachment.getFilename()); ItemAttachmentIfc newItemAttachment = new ItemAttachment( null, cr_copy.getId(), itemAttachment.getFilename(), itemAttachment.getMimeType(), itemAttachment.getFileSize(), itemAttachment.getDescription(), cr_copy.getUrl(true), itemAttachment.getIsLink(), itemAttachment.getStatus(), itemAttachment.getCreatedBy(), itemAttachment.getCreatedDate(), itemAttachment.getLastModifiedBy(), itemAttachment.getLastModifiedDate()); newItemAttachment.setItem(cloned); h.add(newItemAttachment); } return h; }
itemAttachment.getResourceId(), itemAttachment .getFilename(), toContext); newItem, cr_copy.getId(), itemAttachment.getFilename(), itemAttachment.getMimeType(), itemAttachment .getFileSize(), itemAttachment.getDescription(), url, itemAttachment .getIsLink(), itemAttachment.getStatus(), itemAttachment.getCreatedBy(), itemAttachment .getCreatedDate(), itemAttachment .getLastModifiedBy(), itemAttachment .getLastModifiedDate()); h.add(newItemAttachment); } catch (Exception e) {
private Set copyItemAttachmentSet(ItemData cloned, Set itemAttachmentSet) { AssessmentService service = new AssessmentService(); Set h = new HashSet(); Iterator n = itemAttachmentSet.iterator(); while (n.hasNext()) { ItemAttachmentIfc itemAttachment = (ItemAttachmentIfc) n.next(); ContentResource cr_copy = service.createCopyOfContentResource( itemAttachment.getResourceId(), itemAttachment.getFilename()); ItemAttachmentIfc newItemAttachment = new ItemAttachment( null, cr_copy.getId(), itemAttachment.getFilename(), itemAttachment.getMimeType(), itemAttachment.getFileSize(), itemAttachment.getDescription(), cr_copy.getUrl(true), itemAttachment.getIsLink(), itemAttachment.getStatus(), itemAttachment.getCreatedBy(), itemAttachment.getCreatedDate(), itemAttachment.getLastModifiedBy(), itemAttachment.getLastModifiedDate()); newItemAttachment.setItem(cloned); h.add(newItemAttachment); } return h; }
itemAttachment.getResourceId(), itemAttachment .getFilename()); .getFilename(), itemAttachment.getMimeType(), itemAttachment.getFileSize(), itemAttachment .getDescription(), url, itemAttachment .getIsLink(), itemAttachment.getStatus(), itemAttachment.getCreatedBy(), itemAttachment .getCreatedDate(), itemAttachment .getLastModifiedBy(), itemAttachment .getLastModifiedDate()); h.add(publishedItemAttachment); } catch (Exception e) {
ResourceProperties p = cr.getProperties(); if (isEditPendingAssessmentFlow) { attach = new ItemAttachment();
ResourceProperties p = cr.getProperties(); if (isEditPendingAssessmentFlow) { attach = new ItemAttachment();