boolean isAttachmentsEnabledAndPathSet() { return attachmentManager.attachmentsEnabled(); }
private boolean validateAttachmentsEnabled(@Nullable final ApplicationUser user, final ErrorCollection errorCollection) { return processValidationResult(attachmentManager.attachmentsEnabled(), "attachment.service.error.attachments.disabled", user, errorCollection); }
/** * Returns the absolution path for the Default Import Attachments directory ([jira-home/import/attachments]) if * attachments are enabled * * @return the absolute path for the Default Import Attachments directory ([jira-home/import/attachments]) or null * if attachments are not enabled */ public String getDefaultImportAttachmentsPath() { if(attachmentManager.attachmentsEnabled()) { return jiraHome.getImportAttachmentsDirectory().getAbsolutePath(); } else { return null; } }
/** * Returns the meta information for an attachments, specifically if they are enabled and the maximum upload size * allowed. * * @return a JSON representation of the enable attachment capabilities * * @response.representation.200.qname * attachmentMeta * * @response.representation.200.mediaType * application/json * * @response.representation.200.example * {@link com.atlassian.jira.rest.v2.issue.attachment.format.AttachmentMetaBean#DOC_EXAMPLE} * * @response.representation.200.doc * JSON representation of the attachment capabilities. * Consumers of this resource may also need to check if the logged in user has permission to upload or * otherwise manipulate attachments using the {@link com.atlassian.jira.rest.v2.permission.PermissionsResource}. */ @GET @Path ("meta") public Response getAttachmentMeta() { final boolean enabled = attachmentManager.attachmentsEnabled(); final long maxSize = Long.parseLong(Configuration.getString(APKeys.JIRA_ATTACHMENT_SIZE)); final AttachmentMetaBean bean = new AttachmentMetaBean(enabled, maxSize); return Response.ok(bean).cacheControl(never()).build(); }
private void validateAddAttachment(final ApplicationUser author, final Issue issue) throws AttachmentException, PermissionException { if (!attachmentManager.attachmentsEnabled()) { throw new AttachmentException("Attachments are disabled"); } if (hasNoPermissionToCreateAttachments(author, issue)) { throw new PermissionException(String.format("User '%s' has no permission to create attachments in project '%s'", getAuthorNameOrAnonymousIfNull(author), issue.getProjectObject().getKey())); } }
@Override public Promise<Void> deleteAttachmentsForIssue(final Issue issue) if (attachmentManager.attachmentsEnabled())
private void cloneAttachmentsIfNeeded(Issue clone) throws CreateException { /* * Note, that Create Attachment permission is not checked, * the same way Link Issue permission is not checked for cloning links. */ if (isCloneAttachments() && attachmentManager.attachmentsEnabled()) { Map<Long, Either<AttachmentError, Attachment>> result = attachmentManager.copyAttachments(originalIssue, getLoggedInUser(), clone.getKey()); for (final Either<AttachmentError, Attachment> either : result.values()) { if (either.isLeft()) { final AttachmentError error = either.left().get(); log.warn(error.getLogMessage(), error.getException().getOrNull()); } } } }
public boolean isDisplayCopyAttachments() { if (attachmentManager.attachmentsEnabled()) { if (givenIssueHasAnyAttachment(originalIssue)) { // If an issue has attachments then we should allow to clone them return true; } else if (subTaskManager.isSubTasksEnabled()) { // Otherwise need to check if at least one sub-task has an attachment if (originalIssueHasSubTask()) { for (Issue subTask : originalIssue.getSubTaskObjects()) { if (givenIssueHasAnyAttachment(subTask)) { return true; } } } } } return false; }
public boolean isShown(final Issue issue) { final boolean hasCreateAttachmentPermission; if (issue.isCreated()) { // check issue permission hasCreateAttachmentPermission = permissionManager.hasPermission( ProjectPermissions.CREATE_ATTACHMENTS, issue, getAuthenticationContext().getUser()); } else { // issue not saved to the DB yet - check the project permission hasCreateAttachmentPermission = permissionManager.hasPermission( CREATE_ATTACHMENTS, issue.getProjectObject(), getAuthenticationContext().getUser(), true); } return hasCreateAttachmentPermission && attachmentManager.attachmentsEnabled(); }
private Response tryProcessingAttachment(final String id) { if (!attachmentManager.attachmentsEnabled()) { final String message = i18n.getText("attachment.service.error.disabled"); final ErrorCollection errors = errorCollectionFactory.of(NOT_FOUND, message); return responder.restfulErrors(errors); } @Nullable final ApplicationUser user = authContext.getUser(); final JiraServiceContext serviceContext = contextFactory.createContext(user); final long attachmentId = Long.parseLong(id); final Attachment attachment = attachmentService.getAttachment(serviceContext, attachmentId); final com.atlassian.jira.util.ErrorCollection serviceErrors = serviceContext.getErrorCollection(); if (serviceErrors.hasAnyErrors()) { final ErrorCollection errors = errorCollectionFactory.of(serviceErrors); errors.reason(NOT_FOUND); return responder.restfulErrors(errors); } else if (authorizer.authorize(attachment, user)) { return operation.perform(attachment, serviceContext); } else { final String message = authorizer.getNoPermissionMessage(i18n, id); final ErrorCollection errors = errorCollectionFactory.of(FORBIDDEN, message); return responder.restfulErrors(errors); } }
if (!attachmentManager.attachmentsEnabled())
private ConfigurationBean createConfigurationBean(boolean timeTrackingEnabled, Option<TimeTrackingConfigurationBean> timeTrackingConfigurationBean) { return ConfigurationBean.builer() .votingEnabled(voteService.isVotingEnabled()) .watchingEnabled(watcherService.isWatchingEnabled()) .unassignedIssuesAllowed(applicationProperties.getOption(APKeys.JIRA_OPTION_ALLOWUNASSIGNED)) .subTasksEnabled(subTaskManager.isSubTasksEnabled()) .attachmentsEnabled(attachmentManager.attachmentsEnabled()) .issueLinkingEnabled(issueLinkManager.isLinkingEnabled()) .timeTrackingEnabled(timeTrackingEnabled) .timeTrackingConfiguration(timeTrackingConfigurationBean.getOrNull()) .build(); }