com.atlassian.jira.issue.attachment.Attachment.getFilename()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中com.atlassian.jira.issue.attachment.Attachment.getFilename()方法的一些代码示例,展示了Attachment.getFilename()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attachment.getFilename()方法的具体详情如下:
包路径:com.atlassian.jira.issue.attachment.Attachment
类名称:Attachment
方法名:getFilename

Attachment.getFilename介绍

暂无

代码示例

代码示例来源:origin: com.atlassian.jira/jira-core

public int compare(final Attachment a1, final Attachment a2)
  {
    final String filename1 = a1.getFilename();
    final String filename2 = a2.getFilename();

    if ((filename1 == null) && (filename2 == null))
    {
      return 0;
    }

    if (filename1 == null)
    {
      return -1; // non null values are greater than null values
    }

    if (filename2 == null)
    {
      return 1; // non null values are greater than null values
    }

    return collator.compare(filename1, filename2);
  }
}

代码示例来源:origin: com.atlassian.jira/jira-core

private void groupAttachmentsByFileName()
{
  for (final Attachment attachment : attachments)
  {
    TreeSet<Attachment> namedAttachments = fileNameGroupingMap.get(attachment.getFilename());
    if (namedAttachments == null)
    {
      namedAttachments = new TreeSet<Attachment>(new AttachmentCreationDateComparator());
      fileNameGroupingMap.put(attachment.getFilename(), namedAttachments);
    }
    namedAttachments.add(attachment);
  }
}

代码示例来源:origin: com.atlassian.jira/jira-core

private Attachment getAttachment(Issue issue, String attachementName) throws GenericEntityException
{
  Attachment attachment = null;
  Collection<Attachment> attachments = issue.getAttachments();
  for (final Attachment tempAttachement : attachments)
  {
    if (tempAttachement.getFilename().equals(attachementName))
    {
      // Since the list is sorted by filename and date we know the first is the most recent
      attachment = tempAttachement;
      break;
    }
  }
  return attachment;
}

代码示例来源:origin: com.atlassian.streams/streams-jira-plugin

public URI getAttachmentUri(URI baseUri, Attachment attachment)
{
  return URI.create(baseUri.toASCIIString() + "/secure/attachment/" +
    attachment.getId() + "/" + Uris.encode(attachment.getFilename()));
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
  public ChangeItemBean apply(final Attachment attachment)
  {
    return new ChangeItemBean(
        ChangeItemBean.STATIC_FIELD, "Attachment", null, null,
        attachment.getId().toString(), attachment.getFilename()
    );
  }
};

代码示例来源:origin: com.atlassian.jira/jira-core

/**
   * Determines whether the specified attachment is the latest file uploaded amongst the group of files
   * with the same name in the underlying list.
   * @param attachment The attachment in play. Should not be null.
   * @return true if this is the latest (or only) file with this name; otherwise false.
   */
  public boolean isLatestVersion(Attachment attachment)
  {
    notNull("attachment" , attachment);

    final TreeSet<Attachment> namedAttachments = fileNameGroupingMap.get(attachment.getFilename());

    if (namedAttachments != null)
    {
      return (namedAttachments.size() == 1) || (namedAttachments.last().equals(attachment));
    }
    return false;
  }
}

代码示例来源:origin: com.atlassian.jira/jira-api

static AttachmentAdapter fromAttachment(final Attachment attachment)
  {
    return new AttachmentAdapter(attachment.getId(), attachment.getFilename());
  }
}

代码示例来源:origin: com.atlassian.jira/jira-core

private <T> Either<AttachmentError, T> copyAttachmentError(
      final Attachment attachment, @Nullable final ApplicationUser author,
      final String newIssueKey, final Throwable throwable)
  {
    return attachmentError(
        String.format("Unable to copy attachment to issue with key %s.", newIssueKey),
        getI18n(author).getText("attachment.error.copy.generic", newIssueKey),
        attachment.getFilename(),
        throwable,
        SERVER_ERROR);
  }
}

代码示例来源:origin: com.atlassian.streams/streams-jira-plugin

public AttachmentItem apply(Attachment attachment)
  {
    return new AttachmentItem(uriProvider.getAttachmentUri(baseUri, attachment), attachment.getFilename());
  }
};

代码示例来源:origin: com.atlassian.jira/jira-attachment-dmz

public static AttachmentAdapterImpl fromAttachment(final Attachment attachment)
  {
    return new AttachmentAdapterImpl(attachment.getId(), attachment.getFilename());
  }
}

代码示例来源:origin: com.atlassian.jira/jira-attachment-dmz

public static AttachmentKey from(final String originalProjectKey, final String issueKey, final Attachment attachment)
{
  return from(originalProjectKey, issueKey, attachment.getFilename(), attachment.getId());
}

代码示例来源:origin: com.atlassian.cpji/cpji-jira-plugin

@Override
  protected void modifyRequest(ApplicationLinkRequest request) {
    RequestFilePart requestFilePart = new RequestFilePart(attachment.getMimetype(), attachment.getFilename(), attachmentFile, "file");
    request.setFiles(ImmutableList.of(requestFilePart));
    request.addHeader("X-Atlassian-Token", "nocheck");
  }
});

