Skip to content

Commit

Permalink
Fix JENKINS-14607
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed Jul 27, 2012
1 parent 7f022c4 commit 7d1194c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
15 changes: 13 additions & 2 deletions src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java
Expand Up @@ -372,14 +372,25 @@ private URLTriggerEntry fillAndGetEntry(StaplerRequest req, JSONObject entryObje
} catch (JSONException jsone) {
contentTypesJsonElt = inspectingContentJSONObject.getJSONObject("contentTypes");
}
List<URLTriggerContentType> types = req.bindJSONToList(URLTriggerContentType.class, contentTypesJsonElt);
urlTriggerEntry.setContentTypes(types.toArray(new URLTriggerContentType[types.size()]));
if (contentTypesJsonElt != null && !isEmptyJSONElement(contentTypesJsonElt)) {
List<URLTriggerContentType> types = req.bindJSONToList(URLTriggerContentType.class, contentTypesJsonElt);
urlTriggerEntry.setContentTypes(types.toArray(new URLTriggerContentType[types.size()]));
} else {
urlTriggerEntry.setInspectingContent(false);
}

}

return urlTriggerEntry;
}

private boolean isEmptyJSONElement(JSON element) {
if (element instanceof JSONObject) {
return ((JSONObject) element).getString("kind").isEmpty();
}
return false;
}

@Override
public String getDisplayName() {
return Messages.urltrigger_displayName();
Expand Down
Expand Up @@ -107,8 +107,13 @@ private void refreshLatModificationDate(URLTriggerEntry entry, Date lastModifica
}

private void refreshContent(URLTriggerEntry entry, String content, XTriggerLog log) throws XTriggerException {
for (final URLTriggerContentType type : entry.getContentTypes()) {
type.initForContent(content, log);
URLTriggerContentType[] contentTypes = entry.getContentTypes();
if (contentTypes != null) {
for (final URLTriggerContentType type : contentTypes) {
if (type != null) {
type.initForContent(content, log);
}
}
}
}

Expand Down Expand Up @@ -153,11 +158,19 @@ private boolean checkContent(URLTriggerEntry entry, XTriggerLog log, String cont
return false;
}

URLTriggerContentType[] contentTypes = entry.getContentTypes();
if (contentTypes == null) {
log.info("You have to add at least one content nature type to check.");
return false;
}

log.info("Inspecting the content");
for (final URLTriggerContentType type : entry.getContentTypes()) {
boolean isTriggering = type.isTriggering(content, log);
if (isTriggering) {
return true;
for (final URLTriggerContentType type : contentTypes) {
if (type != null) {
boolean isTriggering = type.isTriggering(content, log);
if (isTriggering) {
return true;
}
}
}

Expand Down

0 comments on commit 7d1194c

Please sign in to comment.