@Test public void testDeleteAttachment() { handler.addRequest("DELETE", "/qcbin/rest/domains/domain/projects/project/defects/1/attachments/logfile.txt", 200) .content("attachmentServiceTest_attachment.xml"); handler.async(); addEntityListener(new EntityNotFound(handler, "attachment", 653, true)); attachmentService.deleteAttachment("logfile.txt", new EntityRef("defect", 1)); }
public void deleteAttachment(String name, EntityRef parent) { MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}/attachments/{2}", parent.type, parent.id, EntityQuery.encode(name)) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); } else { EntityList list = EntityList.create(result.getBodyAsStream()); if(!list.isEmpty()) { entityService.fireEntityNotFound(new EntityRef(list.get(0)), true); } } }
AttachmentService { public void deleteAttachment(String name, EntityRef parent) { MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}/attachments/{2}", parent.type, parent.id, EntityQuery.encode(name)) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); } else { EntityList list = EntityList.create(result.getBodyAsStream()); if(!list.isEmpty()) { entityService.fireEntityNotFound(new EntityRef(list.get(0)), true); } } } }
AttachmentService { public void deleteAttachment(String name, EntityRef parent) { MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}/attachments/{2}", parent.type, parent.id, EntityQuery.encode(name)) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); } else { EntityList list = EntityList.create(result.getBodyAsStream()); if(!list.isEmpty()) { entityService.fireEntityNotFound(new EntityRef(list.get(0)), true); } } } AttachmentService(RestService restService, EntityService entityService, ErrorService errorService); }
AttachmentService { public void deleteAttachment(String name, EntityRef parent) { MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}/attachments/{2}", parent.type, parent.id, EntityQuery.encode(name)) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); } else { EntityList list = EntityList.create(result.getBodyAsStream()); if(!list.isEmpty()) { entityService.fireEntityNotFound(new EntityRef(list.get(0)), true); } } } AttachmentService(RestService restService, EntityService entityService, ErrorService errorService); Entity getAttachmentEntity(Entity entity); Entity getAttachmentEntity(String name, EntityRef parent); String createAttachment(String filename, IndicatingInputStream is, long length, EntityRef parent); boolean updateAttachmentContent(String name, EntityRef parent, IndicatingInputStream is, long length, boolean silent); Entity updateAttachmentProperty(String name, EntityRef parent, String propertyName, String propertyValue, boolean silent); void deleteAttachment(String name, EntityRef parent); }
AttachmentService { public void deleteAttachment(String name, EntityRef parent) { MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}/attachments/{2}", parent.type, parent.id, EntityQuery.encode(name)) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); } else { EntityList list = EntityList.create(result.getBodyAsStream()); if(!list.isEmpty()) { entityService.fireEntityNotFound(new EntityRef(list.get(0)), true); } } } AttachmentService(RestService restService, EntityService entityService, ErrorService errorService); Entity getAttachmentEntity(Entity entity); Entity getAttachmentEntity(String name, EntityRef parent); String createAttachment(String filename, IndicatingInputStream is, long length, EntityRef parent); boolean updateAttachmentContent(String name, EntityRef parent, IndicatingInputStream is, long length, boolean silent); Entity updateAttachmentProperty(String name, EntityRef parent, String propertyName, String propertyValue, boolean silent); void deleteAttachment(String name, EntityRef parent);  }