Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c9ced222 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- prepared for JSON message display

parent 8265956b
No related branches found
No related tags found
No related merge requests found
Showing
with 112 additions and 21 deletions
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011, 2013 * Copyright (C) INRIA, 2006-2009, 2011, 2013-2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -54,5 +54,8 @@ public class AlignmentId extends Success { ...@@ -54,5 +54,8 @@ public class AlignmentId extends Success {
public String RESTString(){ public String RESTString(){
return "<alid>"+getContent()+"</alid>"; return "<alid>"+getContent()+"</alid>";
} }
public String JSONString(){
return "{ \"type\" : \"AlignmentId\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011, 2013 * Copyright (C) INRIA, 2006-2009, 2011, 2013-2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -100,4 +100,17 @@ public class AlignmentIds extends Success { ...@@ -100,4 +100,17 @@ public class AlignmentIds extends Success {
msg += " </alignmentList>"; msg += " </alignmentList>";
return msg; return msg;
} }
public String JSONString(){
String msg = "{ \"type\" : \"AlignmentIds\",\n";
msg += " \"alignmentIds\" : [";
String id[] = content.split(" ");
for ( int i = id.length-1; i >= 0; i-- ){
if ( id[i].trim() != "" ) {
msg += " \""+id[i].trim()+"\",\n";
}
}
msg += " ]\n}\n";
return msg;
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -41,4 +41,7 @@ public class AlignmentMetadata extends Success { ...@@ -41,4 +41,7 @@ public class AlignmentMetadata extends Success {
public String SOAPString(){ public String SOAPString(){
return "<id>"+surrogate+"</id>"+"<in-reply-to>"+inReplyTo+"</in-reply-to><metadata>"+content+"</metadata>"; return "<id>"+surrogate+"</id>"+"<in-reply-to>"+inReplyTo+"</in-reply-to><metadata>"+content+"</metadata>";
} }
public String JSONString(){
return "{ \"type\" : \"AlignmentMetadata\",\n \"id\" : \"+surrogate+\",\n \"in-reply-to\" : \"+inReplyTo+\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -36,4 +36,7 @@ public class CannotRenderAlignment extends ErrorMsg { ...@@ -36,4 +36,7 @@ public class CannotRenderAlignment extends ErrorMsg {
public String RESTString(){ public String RESTString(){
return "<CannotRenderAlignment>"+content+"</CannotRenderAlignment>"; return "<CannotRenderAlignment>"+content+"</CannotRenderAlignment>";
} }
public String JSONString(){
return "{ \"type\" : \"CannotRenderAlignment\",\n \"content\" : \""+getContent()+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2012 * Copyright (C) INRIA, 2012, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -63,4 +63,15 @@ public class EntityList extends Success { ...@@ -63,4 +63,15 @@ public class EntityList extends Success {
msg += " </entityList>"; msg += " </entityList>";
return msg; return msg;
} }
public String JSONString(){
String msg = "{ \"type\" : \"EntityList\",\n \"entities\" : \" [\n";
String id[] = content.split(" ");
for ( int i = id.length-1; i >= 0; i-- ){
if ( id[i].trim() != "" ) {
msg += " \""+id[i].trim()+"\",\n";
}
}
msg += "]\n}";
return msg;
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2011 * Copyright (C) INRIA, 2006-2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -56,4 +56,7 @@ public class ErrorMsg extends Message { ...@@ -56,4 +56,7 @@ public class ErrorMsg extends Message {
res += " "+RESTString()+"\n"+" </ErrorMsg>\n"; res += " "+RESTString()+"\n"+" </ErrorMsg>\n";
return res; return res;
} }
public String JSONString(){
return "{ \"type\" : \"ErrorMsg\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2011 * Copyright (C) INRIA, 2006-2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -52,5 +52,13 @@ public class EvalResult extends Success { ...@@ -52,5 +52,13 @@ public class EvalResult extends Success {
results += "</EvaluationResults>"; results += "</EvaluationResults>";
return results; return results;
} }
public String JSONString(){
String results = "{ \"type\" : \"EvaluationResult\"";
for ( String key : getParameters().stringPropertyNames() ) {
results += ",\n \""+key+"\" : \""+getParameters().getProperty( key )+"\"";
}
results += "\n}";
return results;
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2008, 2011 * Copyright (C) INRIA, 2008, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -23,7 +23,7 @@ package fr.inrialpes.exmo.align.service.msg; ...@@ -23,7 +23,7 @@ package fr.inrialpes.exmo.align.service.msg;
import java.util.Properties; import java.util.Properties;
/** /**
* Contains the messages that should be sent according to the protocol * The id of the result of an evaluation
*/ */
public class EvaluationId extends Success { public class EvaluationId extends Success {
...@@ -45,5 +45,8 @@ public class EvaluationId extends Success { ...@@ -45,5 +45,8 @@ public class EvaluationId extends Success {
public String RESTString(){ public String RESTString(){
return "<alid>"+content+"</alid>"; return "<alid>"+content+"</alid>";
} }
public String JSONString(){
return "{ \"type\" : \"EvaluationId\",\n \"id\" : \""+content+"\"}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2007, 2009, 2011 * Copyright (C) INRIA, 2006-2007, 2009, 2011-2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -52,6 +52,9 @@ public class Message { ...@@ -52,6 +52,9 @@ public class Message {
return "<ErrorMsg/>"; return "<ErrorMsg/>";
} }
/**
* For HTML interface calling the REST interface
*/
public String HTMLRESTString(){ public String HTMLRESTString(){
return "<ErrorMsg/>"; return "<ErrorMsg/>";
} }
...@@ -60,6 +63,10 @@ public class Message { ...@@ -60,6 +63,10 @@ public class Message {
return "<id>"+surrogate+"</id>"+"<sender>"+sender+"</sender>" + "<receiver>"+receiver+"</receiver>" + "<in-reply-to>" + inReplyTo+ "</in-reply-to>" + "<content>" + content + "</content>"; return "<id>"+surrogate+"</id>"+"<sender>"+sender+"</sender>" + "<receiver>"+receiver+"</receiver>" + "<in-reply-to>" + inReplyTo+ "</in-reply-to>" + "<content>" + content + "</content>";
} }
public String JSONString(){
return "{ \"id\" : \""+surrogate+"\",\n \"sender\" : \""+sender+"\",\n \"receiver\" : \""+receiver+"\",\n \"in-reply-to\" : \"" + inReplyTo+ "\",\n \"content\" : \"" + content + "\"\n}";
}
public int getId () { public int getId () {
return surrogate; return surrogate;
} }
......
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -38,5 +38,8 @@ public class NonConformParameters extends ErrorMsg { ...@@ -38,5 +38,8 @@ public class NonConformParameters extends ErrorMsg {
public String RESTString(){ public String RESTString(){
return "<NonConformParameters>" + content + "</NonConformParameters>"; return "<NonConformParameters>" + content + "</NonConformParameters>";
} }
public String JSONString(){
return "{ \"type\" : \"NonConformParameters\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -37,5 +37,9 @@ public class OntologyURI extends Success { ...@@ -37,5 +37,9 @@ public class OntologyURI extends Success {
public String RESTString(){ public String RESTString(){
return "<uri>"+content+"</uri>"; return "<uri>"+content+"</uri>";
} }
public String JSONString(){
String res = "{ \"type\" : \"OntologyURI\",\n";
res += " \"uri\" : \""+content+"\"\n}\n";
return res;
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006, 2008-2009, 2011 * Copyright (C) INRIA, 2006, 2008-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -31,7 +31,12 @@ public class RenderedAlignment extends Success { ...@@ -31,7 +31,12 @@ public class RenderedAlignment extends Success {
public RenderedAlignment ( int surr, Message rep, String from, String to, String cont, Properties param ) { public RenderedAlignment ( int surr, Message rep, String from, String to, String cont, Properties param ) {
super( surr, rep, from, to, cont, param ); super( surr, rep, from, to, cont, param );
} }
// THIS CONTENT SHOULD BE ESCAPED: XMLSTRINGENCODDE?
public String RESTString(){ public String RESTString(){
return "<alignment>"+content+"</alignment>"; return "<alignment>"+content+"</alignment>";
} }
// THIS CONTENT SHOULD BE ESCAPED: STRINGENCODDE?
public String JSONString(){
return "{ \"type\" : \"RenderedAlignment\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -36,4 +36,7 @@ public class RunTimeError extends ErrorMsg { ...@@ -36,4 +36,7 @@ public class RunTimeError extends ErrorMsg {
public String HTMLString(){ public String HTMLString(){
return "Cannot process: "+content; return "Cannot process: "+content;
} }
public String JSONString(){
return "{ \"type\" : \"RunTimeError\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006, 2008-2009, 2011 * Copyright (C) INRIA, 2006, 2008-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -41,4 +41,11 @@ public class Success extends Message { ...@@ -41,4 +41,11 @@ public class Success extends Message {
res += " "+RESTString()+"\n"; res += " "+RESTString()+"\n";
return res; return res;
} }
public String JSONString(){
String res = "{ \"type\" : \"Success\",\n";
res += " \"id\" : \""+surrogate+"\",\n";
if ( inReplyTo != null ) res += " \"in-reply-to\" : \""+inReplyTo+"\",\n";
res += " \"content\" : \""+content+"\"\n}\n";
return res;
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -37,4 +37,7 @@ public class TranslatedMessage extends Success { ...@@ -37,4 +37,7 @@ public class TranslatedMessage extends Success {
public String RESTString(){ public String RESTString(){
return "<message>"+content+"</message>"; return "<message>"+content+"</message>";
} }
public String JSONString(){
return "{ \"type\" : \"TranslatedMessage\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -36,4 +36,7 @@ public class UnknownAlignment extends ErrorMsg { ...@@ -36,4 +36,7 @@ public class UnknownAlignment extends ErrorMsg {
public String HTMLString(){ public String HTMLString(){
return "Unknown alignment: "+content; return "Unknown alignment: "+content;
} }
public String JSONString(){
return "{ \"type\" : \"UnknownAlignment\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -36,4 +36,7 @@ public class UnknownMethod extends ErrorMsg { ...@@ -36,4 +36,7 @@ public class UnknownMethod extends ErrorMsg {
public String RESTString() { public String RESTString() {
return "<UnknownMethod>"+content+"</UnknownMethod>"; return "<UnknownMethod>"+content+"</UnknownMethod>";
} }
public String JSONString(){
return "{ \"type\" : \"UnknownMethod\",\n \"content\" : \""+getContent()+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -36,4 +36,7 @@ public class UnreachableAlignment extends ErrorMsg { ...@@ -36,4 +36,7 @@ public class UnreachableAlignment extends ErrorMsg {
public String HTMLString() { public String HTMLString() {
return "Unreachable alignment: "+content; return "Unreachable alignment: "+content;
} }
public String JSONString(){
return "{ \"type\" : \"UnreachableAlignment\",\n \"content\" : \""+content+"\"\n}";
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2006-2009, 2011 * Copyright (C) INRIA, 2006-2009, 2011, 2014
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
...@@ -36,4 +36,7 @@ public class UnreachableOntology extends ErrorMsg { ...@@ -36,4 +36,7 @@ public class UnreachableOntology extends ErrorMsg {
public String HTMLString() { public String HTMLString() {
return "Unreachable ontology: "+content; return "Unreachable ontology: "+content;
} }
public String JSONString(){
return "{ \"type\" : \"UnreachableOntology\",\n \"content\" : \""+content+"\"\n}";
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment