Skip to content
Permalink
Browse files
Fix JENKINS-14607
  • Loading branch information
gboissinot committed Jul 27, 2012
1 parent 7f022c4 commit 7d1194c5cde7d5419d608c1fbf80b01abfafddd2
@@ -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();
@@ -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);
}
}
}
}

@@ -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;
}
}
}

0 comments on commit 7d1194c

Please sign in to comment.