Skip to content

Commit

Permalink
added /availableoutputformats url service which outputs a json format…
Browse files Browse the repository at this point in the history
…ted list of output plug-ins (GRAPHDB-336)
  • Loading branch information
Daniel Kirstenpfad committed Jul 31, 2011
1 parent 8d8b77f commit 39dcdc8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
44 changes: 44 additions & 0 deletions Plugins/GraphDS/RESTService/Service/GraphDSREST_Output.cs
Expand Up @@ -295,6 +295,50 @@ public Stream GetDDate()

#endregion

#region GetAvailableOutputFormats()
public Stream GetAvailableOutputFormats()
{
if (WebOperationContext.Current != null)
{
WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";
}
else if (HttpServer.HttpContext != null)
{
HttpServer.HttpContext.Response.SetContentType(new ContentType("application/json"));
}

StringBuilder jsonArray = new StringBuilder();

jsonArray.AppendLine("{");
jsonArray.AppendLine("\"GraphDSOutputFormats\":[");
jsonArray.AppendLine(" {");
// generate JSON formatted output of available I/O plug-ins and associated content-types
// {
// "application/xml":"XML_IO",
// "text/plain":"TEXT_IO"
// }

Int32 Runthrough = 0;

foreach (IOInterface _io_plugin in _Plugins.Values)
{
Runthrough++;

// we have the name and the content type
if (Runthrough == _Plugins.Values.Count)
jsonArray.AppendLine(" \""+_io_plugin.ContentType+"\":\""+_io_plugin.PluginName+"\"");
else
jsonArray.AppendLine(" \""+_io_plugin.ContentType+"\":\""+_io_plugin.PluginName+"\",");

}
jsonArray.AppendLine(" }");
jsonArray.AppendLine(" ]");
jsonArray.AppendLine("}");

return new MemoryStream(Encoding.UTF8.GetBytes(jsonArray.ToString()));
}

#endregion
}

}
Expand Down
12 changes: 11 additions & 1 deletion Plugins/GraphDS/RESTService/Service/GraphDSREST_Service.cs
Expand Up @@ -327,7 +327,17 @@ public Stream GetDDate()

#endregion

#region GetClientAccessPolicy
#region GetAvailableOutputFormats()

public Stream GetAvailableOutputFormats()
{
return _RESTOutput.GetAvailableOutputFormats();
}

#endregion


#region GetClientAccessPolicy

public void GetClientAccessPolicy()
{
Expand Down
9 changes: 9 additions & 0 deletions Plugins/GraphDS/RESTService/Service/IGraphDSREST_Service.cs
Expand Up @@ -188,6 +188,15 @@ public interface IGraphDSREST_Service : ISonesRESTService
[WebGet(UriTemplate = "/ddate")]
Stream GetDDate();


/// <summary>
/// Returns the available output formats
/// </summary>
/// <returns>Returns the available output formats</returns>
[OperationContract, NoAuthentication]
[WebGet(UriTemplate = "/availableoutputformats")]
Stream GetAvailableOutputFormats();

#endregion

}
Expand Down

0 comments on commit 39dcdc8

Please sign in to comment.