Skip to content

Commit

Permalink
Merge branch 'master' into 2.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
as0050629 committed Feb 8, 2024
2 parents a3f5273 + 211fdcc commit d42b2e3
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,20 @@ function execute(nhRequest,sRequestInfo,sSelfInfo) {
if (selfInfo && selfInfo.elastic && selfInfo.elastic.searchUrl) {
// self target for a Geoportal instance
var targets = config.getTargets();
var baseUrl="";
if(requestInfo.baseUrl)
{
baseUrl = requestInfo.baseUrl;
}
//dcat scheduler request
else if(requestInfo.parameterMap && requestInfo.parameterMap.baseUrl)
{
baseUrl = requestInfo.parameterMap.baseUrl;
}

targets.self = gs.Object.create(gs.target.elastic.GeoportalTarget).mixin({
"searchUrl": selfInfo.elastic.searchUrl,
"itemBaseUrl": requestInfo.baseUrl+"/rest/metadata/item"
"itemBaseUrl": baseUrl+"/rest/metadata/item"
});
if (accessQuery) {
targets.self.accessQuery = accessQuery;
Expand Down
22 changes: 19 additions & 3 deletions geoportal/src/main/java/com/esri/geoportal/dcat/DcatBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public class DcatBuilder {
/** The script engines. */
private static final Map<String,ScriptEngine> ENGINES = Collections.synchronizedMap(new HashMap<String,ScriptEngine>());

private String baseUrl = "http://localhost:8080/geoportal";
public String getBaseUrl() {
return baseUrl;
}

public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}


/** JSON processing. */
private static final ObjectMapper MAPPER = new ObjectMapper();
static {
Expand All @@ -79,14 +89,16 @@ public DcatBuilder(DcatCache dcatCache) {
public void build(DcatContext dcatContext) {
try {
LOGGER.info(String.format("Starting building aggregated DCAT file..."));
execute(dcatContext, getSelfInfo(), getCachedEngine(javascriptFile));
execute(dcatContext, getSelfInfo(), getCachedEngine(javascriptFile),getBaseUrl());
} catch(Exception ex) {
LOGGER.error(String.format("Error building aggregated DCAT file!"), ex);
}
}

private void execute(DcatContext dcatContext, String selfInfo, ScriptEngine engine) {
DcatRequestImpl request = new DcatRequestImpl(dcatContext, selfInfo, engine);


private void execute(DcatContext dcatContext, String selfInfo, ScriptEngine engine, String baseUrl) {
DcatRequestImpl request = new DcatRequestImpl(dcatContext, selfInfo, engine,baseUrl );
synchronized (request) {
request.execute();
try {
Expand Down Expand Up @@ -180,6 +192,10 @@ private class DcatRequestImpl extends DcatRequest {
public DcatRequestImpl(DcatContext dcatContext, String selfInfo, ScriptEngine engine) {
super(dcatContext, selfInfo, engine);
}

public DcatRequestImpl(DcatContext dcatContext, String selfInfo, ScriptEngine engine, String requestInfo) {
super(dcatContext, selfInfo, engine,requestInfo);
}

@Override
public void onRec(DcatHeader header, String rec) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public abstract class DcatRequest {
private final String selfInfo;
private final ScriptEngine engine;
private long dataCounter;
private String baseUrl;

/**
* Creates instance of the request.
Expand All @@ -63,6 +64,13 @@ public DcatRequest(DcatContext dcatContext, String selfInfo, ScriptEngine engine
this.engine = engine;
}

public DcatRequest(DcatContext dcatContext, String selfInfo, ScriptEngine engine,String baseUrl) {
this.dcatContext = dcatContext;
this.selfInfo = selfInfo;
this.engine = engine;
this.baseUrl = baseUrl;
}

/**
* Puts response.
* @param status status
Expand Down Expand Up @@ -116,6 +124,7 @@ private void search(String searchAfter) {
requestInfo.set("parameterMap", parameterMap);
parameterMap.put("f", "dcat");
parameterMap.put("size", Integer.toString(PAGE_SIZE));
parameterMap.put("baseUrl",this.baseUrl);

ArrayNode sortNode = MAPPER.createArrayNode();
sortNode.add("_id:asc");
Expand Down
3 changes: 2 additions & 1 deletion geoportal/src/main/resources/config/app-dcat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@

<beans:bean id="dcatBuilder" class="com.esri.geoportal.dcat.DcatBuilder">
<beans:constructor-arg ref="dcatCache"/>
<beans:property name="baseUrl" value="http://localhost:8080/geoportal" />
</beans:bean>

<beans:bean class="com.esri.geoportal.dcat.DcatController" init-method="init" destroy-method="destroy" >
<!-- DCAT building start time (24 hour clock) or empty to disable auto-generation -->
<beans:constructor-arg value="15:50"/>
<beans:constructor-arg ref="dcatCache"/>
<beans:constructor-arg ref="dcatBuilder"/>
<beans:constructor-arg ref="dcatBuilder"/>
</beans:bean>

</beans:beans>
11 changes: 8 additions & 3 deletions geoportal/src/main/resources/metadata/js/EvaluatorBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ var G = {
v = node.getNodeValue();
}
if (typeof v === "string") {
return v;
return this._strip(v);
}
}
return null;
Expand Down Expand Up @@ -414,7 +414,12 @@ var G = {

inReader.close();
return response.toString();
}

},

// strip HTML markup from string
_strip: function(html) {
//var doc = new DOMParser().parseFromString(html, 'text/html');
// return doc.body.textContent || "Metadata Information";
return html.replace(/<\/?("[^"]*"|'[^']*'|[^>])*(>|$)/g, "HTML Markup Was Removed");
}
};
13 changes: 6 additions & 7 deletions geoportal/src/main/webapp/app/search/ItemCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,11 @@ function(declare, lang, array, string, topic, xhr, on, appTopics, domStyle, domC
render: function(hit) {
var item = this.item = hit._source;
item._id = hit._id;
// item.title = this._strip(item.title);
item.title = item.title? item.title: "???";
item.title = this._strip(item.title);
var links = this._uniqueLinks(item);
this._renderTitleLink(item._id, item);
this._renderOwnerAndDate(item);
util.setNodeText(this.descriptionNode,item.description);
util.setNodeText(this.descriptionNode,this._strip(item.description));
this._renderThumbnail(item);

this._renderFootprint(item);
Expand Down Expand Up @@ -335,7 +334,7 @@ function(declare, lang, array, string, topic, xhr, on, appTopics, domStyle, domC
_renderDataHtml: function(item, uri) {
console.log(item);
var itemHtml = new ItemHtml({
title: this._stripDialogTitle(item.title),
title: this._strip(item.title),
uri: uri,
style: "width: 80%; max-width: 80%; height: 80%; max-height: 80%;",
onHide: function() {
Expand Down Expand Up @@ -850,7 +849,7 @@ function(declare, lang, array, string, topic, xhr, on, appTopics, domStyle, domC
href: href,
target: "_blank",
"class": "g-item-status",
innerHTML: caption
innerHTML:this._strip(caption)
}, actionsNode);
}
},
Expand Down Expand Up @@ -897,11 +896,11 @@ function(declare, lang, array, string, topic, xhr, on, appTopics, domStyle, domC
}
},

_stripDialogTitle: function(html) {
_strip: function(html) {
let doc = new DOMParser().parseFromString(html, 'text/html');
return doc.body.textContent || "Metadata Information";
}
});

return oThisClass;
});
});

0 comments on commit d42b2e3

Please sign in to comment.