/** * Creates a new, rejected promise from the given Throwable and result type. * <p> * Synonym for {@link #rejected(Throwable, Class)} * * @param t The throwable * @return The new promise */ public static <A> Promise<A> toRejectedPromise(Throwable t) { return rejected(t); }
/** * Creates a new, rejected promise from the given {@link Throwable} and result * type. * * @param throwable The throwable * @param resultType The result type * @return The new promise * @deprecated Use {@link #rejected(Throwable)} * @since 2.5.0 */ public static <A> Promise<A> rejected(Throwable throwable, Class<A> resultType) { return rejected(throwable); }
/** * Creates a new, rejected promise from the given Throwable and result type. * <p> * Synonym for {@link #rejected(Throwable, Class)} * * @param t The throwable * @param resultType The result type * @return The new promise * @deprecated Use {@link #toRejectedPromise(Throwable)} * @since 2.5.0 */ public static <A> Promise<A> toRejectedPromise(Throwable t, Class<A> resultType) { return rejected(t); }
private <A> Promise<A> fail() { return Promises.rejected(new UnsupportedOperationException(MESSAGE)); }
private Promise<Unit> moveFile(final File sourceFile, final File destinationFile, boolean isTemporary) { final File parentFile = destinationFile.getParentFile(); if (!ensureDirectoryExists(parentFile)) { return Promises.rejected(new AttachmentMoveException("Unable to create target directory " + parentFile.getAbsolutePath())); } return renameOrCopyAndDeleteFile(sourceFile, destinationFile, isTemporary); }
@Override public final ResponsePromise execute(final Request request) { try { return doExecute(request); } catch (Throwable t) { return ResponsePromises.toResponsePromise(rejected(t, Response.class)); } }
@Override public final ResponsePromise execute(final DefaultRequest request) { try { return doExecute(request); } catch (Throwable t) { return ResponsePromises.toResponsePromise(rejected(t, Response.class)); } }
@Override public Promise<Void> deleteThumbnailDirectory(@Nonnull final Issue issue) { final File thumbnailDirectory = attachmentDirectoryAccessor.getThumbnailDirectory(issue, false); try { FileUtils.deleteDirectory(thumbnailDirectory); return Promises.promise(null); } catch (IOException e) { return Promises.rejected(new AttachmentCleanupException(e)); } }
@Override public Promise<Unit> deleteAttachment(final AttachmentKey attachmentKey) { try { final File attachmentFile = getAttachmentFile(attachmentKey); if (attachmentFile.exists()) { if (!attachmentFile.delete()) { log.warn("Failed to delete attachmentFile: " + attachmentFile.getAbsolutePath()); } eventPublisher.publish(new JiraHomeChangeEvent(JiraHomeChangeEvent.Action.FILE_DELETED, JiraHomeChangeEvent.FileType.ATTACHMENT, attachmentFile)); } else { log.warn("Trying to delete non-existent attachment: [" + attachmentFile.getAbsolutePath() + "] ..ignoring"); } } catch (final DataAccessException e) { Promises.rejected(new AttachmentCleanupException(e)); } return Promises.promise(Unit.VALUE); }
@Override public Promise<Unit> deleteAttachmentContainerForIssue(final Issue issue) { Preconditions.checkNotNull(issue); final File attachmentDir = directoryAccessor.getAttachmentDirectory(issue); try { FileUtils.deleteDirectory(attachmentDir); eventPublisher.publish(new JiraHomeChangeEvent(JiraHomeChangeEvent.Action.FILE_DELETED, JiraHomeChangeEvent.FileType.ATTACHMENT, attachmentDir)); return Promises.promise(Unit.VALUE); } catch (final IOException e) { return Promises.rejected(new AttachmentCleanupException(e)); } }
@Override public Promise<Void> apply(@Nullable final Void input) { List<Attachment> attachments = attachmentManager.getAttachments(issue); try { for (Attachment a : attachments) { attachmentManager.deleteAttachment(a); } } catch (RemoveException e) { return Promises.rejected(new AttachmentCleanupException(e)); } return attachmentStore.deleteAttachmentContainerForIssue(issue); } });
public Promise<Unit> deleteTemporaryAttachment(final TemporaryAttachmentId temporaryAttachmentId) { final String tempId = temporaryAttachmentId.toStringId(); final File temporaryAttachmentFile = new File(temporaryDirectory, tempId); final Option<Exception> exception = pathTraversalChecker.validateFileInSecureDirectory(temporaryAttachmentFile, temporaryDirectory); if(exception.isDefined()) { return Promises.rejected(exception.get()); } if(temporaryAttachmentFile.exists()) { deleteTemporaryFile(temporaryAttachmentFile); } return Promises.promise(Unit.VALUE); }
@Override public Promise<Unit> moveTemporaryToAttachment(final TemporaryAttachmentId temporaryAttachmentId, final AttachmentKey destinationKey) { final Either<Exception, File> tempFileEitherException = localTemporaryFileStore.getTemporaryAttachmentFile(temporaryAttachmentId); if (tempFileEitherException.isLeft()) { return Promises.rejected(tempFileEitherException.left().get()); } final File tempFile = tempFileEitherException.right().get(); final File destinationFile = getAttachmentFileHolder(destinationKey); return moveFile(tempFile, destinationFile, true); }
if (defaultLinkOption.isEmpty()) { logger.debug("The link has been removed since triggering the upgrade - could be due to work in another node of a cluster."); return Promises.rejected(new LinkNotFoundException(), null); } else { HipChatLink hipChatLink = defaultLinkOption.get();