ref 11529: DataMiner - Make http reference to logs of DataMiner script a hyperlink
https://support.d4science.org/issues/11529 Added Hyperlink support for logs. git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@167392 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
51e1c223e0
commit
14b70f4bb6
|
@ -4,6 +4,7 @@
|
||||||
<Change>Integrated DataMiner CL for simplify integration with new
|
<Change>Integrated DataMiner CL for simplify integration with new
|
||||||
StorageHub[ticket #11720]</Change>
|
StorageHub[ticket #11720]</Change>
|
||||||
<Change>Added refresh button in operators panel[ticket #11741]</Change>
|
<Change>Added refresh button in operators panel[ticket #11741]</Change>
|
||||||
|
<Change>Added hyperlink for log that contains http reference[ticket #11529]</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.data-miner-manager.1-6-0"
|
<Changeset component="org.gcube.portlets-user.data-miner-manager.1-6-0"
|
||||||
date="2016-11-09">
|
date="2016-11-09">
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.portlets.user.dataminermanager.client.custom.progress.OrangePro
|
||||||
import org.gcube.portlets.user.dataminermanager.client.custom.progress.RedProgressBar;
|
import org.gcube.portlets.user.dataminermanager.client.custom.progress.RedProgressBar;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.events.CancelComputationExecutionRequestEvent;
|
import org.gcube.portlets.user.dataminermanager.client.events.CancelComputationExecutionRequestEvent;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
|
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
|
||||||
|
import org.gcube.portlets.user.dataminermanager.client.util.ElementsHighlights;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
||||||
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||||
|
@ -178,6 +179,9 @@ public class ComputationStatusPanel extends SimpleContainer {
|
||||||
} else {
|
} else {
|
||||||
errorMessage = computationStatus.getError()
|
errorMessage = computationStatus.getError()
|
||||||
.getLocalizedMessage();
|
.getLocalizedMessage();
|
||||||
|
ElementsHighlights el=new ElementsHighlights();
|
||||||
|
errorMessage=el.createLinkFromText(errorMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
Info.display("Failed",
|
Info.display("Failed",
|
||||||
"The computation " + computationId.getId() + " of "
|
"The computation " + computationId.getId() + " of "
|
||||||
|
|
|
@ -0,0 +1,271 @@
|
||||||
|
package org.gcube.portlets.user.dataminermanager.client.util;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ElementsHighlights {
|
||||||
|
|
||||||
|
public ElementsHighlights() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createLinkFromText(String text) {
|
||||||
|
Log.info("Message: " + text);
|
||||||
|
if (text == null || text.isEmpty()) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean end = false;
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
String mes = new String(text);
|
||||||
|
|
||||||
|
while (!end) {
|
||||||
|
if (mes != null && !mes.isEmpty()) {
|
||||||
|
if (mes.contains("http") || mes.contains("https")) {
|
||||||
|
int httpIndex = mes.indexOf("http");
|
||||||
|
int httpsIndex = mes.indexOf("https");
|
||||||
|
if (httpIndex == -1) {
|
||||||
|
if (httpsIndex == -1) {
|
||||||
|
result.append(mes);
|
||||||
|
end = true;
|
||||||
|
} else {
|
||||||
|
String prefix = mes.substring(0, httpsIndex);
|
||||||
|
result.append(prefix);
|
||||||
|
|
||||||
|
String checkTerminator;
|
||||||
|
if (httpsIndex > 0) {
|
||||||
|
checkTerminator = mes.substring(httpsIndex - 1, httpsIndex);
|
||||||
|
if (checkTerminator.compareTo(" ") != 0 && checkTerminator.compareTo("\"") != 0
|
||||||
|
&& checkTerminator.compareTo("'") != 0) {
|
||||||
|
Log.debug("Terminator Found:" + checkTerminator);
|
||||||
|
checkTerminator = " ";
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
checkTerminator = " ";
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mes = mes.substring(httpsIndex, mes.length());
|
||||||
|
|
||||||
|
int terminator = mes.indexOf(checkTerminator);
|
||||||
|
if (terminator == -1) {
|
||||||
|
if(mes.contains("</")){
|
||||||
|
int j=mes.indexOf("</");
|
||||||
|
String extractedUrl=mes.substring(0, j);
|
||||||
|
result.append("<a href='" + extractedUrl + "' target='_blank'>" + extractedUrl + "</a>");
|
||||||
|
result.append(mes.substring(j));
|
||||||
|
} else {
|
||||||
|
result.append("<a href='" + mes + "' target='_blank'>" + mes + "</a>");
|
||||||
|
}
|
||||||
|
end = true;
|
||||||
|
} else {
|
||||||
|
String extractedUrl;
|
||||||
|
if (checkTerminator == " ") {
|
||||||
|
extractedUrl = mes.substring(0, terminator+1);
|
||||||
|
} else {
|
||||||
|
extractedUrl = mes.substring(0, terminator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(extractedUrl.contains("</")){
|
||||||
|
int k=extractedUrl.indexOf("</");
|
||||||
|
extractedUrl=extractedUrl.substring(0, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.debug("extractedUrl: "+extractedUrl);
|
||||||
|
result.append(
|
||||||
|
"<a href='" + extractedUrl + "' target='_blank'>" + extractedUrl + "</a>");
|
||||||
|
mes = mes.substring(terminator, mes.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (httpsIndex == -1) {
|
||||||
|
String prefix = mes.substring(0, httpIndex);
|
||||||
|
result.append(prefix);
|
||||||
|
|
||||||
|
String checkTerminator;
|
||||||
|
if (httpIndex > 0) {
|
||||||
|
checkTerminator = mes.substring(httpIndex - 1, httpIndex);
|
||||||
|
if (checkTerminator.compareTo(" ") != 0 && checkTerminator.compareTo("\"") != 0
|
||||||
|
&& checkTerminator.compareTo("'") != 0) {
|
||||||
|
Log.debug("Terminator Found:" + checkTerminator);
|
||||||
|
checkTerminator = " ";
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
checkTerminator = " ";
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
}
|
||||||
|
|
||||||
|
mes = mes.substring(httpIndex, mes.length());
|
||||||
|
int terminator = mes.indexOf(checkTerminator);
|
||||||
|
Log.debug("TerminatorCheck found: "+terminator);
|
||||||
|
if (terminator == -1) {
|
||||||
|
if(mes.contains("</")){
|
||||||
|
int j=mes.indexOf("</");
|
||||||
|
String extractedUrl=mes.substring(0, j);
|
||||||
|
result.append("<a href='" + extractedUrl + "' target='_blank'>" + extractedUrl + "</a>");
|
||||||
|
result.append(mes.substring(j));
|
||||||
|
} else {
|
||||||
|
result.append("<a href='" + mes + "' target='_blank'>" + mes + "</a>");
|
||||||
|
}
|
||||||
|
end = true;
|
||||||
|
} else {
|
||||||
|
String extractedUrl;
|
||||||
|
if (checkTerminator == " ") {
|
||||||
|
extractedUrl = mes.substring(0, terminator+1);
|
||||||
|
} else {
|
||||||
|
extractedUrl = mes.substring(0, terminator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(extractedUrl.contains("</")){
|
||||||
|
int k=extractedUrl.indexOf("</");
|
||||||
|
extractedUrl=extractedUrl.substring(0, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.debug("extractedUrl: "+extractedUrl);
|
||||||
|
result.append(
|
||||||
|
"<a href='" + extractedUrl + "' target='_blank'>" + extractedUrl + "</a>");
|
||||||
|
mes = mes.substring(terminator, mes.length());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (httpsIndex <= httpIndex) {
|
||||||
|
String prefix = mes.substring(0, httpsIndex);
|
||||||
|
result.append(prefix);
|
||||||
|
|
||||||
|
String checkTerminator;
|
||||||
|
if (httpsIndex > 0) {
|
||||||
|
checkTerminator = mes.substring(httpsIndex - 1, httpsIndex);
|
||||||
|
if (checkTerminator.compareTo(" ") != 0 && checkTerminator.compareTo("\"") != 0
|
||||||
|
&& checkTerminator.compareTo("'") != 0) {
|
||||||
|
Log.debug("Terminator Found:" + checkTerminator);
|
||||||
|
checkTerminator = " ";
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
checkTerminator = " ";
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mes = mes.substring(httpsIndex, mes.length());
|
||||||
|
int terminator = mes.indexOf(checkTerminator);
|
||||||
|
|
||||||
|
if (terminator == -1) {
|
||||||
|
if(mes.contains("</")){
|
||||||
|
int j=mes.indexOf("</");
|
||||||
|
String extractedUrl=mes.substring(0, j);
|
||||||
|
result.append("<a href='" + extractedUrl + "' target='_blank'>" + extractedUrl + "</a>");
|
||||||
|
result.append(mes.substring(j));
|
||||||
|
} else {
|
||||||
|
result.append("<a href='" + mes + "' target='_blank'>" + mes + "</a>");
|
||||||
|
}
|
||||||
|
end = true;
|
||||||
|
} else {
|
||||||
|
String extractedUrl;
|
||||||
|
if (checkTerminator == " ") {
|
||||||
|
extractedUrl = mes.substring(0, terminator);
|
||||||
|
} else {
|
||||||
|
extractedUrl = mes.substring(0, terminator - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(extractedUrl.contains("</")){
|
||||||
|
int k=extractedUrl.indexOf("</");
|
||||||
|
extractedUrl=extractedUrl.substring(0, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.debug("extractedUrl: "+extractedUrl);
|
||||||
|
result.append(
|
||||||
|
"<a href='" + extractedUrl + "' target='_blank'>" + extractedUrl + "</a>");
|
||||||
|
mes = mes.substring(terminator, mes.length());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String prefix = mes.substring(0, httpIndex);
|
||||||
|
result.append(prefix);
|
||||||
|
|
||||||
|
String checkTerminator;
|
||||||
|
if (httpIndex > 0) {
|
||||||
|
checkTerminator = mes.substring(httpIndex - 1, httpIndex);
|
||||||
|
if (checkTerminator.compareTo(" ") != 0 && checkTerminator.compareTo("\"") != 0
|
||||||
|
&& checkTerminator.compareTo("'") != 0) {
|
||||||
|
Log.debug("Terminator Found:" + checkTerminator);
|
||||||
|
checkTerminator = " ";
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
checkTerminator = " ";
|
||||||
|
Log.debug("Terminator Set:" + checkTerminator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mes = mes.substring(httpIndex, mes.length());
|
||||||
|
int terminator = mes.indexOf(checkTerminator);
|
||||||
|
|
||||||
|
if (terminator == -1) {
|
||||||
|
if(mes.contains("</")){
|
||||||
|
int j=mes.indexOf("</");
|
||||||
|
String extractedUrl=mes.substring(0, j);
|
||||||
|
result.append("<a href='" + extractedUrl + "' target='_blank'>" + extractedUrl + "</a>");
|
||||||
|
result.append(mes.substring(j));
|
||||||
|
} else {
|
||||||
|
result.append("<a href='" + mes + "' target='_blank'>" + mes + "</a>");
|
||||||
|
}
|
||||||
|
end = true;
|
||||||
|
} else {
|
||||||
|
String extractedUrl;
|
||||||
|
if (checkTerminator == " ") {
|
||||||
|
extractedUrl = mes.substring(0, terminator);
|
||||||
|
} else {
|
||||||
|
extractedUrl = mes.substring(0, terminator - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(extractedUrl.contains("</")){
|
||||||
|
int k=extractedUrl.indexOf("</");
|
||||||
|
extractedUrl=extractedUrl.substring(0, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.debug("extractedUrl: "+extractedUrl);
|
||||||
|
result.append(
|
||||||
|
"<a href='" + extractedUrl + "' target='_blank'>" + extractedUrl + "</a>");
|
||||||
|
mes = mes.substring(terminator, mes.length());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
result.append(mes);
|
||||||
|
end = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
end = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.info("New Message: " + result.toString());
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ public class Constants {
|
||||||
|
|
||||||
public static final String DEFAULT_USER = "giancarlo.panichi";
|
public static final String DEFAULT_USER = "giancarlo.panichi";
|
||||||
public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
|
public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
|
||||||
public final static String DEFAULT_TOKEN = "ae1208f0-210d-47c9-9b24-d3f2dfcce05f-98187548";
|
public final static String DEFAULT_TOKEN = "";
|
||||||
|
|
||||||
public static final String DEFAULT_ROLE = "OrganizationMember";
|
public static final String DEFAULT_ROLE = "OrganizationMember";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package org.gcube.portlets.user.dataminermanager;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.dataminermanager.client.util.ElementsHighlights;
|
||||||
|
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ElementsHighlightsTest extends TestCase {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(ElementsHighlightsTest.class);
|
||||||
|
|
||||||
|
public void testExecute() {
|
||||||
|
if (Constants.TEST_ENABLE) {
|
||||||
|
logger.debug("ElementsHighlightsTest Test");
|
||||||
|
try {
|
||||||
|
ElementsHighlights eh = new ElementsHighlights();
|
||||||
|
|
||||||
|
/*String textWithLink = new String(
|
||||||
|
"Result reported in https://trivial.com/error/Error.txt and https://trivial.com/error/Error.txt test2");
|
||||||
|
logger.debug("Text with link: " + textWithLink);
|
||||||
|
eh.createLinkFromText(textWithLink);
|
||||||
|
|
||||||
|
String textWithoutLink = new String(
|
||||||
|
"Error reported in https://trivial.com/error/Error.txt and https://trivial.com/error/Error.txt test2");
|
||||||
|
logger.debug("Text without link: " + textWithoutLink);
|
||||||
|
eh.createLinkFromText(textWithoutLink);
|
||||||
|
|
||||||
|
String textNull = null;
|
||||||
|
logger.debug("Text null: " + textNull);
|
||||||
|
eh.createLinkFromText(textNull);*/
|
||||||
|
|
||||||
|
String textWithSomeTags = new String(
|
||||||
|
"The computation e1e862c8-2735-45ec-9e21-7663a7366316 of Netcdf Support "
|
||||||
|
+ "Java has failed. http://www.opengis.net/ows/1.1 xmlns:wps='http://www.opengis.net/wps/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> java.lang.RuntimeException: Logs of the script can be found at http://data-d.d4science.org/ZHFXaWtUS2FSOGlqSytNOHZaRHNMYTFRSkw3WEc2d3ZHbWJQNStIS0N6Yz0-VLT</ows:ExceptionText>");
|
||||||
|
logger.debug("Text with some tags: " + textWithSomeTags);
|
||||||
|
eh.createLinkFromText(textWithSomeTags);
|
||||||
|
|
||||||
|
assertTrue("Success", true);
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
assertTrue("Error", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
assertTrue("Success", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue