Skip to content

Commit

Permalink
Fixed bug in substituting placeholders.
Browse files Browse the repository at this point in the history
  • Loading branch information
csrster committed Sep 4, 2018
1 parent bc8e9b9 commit 986eed3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,11 @@ public boolean isValid() {
@Override
public void insertUmbrabean(Job aJob, String rabbitMQUrl, String limitSearchRegEx)
{
String tmp = template;
this.template = tmp.replace(UMBRA_BEAN_IN_SIMPLEOVERRIDES_BEAN_PLACEHOLDER,
this.template = this.template.replace(UMBRA_BEAN_IN_SIMPLEOVERRIDES_BEAN_PLACEHOLDER,
getUmbraBeanInformationInSimpleoverridesBean(aJob, rabbitMQUrl, limitSearchRegEx));
this.template = tmp.replace(UMBRA_BEAN_PLACEHOLDER, getUmbrabeanPlaceholder());
this.template = tmp.replace(AMQP_URLRECEIVER_PLACEHOLDER, getAmqpUrlreceiverPlaceholder());
this.template = tmp.replace(CALL_UMBRABEAN_PLACEHOLDER, getCallUmbrabean());
this.template = this.template.replace(UMBRA_BEAN_PLACEHOLDER, getUmbrabeanPlaceholder());
this.template = this.template.replace(AMQP_URLRECEIVER_PLACEHOLDER, getAmqpUrlreceiverPlaceholder());
this.template = this.template.replace(CALL_UMBRABEAN_PLACEHOLDER, getCallUmbrabean());
}

public static final String UMBRA_BEAN_IN_SIMPLEOVERRIDES_BEAN_PLACEHOLDER = "%{UMBRA_BEAN_IN_SIMPLEOVERRIDES_BEAN_PLACEHOLDER}";
Expand Down Expand Up @@ -917,14 +916,18 @@ public void writeTemplate(JspWriter out) throws IOFailure {
public void removePlaceholders() {
template = template.replace(METADATA_ITEMS_PLACEHOLDER, "");
template = template.replace(CRAWLERTRAPS_PLACEHOLDER, "");

template = template.replace(UMBRA_BEAN_IN_SIMPLEOVERRIDES_BEAN_PLACEHOLDER, "")
.replace(UMBRA_BEAN_PLACEHOLDER, "")
.replace(AMQP_URLRECEIVER_PLACEHOLDER, "")
.replace(CALL_UMBRABEAN_PLACEHOLDER, "");

if (template.contains(METADATA_ITEMS_PLACEHOLDER)) {
throw new IllegalState("The placeholder for the property '" + METADATA_ITEMS_PLACEHOLDER
+ "' should have been deleted now.");
}
if (template.contains(CRAWLERTRAPS_PLACEHOLDER)) {
throw new IllegalState("The placeholder for the property '" + CRAWLERTRAPS_PLACEHOLDER
+ "' should have been deleted now.");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public static void makeTemplateReadyForHeritrix3(Heritrix3Files files) throws IO
} else {
log.debug("Template is not dedup-enabled so not setting index location");
}
//TODO here we could actually substitute template placeholders at the HarvestController level
// Remove superfluous placeholders in the template (maybe unnecessary)
template.removePlaceholders();
files.writeOrderXml(template);
Expand Down

0 comments on commit 986eed3

Please sign in to comment.