A repository is a central place to store items, resources and other components that enable the FME Server to perform. A typical item is a workspace, a custom format or a custom transformer. Associated with items are resources.
To List Available Repositories
Listing repositories requires a GET request, with no parameters.
httpRequest.open("GET", "/fmerest/repositories.json?token="+token_, true);
httpRequest.onreadystatechange = function()
{
if (httpRequest.readyState == 4)
{
if (httpRequest.status == 200)
{
var reply = eval("(" + httpRequest.responseText + ")");
// verify repositories exist
if (typeof(reply.serviceResponse.repositories) != 'undefined')
{
var repositories = reply.serviceResponse.repositories.repository;
for (var i in repositories)
{
println(repositories[i].name);
}
}
else
{
println("No Repositories");
}
}
else
{
println("Error");
}
}
}
httpRequest.send(null);
To Add Repositories
Repositories are uniquely identified by their name. Create a new repository by specifying a name and description for the repository. Adding a repository requires a POST method, with the parameters sent.
Note: If you add a repository using the name of one that already exists, the existing repository is overwritten.
httpRequest.open("POST", "http://localhost/fmerest/repositories.json?token="+token_, true);
httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var param = "repository="+name+"&description="+description;
httpRequest.setRequestHeader("Content-length", param.length);
httpRequest.setRequestHeader("Connection", "close");
httpRequest.onreadystatechange = function()
{
if (httpRequest.readyState == 4)
{
if (httpRequest.status == 200)
{
println("Repository added");
}
else
{
println("Failed to add repository");
}
}
}
httpRequest.send(param);
To Remove Repositories
Removing a repository requires the name of the repository. It’s important to know that removing a repository also removes any items and resources in it.
httpRequest.open("DELETE", "/fmerest/repositories/"+name+".json?token="+token_, true);
httpRequest.onreadystatechange = function()
{
if (httpRequest.readyState == 4)
{
if (httpRequest.status == 200)
{
println("Repository removed");
}
else
{
println("Failed to remove repository");
}
}
}
httpRequest.send(null);