merged with branch version 1.9 at 179217 RN
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@179847 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8e9ecfe58c
commit
57c3d65283
|
@ -3,7 +3,7 @@
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
<dependent-module archiveName="grsf-common-library-1.0.3-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-common-library/grsf-common-library">
|
<dependent-module archiveName="ckan-util-library-2.10.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library-TRUNK/ckan-util-library-TRUNK">
|
||||||
<dependency-type>uses</dependency-type>
|
<dependency-type>uses</dependency-type>
|
||||||
</dependent-module>
|
</dependent-module>
|
||||||
<property name="context-root" value="grsf-publisher-ws"/>
|
<property name="context-root" value="grsf-publisher-ws"/>
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
<!DOCTYPE xml>
|
<!DOCTYPE xml>
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<Changeset component="org.gcube.data-catalogue.grsf-publisher-ws.1-9-0" date="${buildDate}">
|
<Changeset component="org.gcube.data-catalogue.grsf-publisher-ws.1-9-0" date="${buildDate}">
|
||||||
<Change></Change>
|
<Change>refers_to can be null while publishing legacy records refs #13347</Change>
|
||||||
|
<Change>Removed the non-ascii clean from extra fields refs #12421</Change>
|
||||||
|
<Change>Properly supporting UTF-8 characters refs #12421</Change>
|
||||||
|
<Change>Title is updated according to Stock/Fishery Name refs #16395</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.data-catalogue.grsf-publisher-ws.1-8-0" date="2019-02-26">
|
<Changeset component="org.gcube.data-catalogue.grsf-publisher-ws.1-8-0" date="2019-02-26">
|
||||||
<Change>The sources in GRSF VRE are calculated using 'database_sources' field #12861</Change>
|
<Change>The sources in GRSF VRE are calculated using 'database_sources' field #12861</Change>
|
||||||
|
|
|
@ -196,7 +196,7 @@ public abstract class Base {
|
||||||
else
|
else
|
||||||
values = new ArrayList<String>();
|
values = new ArrayList<String>();
|
||||||
|
|
||||||
values.add(HelperMethods.removeHTML(value.toString()));
|
values.add(HelperMethods.removeHTML(value.toString(), false));
|
||||||
extrasFields.put(key, values);
|
extrasFields.put(key, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class FisheryRecord extends Common {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FisheryRecord [fisheryName=" + fisheryName + ", fisheryId="
|
return super.toString() + " - FisheryRecord [fisheryName=" + fisheryName + ", fisheryId="
|
||||||
+ fisheryId + ", fishingArea=" + fishingArea
|
+ fisheryId + ", fishingArea=" + fishingArea
|
||||||
+ ", resourcesExploited=" + resourcesExploited
|
+ ", resourcesExploited=" + resourcesExploited
|
||||||
+ ", jurisdictionArea=" + jurisdictionArea
|
+ ", jurisdictionArea=" + jurisdictionArea
|
||||||
|
|
|
@ -292,7 +292,7 @@ public class StockRecord extends Common{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StockRecord [stockName=" + stockName + ", stockId=" + stockId
|
return super.toString() + "- StockRecord [stockName=" + stockName + ", stockId=" + stockId
|
||||||
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
||||||
+ ", assessmentMethods=" + assessmentMethods
|
+ ", assessmentMethods=" + assessmentMethods
|
||||||
+ ", abundanceLevelStandard=" + abundanceLevelStandard
|
+ ", abundanceLevelStandard=" + abundanceLevelStandard
|
||||||
|
|
|
@ -423,9 +423,12 @@ public class GrsfPublisherFisheryService {
|
||||||
// check he/she has admin role
|
// check he/she has admin role
|
||||||
CommonServiceUtils.hasAdminRole(username, catalogue, apiKey, organization);
|
CommonServiceUtils.hasAdminRole(username, catalogue, apiKey, organization);
|
||||||
|
|
||||||
// name, title, product url and are going to remain unchanged (so we keep them from the already published record);
|
// name, product url and are going to remain unchanged (so we keep them from the already published record);
|
||||||
String name = recordPublished.getName();
|
String name = recordPublished.getName();
|
||||||
String title = recordPublished.getTitle();
|
|
||||||
|
// The title must change if Fishery Name change
|
||||||
|
//String title = recordPublished.getTitle();
|
||||||
|
String title = record.getFisheryName();
|
||||||
|
|
||||||
// Cast the source to the accepted ones
|
// Cast the source to the accepted ones
|
||||||
Sources sourceInPath = Sources.onDeserialize(source);
|
Sources sourceInPath = Sources.onDeserialize(source);
|
||||||
|
@ -480,7 +483,7 @@ public class GrsfPublisherFisheryService {
|
||||||
// update the product
|
// update the product
|
||||||
String id = catalogue.updateCKanDataset(apiKey, catalogId, title, name, publishInOrganization,
|
String id = catalogue.updateCKanDataset(apiKey, catalogId, title, name, publishInOrganization,
|
||||||
authorFullname, authorMail, record.getMaintainer(), record.getMaintainerContact(), version,
|
authorFullname, authorMail, record.getMaintainer(), record.getMaintainerContact(), version,
|
||||||
HelperMethods.removeHTML(record.getDescription()), license, new ArrayList<String>(tags), null, // remove any previous group
|
HelperMethods.removeHTML(record.getDescription(), false), license, new ArrayList<String>(tags), null, // remove any previous group
|
||||||
customFields, resources, publicDataset);
|
customFields, resources, publicDataset);
|
||||||
|
|
||||||
if(id != null) {
|
if(id != null) {
|
||||||
|
|
|
@ -188,7 +188,7 @@ public class GrsfPublisherStockService {
|
||||||
publishInOrganization, authorFullname, authorMail,
|
publishInOrganization, authorFullname, authorMail,
|
||||||
record.getMaintainer() == null ? authorFullname : record.getMaintainer(),
|
record.getMaintainer() == null ? authorFullname : record.getMaintainer(),
|
||||||
record.getMaintainerContact() == null ? authorMail : record.getMaintainerContact(), version,
|
record.getMaintainerContact() == null ? authorMail : record.getMaintainerContact(), version,
|
||||||
HelperMethods.removeHTML(record.getDescription()), license, new ArrayList<String>(tags),
|
HelperMethods.removeHTML(record.getDescription(), false), license, new ArrayList<String>(tags),
|
||||||
customFields, resources, publicDataset);
|
customFields, resources, publicDataset);
|
||||||
|
|
||||||
if(id != null) {
|
if(id != null) {
|
||||||
|
@ -425,9 +425,13 @@ public class GrsfPublisherStockService {
|
||||||
// check he/she has admin role
|
// check he/she has admin role
|
||||||
CommonServiceUtils.hasAdminRole(username, catalogue, apiKey, organization);
|
CommonServiceUtils.hasAdminRole(username, catalogue, apiKey, organization);
|
||||||
|
|
||||||
// name, title, product url and are going to remain unchanged (so we keep them from the publisher record);
|
// name, product url and are going to remain unchanged (so we keep them from the publisher record);
|
||||||
String name = recordPublished.getName();
|
String name = recordPublished.getName();
|
||||||
String title = recordPublished.getTitle();
|
|
||||||
|
// The title must change if Stock Name change
|
||||||
|
//String title = recordPublished.getTitle();
|
||||||
|
String title = record.getStockName();
|
||||||
|
|
||||||
|
|
||||||
// Cast the source to the accepted ones
|
// Cast the source to the accepted ones
|
||||||
Sources sourceInPath = Sources.onDeserialize(source);
|
Sources sourceInPath = Sources.onDeserialize(source);
|
||||||
|
@ -482,7 +486,7 @@ public class GrsfPublisherStockService {
|
||||||
// update the product
|
// update the product
|
||||||
String id = catalogue.updateCKanDataset(apiKey, catalogId, title, name, publishInOrganization,
|
String id = catalogue.updateCKanDataset(apiKey, catalogId, title, name, publishInOrganization,
|
||||||
authorFullname, authorMail, record.getMaintainer(), record.getMaintainerContact(), version,
|
authorFullname, authorMail, record.getMaintainer(), record.getMaintainerContact(), version,
|
||||||
HelperMethods.removeHTML(record.getDescription()), license, new ArrayList<String>(tags), null, // remove any previous group
|
HelperMethods.removeHTML(record.getDescription(), false), license, new ArrayList<String>(tags), null, // remove any previous group
|
||||||
customFields, resources, publicDataset);
|
customFields, resources, publicDataset);
|
||||||
|
|
||||||
if(id != null) {
|
if(id != null) {
|
||||||
|
|
|
@ -80,20 +80,19 @@ public class CommonServiceUtils {
|
||||||
List<RefersToBean> refersToList = record.getRefersTo();
|
List<RefersToBean> refersToList = record.getRefersTo();
|
||||||
if(refersToList == null || refersToList.isEmpty())
|
if(refersToList == null || refersToList.isEmpty())
|
||||||
throw new Exception("refers_to cannot be null/empty");
|
throw new Exception("refers_to cannot be null/empty");
|
||||||
}
|
|
||||||
|
|
||||||
String shortTitle = record.getShortName();
|
|
||||||
Boolean traceabilityFlag = record.isTraceabilityFlag();
|
Boolean traceabilityFlag = record.isTraceabilityFlag();
|
||||||
Status status = record.getStatus();
|
|
||||||
|
|
||||||
if(traceabilityFlag == null)
|
if(traceabilityFlag == null)
|
||||||
throw new Exception("traceability_flag cannot be null");
|
throw new Exception("traceability_flag cannot be null");
|
||||||
|
|
||||||
if(shortTitle == null || shortTitle.isEmpty())
|
Status status = record.getStatus();
|
||||||
throw new Exception("short_title cannot be null/empty");
|
|
||||||
|
|
||||||
if(status == null)
|
if(status == null)
|
||||||
throw new Exception("status cannot be null/empty");
|
throw new Exception("status cannot be null/empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
String shortTitle = record.getShortName();
|
||||||
|
if(shortTitle == null || shortTitle.isEmpty())
|
||||||
|
throw new Exception("short_title cannot be null/empty");
|
||||||
|
|
||||||
// check if it is a stock and perform related checks
|
// check if it is a stock and perform related checks
|
||||||
if(record.getClass().equals(StockRecord.class)) {
|
if(record.getClass().equals(StockRecord.class)) {
|
||||||
|
@ -349,18 +348,21 @@ public class CommonServiceUtils {
|
||||||
Constants.TIME_SERIES_TAKE_LAST_VALUES);
|
Constants.TIME_SERIES_TAKE_LAST_VALUES);
|
||||||
for(int i = 0; i < elementsToConsider; i++) {
|
for(int i = 0; i < elementsToConsider; i++) {
|
||||||
// trim and remove html
|
// trim and remove html
|
||||||
String clean = HelperMethods.removeHTML(asList.get(i).toString().trim());
|
// String clean = HelperMethods.removeHTML(asList.get(i).toString().trim());
|
||||||
|
String clean = HelperMethods.removeHTML(asList.get(i).toString().trim(), false);
|
||||||
valuesForKey.add(clean);
|
valuesForKey.add(clean);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
for(int i = 0; i < elementsToConsider; i++) {
|
for(int i = 0; i < elementsToConsider; i++) {
|
||||||
String clean = HelperMethods.removeHTML(asList.get(i).toString().trim());
|
// String clean = HelperMethods.removeHTML(asList.get(i).toString().trim());
|
||||||
|
String clean = HelperMethods.removeHTML(asList.get(i).toString().trim(), false);
|
||||||
valuesForKey.add(clean);
|
valuesForKey.add(clean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String clean = HelperMethods.removeHTML(f.toString().trim());
|
// String clean = HelperMethods.removeHTML(f.toString().trim());
|
||||||
|
String clean = HelperMethods.removeHTML(f.toString().trim(), false);
|
||||||
valuesForKey.add(clean);
|
valuesForKey.add(clean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,11 +502,13 @@ public class CommonServiceUtils {
|
||||||
// I'm not in GRSF Admin so the groups must be added using databaseSources
|
// I'm not in GRSF Admin so the groups must be added using databaseSources
|
||||||
|
|
||||||
List<Resource<Sources>> databaseSources = record.getDatabaseSources();
|
List<Resource<Sources>> databaseSources = record.getDatabaseSources();
|
||||||
|
if(databaseSources!=null) {
|
||||||
for(Resource<Sources> source : databaseSources) {
|
for(Resource<Sources> source : databaseSources) {
|
||||||
Sources sourceName = source.getName();
|
Sources sourceName = source.getName();
|
||||||
sourcesList.add(sourceName.getOrigName().toLowerCase());
|
sourcesList.add(sourceName.getOrigName().toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// append to groups: we need to add this record to the correspondent group of the sources
|
// append to groups: we need to add this record to the correspondent group of the sources
|
||||||
addRecordToGroupSources(groups, new ArrayList(sourcesList), productType, sourceInPath);
|
addRecordToGroupSources(groups, new ArrayList(sourcesList), productType, sourceInPath);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -66,7 +65,7 @@ public abstract class HelperMethods {
|
||||||
|
|
||||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(HelperMethods.class);
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(HelperMethods.class);
|
||||||
private static final String APPLICATION_ID_CATALOGUE_MANAGER = "org.gcube.datacatalogue.ProductCatalogue";
|
private static final String APPLICATION_ID_CATALOGUE_MANAGER = "org.gcube.datacatalogue.ProductCatalogue";
|
||||||
private static final String NOTIFICATION_MESSAGE = "Dear members,<br>The record 'PRODUCT_TITLE' has been just published by USER_FULLNAME.<br>You can find it here: PRODUCT_URL <br>";
|
private static final String NOTIFICATION_MESSAGE = "Dear members,\nThe record 'PRODUCT_TITLE' has been just published by USER_FULLNAME.\nYou can find it here: PRODUCT_URL\n";
|
||||||
private static final String SOCIAL_SERVICE_APPLICATION_TOKEN = "/2/tokens/generate-application-token/";
|
private static final String SOCIAL_SERVICE_APPLICATION_TOKEN = "/2/tokens/generate-application-token/";
|
||||||
private static final String SOCIAL_SERVICE_WRITE_APPLICATION_POST = "/2/posts/write-post-app/";
|
private static final String SOCIAL_SERVICE_WRITE_APPLICATION_POST = "/2/posts/write-post-app/";
|
||||||
private static final String MEDIATYPE_JSON = "application/json";
|
private static final String MEDIATYPE_JSON = "application/json";
|
||||||
|
@ -351,25 +350,32 @@ public abstract class HelperMethods {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static String removeHTML(String html, boolean removeAscii) {
|
||||||
* Strip out HTML code
|
|
||||||
* @param html
|
|
||||||
* @return
|
|
||||||
* @throws UnsupportedEncodingException
|
|
||||||
*/
|
|
||||||
public static String removeHTML(String html) {
|
|
||||||
if(html == null || html.isEmpty())
|
if(html == null || html.isEmpty())
|
||||||
return html;
|
return html;
|
||||||
|
|
||||||
// remove html and clean
|
// remove html and clean
|
||||||
String withoutHTML = Jsoup.parse(html).text();
|
String withoutHTML = Jsoup.parse(html).text();
|
||||||
withoutHTML = Jsoup.clean(withoutHTML, Whitelist.basic());
|
withoutHTML = Jsoup.clean(withoutHTML, Whitelist.basic());
|
||||||
|
if(removeAscii) {
|
||||||
// remove non ascii chars ...
|
// remove non ascii chars ...
|
||||||
withoutHTML = withoutHTML.replaceAll("[^\\p{ASCII}]", " ");
|
withoutHTML = withoutHTML.replaceAll("[^\\p{ASCII}]", " ");
|
||||||
|
}
|
||||||
return withoutHTML;
|
return withoutHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip out HTML code
|
||||||
|
* @param html
|
||||||
|
* @return
|
||||||
|
* @throws UnsupportedEncodingException
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
public static String removeHTML(String html) {
|
||||||
|
return removeHTML(html, true);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send notification to vre members about the created product by writing a post.
|
* Send notification to vre members about the created product by writing a post.
|
||||||
* @param productName the title of the product
|
* @param productName the title of the product
|
||||||
|
|
|
@ -374,7 +374,7 @@ public class JTests {
|
||||||
public void removeHTML() throws Exception{
|
public void removeHTML() throws Exception{
|
||||||
|
|
||||||
String toTest = "<p>Based on the results of the MP operation[] asdkljlasdklsa . - * ; for 2015–17 in its 2013 meeting and the outcome of the review of exceptional circumstances in its 2015 meeting, the ESC recommended that there is no need to revise the Extended Commission’s 2013 TAC decision regarding the TAC for 2016–17. The recommended annual TAC for the years 2016-2017 is 14,647.4t.</p>";
|
String toTest = "<p>Based on the results of the MP operation[] asdkljlasdklsa . - * ; for 2015–17 in its 2013 meeting and the outcome of the review of exceptional circumstances in its 2015 meeting, the ESC recommended that there is no need to revise the Extended Commission’s 2013 TAC decision regarding the TAC for 2016–17. The recommended annual TAC for the years 2016-2017 is 14,647.4t.</p>";
|
||||||
HelperMethods.removeHTML(toTest);
|
HelperMethods.removeHTML(toTest, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue