public boolean isAttachmentValid(String fileId) { try { return (fileId != null && attachmentManager.getAttachment(new Long(fileId)) != null); } catch (Exception e) { return false; } }
/** * Looks up the attachment by reading the id from the query string. * * @param query eg. '/10000/foo.txt' * @return attachment found * @throws AttachmentNotFoundException if no attachment is found after parsing the query string * or if the resulting attachment id does not exist. * @throws DataAccessException if there is a problem accessing the database. */ protected Attachment getAttachment(String query) { int x = query.indexOf('/', 1); final String idStr = query.substring(1, x); Long id; try { id = new Long(idStr); } catch (NumberFormatException e) { throw new AttachmentNotFoundException(idStr); } if (query.indexOf('/', x+1) != -1) { // JRA-14580. only one slash is allowed to prevent infinite recursion by web crawlers. throw new AttachmentNotFoundException(idStr); } return ComponentAccessor.getAttachmentManager().getAttachment(id); }
final Attachment attachment = attachmentManager.getAttachment(attachmentId);
public boolean apply(GenericValue item) { if (ATTACHMENT.equalsIgnoreCase(item.getString("field"))) { try { return attachmentManager.getAttachment(createLong(item.getString("newvalue"))) != null; } catch (final Exception e) { return false; } } return true; } };
public Option<Attachment> apply(Long id) { try { return option(attachmentManager.getAttachment(id)); } catch (DataAccessException e) { log.error("Error retrieving attachments", e); return none(); } catch (AttachmentNotFoundException e) { return none(); } } };
Attachment getAndVerifyAttachment(Long attachmentId, ErrorCollection errorCollection) { if (attachmentId == null) { errorCollection.addErrorMessage(getText("attachment.service.error.null.attachment.id")); return null; } Attachment attachment = attachmentManager.getAttachment(attachmentId); if (attachment == null) { errorCollection.addErrorMessage(getText("attachment.service.error.null.attachment", attachmentId.toString())); } return attachment; }
return attachmentManager.getAttachment(genericValue.getLong("id"));
public RendererAttachment getThumbnail(RendererAttachment attachment, RenderContext context, EmbeddedImage image) { if (attachment != null && image.isThumbNail()) { try { Attachment jiraAttachment = attachmentManager.getAttachment(new Long(attachment.getId())); if (thumbnailManager.isThumbnailable(jiraAttachment)) { try { ThumbnailedImage thumbnail = thumbnailManager.toThumbnailedImage(thumbnailManager.getThumbnail(jiraAttachment)); if (thumbnail != null) { return convertToRendererAttachment(thumbnail, jiraAttachment, context, image); } } catch (Exception e) { log.warn("Error looking up thumbnails in RendererAttachmentManager.", e); } } } catch (GenericEntityException e) { log.warn("Error resolving attachment with id: " + attachment.getId(), e); } } return null; }
if (idStringValue != null) Attachment attachment = attachmentManager.getAttachment(Long.valueOf(idStringValue)); if (attachment != null)
if (idStringValue != null) Attachment attachment = attachmentManager.getAttachment(Long.valueOf(idStringValue)); if (attachment != null)