private IssueLinkType getIssueLinkTypeByName(final String linkTypeName) { final Collection linkTypes = issueLinkTypeManager.getIssueLinkTypesByName(linkTypeName); if (linkTypes.isEmpty()) { return null; } // Return the first one - there should never be more than one. return (IssueLinkType) linkTypes.iterator().next(); } }
private IssueLinkType getIssueLinkTypeByName(final String linkTypeName) { final Collection linkTypes = issueLinkTypeManager.getIssueLinkTypesByName(linkTypeName); if (linkTypes.isEmpty()) { return null; } // Return the first one - there should never be more than one. return (IssueLinkType) linkTypes.iterator().next(); }
/** * Returns the issue link type specified by the clone link name in the properties file or null for none. * * @return the issue link type specified by the clone link name in the properties file or null for none. */ IssueLinkType getCloneIssueLinkType() { String cloneIssueLinkTypeName = getCloneIssueLinkTypeName(); if (cloneIssueLinkTypeName == null) return null; final Collection<IssueLinkType> cloneIssueLinkTypes = issueLinkTypeManager.getIssueLinkTypesByName(cloneIssueLinkTypeName); if (cloneIssueLinkTypes.isEmpty()) { return null; } else { return cloneIssueLinkTypes.iterator().next(); } }
/** * Check if IssueLinkType name already exists - if so, get id from this IssueTypeLink name to ensure that selected * IssueLinkType name is being edited. This addresses the situation where an IssueLinkType is renamed to conflict * with a pre-existing IssueLinkType. */ private boolean duplicateLinkName() { // Obtain all existing IssueLinkTypes Collection<IssueLinkType> existingIssueLinkTypes = issueLinkTypeManager.getIssueLinkTypesByName(getName()); if (existingIssueLinkTypes != null) { for (final IssueLinkType issueLinkType : existingIssueLinkTypes) { if (!id.equals(issueLinkType.getId())) { return true; } } } return false; }
public IssueLinkType getCloneIssueLinkType() { if (cloneIssueLinkType == null) { final Collection<IssueLinkType> cloneIssueLinkTypes = issueLinkTypeManager.getIssueLinkTypesByName(getCloneLinkTypeName()); if (StringUtils.isBlank(getCloneLinkTypeName())) { // Issue linking is not required cloneIssueLinkType = null; } else if (CollectionUtils.isEmpty(cloneIssueLinkTypes)) { log.warn("The clone link type '" + getCloneLinkTypeName() + "' does not exist. A link to the original issue will not be created."); cloneIssueLinkType = null; } else { for (final IssueLinkType issueLinkType : cloneIssueLinkTypes) { if (issueLinkType.getName().equals(getCloneLinkTypeName())) { cloneIssueLinkType = issueLinkType; } } } } return cloneIssueLinkType; }
@Override public ServiceOutcome<IssueLinkType> createIssueLinkType(ApplicationUser user, String name, String outward, String inward) { final I18nHelper i18n = i18nFactory.getInstance(user); if (!applicationProperties.getOption(APKeys.JIRA_OPTION_ISSUELINKING)) { return ServiceOutcomeImpl.error(i18n.getText("admin.issuelinking.status", i18n.getText("admin.common.words.disabled")), ErrorCollection.Reason.NOT_FOUND); } if (!permissionManager.hasPermission(Permissions.ADMINISTER, user)) { return ServiceOutcomeImpl.error(i18n.getText("admin.errors.linking.error.create.no.permission"), ErrorCollection.Reason.FORBIDDEN); } if (!issueLinkTypeManager.getIssueLinkTypesByName(name).isEmpty()) { return ServiceOutcomeImpl.error(i18n.getText("admin.errors.linking.error.create.duplicate")); } // User created link types always have a "style" of null. I don't know what "style" means. issueLinkTypeManager.createIssueLinkType(name, outward, inward, null); Collection<IssueLinkType> issueLinkTypesByName = issueLinkTypeManager.getIssueLinkTypesByName(name); if (issueLinkTypesByName.size() != 1) { return ServiceOutcomeImpl.error(i18n.getText("admin.errors.linking.error.create.failed.mysteriously"), ErrorCollection.Reason.SERVER_ERROR); } else { return ServiceOutcomeImpl.ok(issueLinkTypesByName.iterator().next()); } }
@Override public ServiceOutcome<IssueLinkType> updateIssueLinkType(ApplicationUser user, IssueLinkType linkType, String name, String outward, String inward) { final I18nHelper i18n = i18nFactory.getInstance(user); if (!applicationProperties.getOption(APKeys.JIRA_OPTION_ISSUELINKING)) { return ServiceOutcomeImpl.error(i18n.getText("admin.issuelinking.status", i18n.getText("admin.common.words.disabled")), ErrorCollection.Reason.NOT_FOUND); } if (!permissionManager.hasPermission(Permissions.ADMINISTER, user)) { return ServiceOutcomeImpl.error(i18n.getText("admin.errors.linking.error.update.no.permission"), ErrorCollection.Reason.FORBIDDEN); } // Trying to give this link type the same name as an existing link type is not allowed. if (!Objects.equal(name, linkType.getName()) && !issueLinkTypeManager.getIssueLinkTypesByName(name).isEmpty()) { return ServiceOutcomeImpl.error(i18n.getText("admin.errors.linking.error.create.duplicate")); } issueLinkTypeManager.updateIssueLinkType(linkType, StringUtils.isEmpty(name) ? linkType.getName() : name, StringUtils.isEmpty(outward) ? linkType.getOutward() : outward, StringUtils.isEmpty(inward) ? linkType.getInward() : inward); return ServiceOutcomeImpl.ok(linkType); } }
Collection<IssueLinkType> linkTypes = issueLinkTypeManager.getIssueLinkTypesByName(linkTypeBean.name()); if (linkTypes == null || linkTypes.isEmpty())
protected void doValidation() { //only do validation if one field is specified if (name != null || outward != null || inward != null) { if (!TextUtils.stringSet(name)) { addError("name", getText("admin.errors.you.must.specify.a.name.for.this.link.type")); } if (!TextUtils.stringSet(outward)) { addError("outward", getText("admin.errors.please.specify.a.description.for.the.outward.link")); } if (!TextUtils.stringSet(inward)) { addError("inward", getText("admin.errors.please.specify.a.description.for.the.inward.link")); } // also check that no link with that name already exists Collection<IssueLinkType> existing = issueLinkTypeManager.getIssueLinkTypesByName(name); if (existing != null && existing.size() > 0) { addError("name", getText("admin.errors.another.link.type.with.that.name.already.exists")); } } }