代码示例来源:origin: com.atlassian.jira/jira-core

private String buildAttachmentUrl(RenderContext context, Attachment attachment)
  {
    String encodedAttachmentId;
    String encodedFilename;
    try
    {
      encodedAttachmentId = URLCodec.encode(attachment.getId().toString(), context.getCharacterEncoding());
      encodedFilename = URLCodec.encode(attachment.getFilename(), context.getCharacterEncoding());
    }
    catch (UnsupportedEncodingException uee)
    {
      encodedAttachmentId = attachment.getId().toString();
      encodedFilename = attachment.getFilename();
    }
    return context.getSiteRoot() + "/secure/attachment/" + encodedAttachmentId + "/" + encodedAttachmentId + "_" + encodedFilename;
  }
}

代码示例来源:origin: com.atlassian.jira/jira-core

private String buildAttachmentUrl(RenderContext context, Attachment attachment) throws UnsupportedEncodingException
{
  String encodedAttachmentId = URLCodec.encode(attachment.getId().toString(), context.getCharacterEncoding());
  return context.getSiteRoot() + "/secure/attachment/" + encodedAttachmentId + "/" + encodedAttachmentId + "_" +
      URLCodec.encode(attachment.getFilename(), context.getCharacterEncoding());
}

代码示例来源:origin: com.atlassian.jira/jira-core

private RendererAttachment convertToRendererAttachment(Attachment attachment, RenderContext context, EmbeddedResource resource)
{
  return new RendererAttachment(attachment.getId().longValue(), attachment.getFilename(), attachment.getMimetype(),
      attachment.getAuthorKey(), null, buildAttachmentUrl(context, attachment), null, null, attachment.getCreated());
}

代码示例来源:origin: com.atlassian.jira.plugins/atlassian-jira-rpc-plugin

public RemoteAttachment(Attachment attachment)
{
  super(attachment.getId().toString());
  author = getUsernameFor(attachment.getAuthorObject());
  created = attachment.getCreated();
  filename = attachment.getFilename();
  filesize = attachment.getFilesize();
  mimetype = attachment.getMimetype();
}

代码示例来源:origin: com.atlassian.jira/jira-rest-plugin

@Override
public HumanReadableArchive format(final AttachmentArchive archive, final Attachment attachment)
{
  final Long id = attachment.getId();
  final List<AttachmentArchiveEntry> entries = archive.getEntries();
  final Collection<HumanReadableArchiveEntry> convertedEntries = convertEntries(entries);
  final String name = attachment.getFilename();
  final int totalEntryCount = archive.getTotalEntryCount();
  final String mediaType = attachment.getMimetype();
  return new HumanReadableArchive(id, name, convertedEntries, totalEntryCount, mediaType);
}

代码示例来源:origin: com.atlassian.jira/jira-core

IssueUpdateBean constructIssueUpdateBeanForAttachmentDelete(Attachment attachment, Issue issue, ApplicationUser user)
{
  //generate change history for issue to show that attachment has been deleted
  ChangeItemBean changeItem = new ChangeItemBean(ChangeItemBean.STATIC_FIELD, "Attachment", attachment.getId().toString(), attachment.getFilename(), null, null);
  List<ChangeItemBean> changeItemBeans = EasyList.build(changeItem);
  //configure issue update event
  IssueUpdateBean issueUpdateBean = new IssueUpdateBean(issue.getGenericValue(), issue.getGenericValue(), EventType.ISSUE_UPDATED_ID, user);
  issueUpdateBean.setChangeItems(changeItemBeans);
  issueUpdateBean.setDispatchEvent(true);
  issueUpdateBean.setParams(MapBuilder.build("eventsource", IssueEventSource.ACTION));
  return issueUpdateBean;
}

代码示例来源:origin: com.atlassian.streams/streams-jira-plugin

@Override
  public ActivityObject apply(Attachment attachment) {
    final StreamsUriBuilder idBuilder = new StreamsUriBuilder().setUrl(issueUriBuilder.getIssueUri(baseUri, attachment.getIssueObject()).toASCIIString()).setTimestamp(attachment.getCreated());
    return new ActivityObject(ActivityObject.params().
        id(idBuilder.getUri().toASCIIString()).
        activityObjectType(file()).
        title(some(attachment.getFilename())).
        alternateLinkUri(issueUriBuilder.getAttachmentUri(baseUri, attachment)));
  }
};

代码示例来源:origin: com.atlassian.jira/jira-core

private StoreAttachmentBean mapAttachmentToStoreBean(final Attachment metadata, final StoreAttachmentBean.Builder builder)
{
  return builder
      .withId(metadata.getId())
      .withFileName(metadata.getFilename())
      .withSize(metadata.getFilesize())
      .withIssueKey(metadata.getIssue().getKey())
      .withOriginalProjectKey(metadata.getIssue().getProjectObject().getOriginalKey())
      .build();
}

相关文章