Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit b2a88da

Browse files
authored
Merge pull request #63 from nickfyson/clarify_error_messages
Change manual migration message to indicate use of workflow schemes page
2 parents 67903cf + 08f272c commit b2a88da

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

src/main/java/com/semmle/jira/addon/LgtmServlet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void createIssue(
160160
sendError(
161161
resp,
162162
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
163-
"Retrieval of custom field for config key failed.");
163+
"Retrieval of configuration key failed. Please check your add-on configuration.");
164164
return;
165165
}
166166

src/main/java/com/semmle/jira/addon/util/JiraUtils.java

+20-3
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,36 @@ private static PluginSettings getSettingsObject() {
217217

218218
public static CustomField getConfigKeyCustomField() throws CustomFieldRetrievalException {
219219

220+
Object settingsObject = getSettingsObject().get(Constants.CUSTOM_FIELD_CONFIG_KEY);
221+
222+
if (settingsObject == null) {
223+
throw new CustomFieldRetrievalException(
224+
"Null value found for plugin setting "
225+
+ Constants.CUSTOM_FIELD_CONFIG_KEY
226+
+ ". Indicates that the add-on has not yet been (re)configured.");
227+
}
228+
220229
long fieldId;
221230
try {
222-
fieldId = Long.parseLong((String) getSettingsObject().get(Constants.CUSTOM_FIELD_CONFIG_KEY));
231+
fieldId = Long.parseLong((String) settingsObject);
223232
} catch (ClassCastException | NumberFormatException e) {
224-
throw new CustomFieldRetrievalException("Invalid custom field config key.", e);
233+
throw new CustomFieldRetrievalException(
234+
"Invalid value for plugin setting "
235+
+ Constants.CUSTOM_FIELD_CONFIG_KEY
236+
+ " -> "
237+
+ settingsObject.toString()
238+
+ ". Should be long, corresponding to ID of LGTM custom field.",
239+
e);
225240
}
226241

227242
CustomField customField =
228243
ComponentAccessor.getCustomFieldManager().getCustomFieldObject(fieldId);
229244

230245
if (customField == null) {
231246
throw new CustomFieldRetrievalException(
232-
"Custom field not found with specified id = " + String.valueOf(fieldId));
247+
"LGTM Custom Field not found for stored id ("
248+
+ String.valueOf(fieldId)
249+
+ "). Field has likely been unlocked and then deleted.");
233250
}
234251

235252
return customField;

src/main/java/com/semmle/jira/addon/workflow/LgtmTransitionNotificationFunction.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public void execute(Map transientVars, Map args, PropertySet ps) throws Workflow
4242
try {
4343
customField = JiraUtils.getConfigKeyCustomField();
4444
} catch (CustomFieldRetrievalException e) {
45-
String message = "Retrieval of custom field for config key failed.";
45+
String message =
46+
"Retrieval of configuration key failed. Please check your add-on configuration and try again.";
4647
log.error(message, e);
4748
throw new WorkflowException(message, e);
4849
}

src/main/resources/js/lgtm-addon.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,12 @@ function updateConfig() {
195195

196196
var body = '<p>There are existing tickets using an old workflow type, and hence a one-time manual migration is needed.</p>' +
197197
'<ul>'+
198-
'<li>Please go to the <a href="' + AJS.params.baseURL + '/plugins/servlet/project-config/'+
199-
AJS.$('#project').select2('val') +
200-
'/workflows" target="_blank">project workflow page</a> '+
201-
"and select 'Add workflow' followed by 'Add existing'.</li>" +
198+
'<li>Please go to the <a href="' + AJS.params.baseURL + '/secure/admin/ViewWorkflowSchemes.jspa" target="_blank">workflow schemes page</a> '+
199+
"and click to edit the scheme associated with your project chosen above.</li>" +
200+
"<li>Select 'Add workflow' followed by 'Add existing'.</li>" +
202201
"<li>On the first screen select 'LGTM workflow' then on the second select 'LGTM alert'. Click 'Finish'.</li>" +
203202
"<li>Finally, click 'Publish' and Jira will guide you through mapping tickets to the new workflow.</li>" +
204-
'</ul>';
203+
"</ul>";
205204

206205
AJS.messages.error("#message-context", {
207206
title : 'A manual workflow migration is needed.',

0 commit comments

Comments
 (0)