/** * 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); }
/** * @see AbstractViewFileServlet#getInputStream(String, com.atlassian.jira.util.io.InputStreamConsumer) */ protected void getInputStream(String attachmentQuery, InputStreamConsumer<Unit> consumer) throws PermissionException, IOException { Attachment attachment = getAttachment(attachmentQuery); if (!hasPermissionToViewAttachment(getUserName(), attachment)) { throw new PermissionException("You do not have permissions to view this issue"); } ComponentAccessor.getAttachmentManager().streamAttachmentContent(attachment, consumer); }
private synchronized MessageHandlerContext getContext() { if (context == null) { context = new DefaultMessageHandlerContext(ComponentAccessor.getCommentManager(), new Log4jMessageHandlerExecutionMonitor(), ComponentAccessor.getIssueManager(), ComponentAccessor.getAttachmentManager(), ComponentAccessor.getComponent(TextFieldCharacterLengthValidator.class), ComponentAccessor.getPermissionManager(), ComponentAccessor.getApplicationProperties(), ComponentAccessor.getComponent(ApplicationRoleManager.class), ComponentAccessor.getComponent(UserService.class)); } return context; }
/** * This is a static way of instantiating an Issue Object. * * @param genericValue generic value of the issue * @return new instance of MutableIssue * @deprecated You should construct this yourself if at all possible, * or use {@link IssueFactory#getIssue(org.ofbiz.core.entity.GenericValue)} instead. */ public static MutableIssue getIssueObject(GenericValue genericValue) { return new IssueImpl(genericValue, ComponentAccessor.getIssueManager(), ComponentAccessor.getProjectManager(), ComponentAccessor.getVersionManager(), ComponentAccessor.getIssueSecurityLevelManager(), ComponentAccessor.getConstantsManager(), ComponentAccessor.getSubTaskManager(), ComponentAccessor.getAttachmentManager(), ComponentAccessor.getComponentOfType(LabelManager.class), ComponentAccessor.getComponentOfType(ProjectComponentManager.class), ComponentAccessor.getComponentOfType(UserManager.class), ComponentAccessor.getComponentOfType(JiraAuthenticationContext.class)); }