/** * Return the Service Desk license stored in the UPM plugin store. * * @return the old Service Desk license from the UPM plugin store or {@link Option#none()}. */ private Option<License> retrieveOldSdLicense() { return sdSupplier.get() .map(License::new) .filter(license -> license.isLicensed(ApplicationKeys.SERVICE_DESK)); }
private Option<License> get6xSdLicenseFromOldStoreSafely() { try { return licenseDao.get6xLicense().filter(LicenseUtils::isServiceDeskLicense); } catch (MigrationFailedException e) { //We do not care if license is broken in old store here, as there might be valid one in multistore return Option.none(); } }
@Override public <A extends Application> Option<A> getApplication(final ApplicationKey key, final Class<A> type) { return getApplication(key).filter(type::isInstance).map(type::cast); }
@Override public Option<String> doInTransaction() { return hipChatAOUserManager.getByUserKey(userKey).filter(new Predicate<AOHipChatUser>() { @Override public boolean apply(AOHipChatUser input) { return !isExpired(input.getUserTokenExpiry()); } }).map(new Function<AOHipChatUser, String>() { @Override public String apply(AOHipChatUser input) { return input.getUserToken(); } }); } });
@Override public Option<String> doInTransaction() { return hipChatAOLinkManager.getLinkById(hipChatLinkId).filter(new Predicate<AOHipChatLink>() { @Override public boolean apply(AOHipChatLink input) { return !isExpired(input.getAddonTokenExpiry()); } }).map(new Function<AOHipChatLink, String>() { @Override public String apply(AOHipChatLink input) { return input.getToken(); } }); } });
@Override public Option<String> doInTransaction() { return hipChatAOLinkManager.getLinkById(hipChatLinkId).filter(new Predicate<AOHipChatLink>() { @Override public boolean apply(AOHipChatLink input) { return !isExpired(input.getSystemTokenExpiry()); } }).map(new Function<AOHipChatLink, String>() { @Override public String apply(AOHipChatLink input) { return input.getSystemUserToken(); } }); } });
/** * @see com.atlassian.jira.upgrade.tasks.role.Move6xServiceDeskLicenseTo70Store */ @Override public Option<LicenseDetails> get() { try { return encodedLicenseSupplier.get() .map(licenseDetailsFactory::getLicense) .filter(Jira6xServiceDeskPluginLicenseSupplier::isServiceDeskLicense); } catch (LicenseException invalidLicense) { LOG.debug("Invalid Service Desk plugin license", invalidLicense); return Option.none(); } }
@Override MigrationState migrate(final MigrationState state, final boolean licenseSuppliedByUser) { if (licenseSuppliedByUser) { return state.log(new AuditEntry(Move6xServiceDeskLicenseTo70Store.class, "Not moving old Service Desk license - license supplied by user", "The person importing JIRA has supplied a license to use; any existing Service Desk license" + "installed in your system will be ignored in preference of the new license.", AssociatedItem.Type.LICENSE, null, EVENT_SHOWS_IN_CLOUD_LOG)); } else { return sdEncodedLicenseSupplier.get() .map(License::new) .filter(this::isValid6xServiceDeskLicense) .map(sdLicense -> addLicenseIfNotPresent(sdLicense, state)) .getOrElse(state); } }