sOutput, CMD_CREATE_ROOT_AUTHORITY);
return FAILURE;
}
String sNamespace = sSubcommandArgs[0];
Service oAuthority = oAdmin.createRootAuthority(sNamespace);
if (mbOutputAuthIDOnly)
{
sOutput.append(oAuthority.getProviderID());
}
else
{
sOutput.append(oAuthority.dump());
}
}
else if (msSubcommand.equalsIgnoreCase(CMD_DELETE_ROOT_AUTHORITY))
{
sOutput.append(
CMD_DELETE_ROOT_AUTHORITY +
": CURRENTLY NOT IMPLEMENTED.\n");
}
else if (msSubcommand.equalsIgnoreCase(CMD_FIND_ROOT_AUTHORITY))
{
// args: namespace [-output_auth_id_only]
if (iLength != 1)
{
outputSubcommandArgError(sOutput, CMD_FIND_ROOT_AUTHORITY);
return FAILURE;
}
// we'll do special error handling here, because we don't want to
// treat 'not found' as a FAILURE condition -- else caller could
// not distinguish between that and bad argument error
try
{
String sNamespace = sSubcommandArgs[0];
Service oAuthority = oAdmin.findRootAuthority(sNamespace);
sOutput.append(
mbOutputAuthIDOnly ? oAuthority.getProviderID()
: oAuthority.toString());
}
catch (StoreException oEx)
{
// we intepret the following as not-found namespace
if (
(oEx.getExMessage() != null) &&
(oEx.getExMessage().indexOf("namespace") != -1))
{
sOutput.setLength(0); // not needed -- just for illustration
}
else
{
throw oEx;
}
}
}
else if (msSubcommand.equalsIgnoreCase(CMD_LIST_ROOT_AUTHORITIES))
{
sOutput.append(
CMD_LIST_ROOT_AUTHORITIES +
": CURRENTLY NOT IMPLEMENTED.\n");
}
else if (msSubcommand.equalsIgnoreCase(CMD_CREATE_AUTHORITY))
{
sOutput.append(
CMD_CREATE_AUTHORITY + ": CURRENTLY NOT IMPLEMENTED.\n");
}
else if (msSubcommand.equalsIgnoreCase(CMD_DELETE_AUTHORITY))
{
sOutput.append(
CMD_DELETE_AUTHORITY + ": CURRENTLY NOT IMPLEMENTED.\n");
}
else if (msSubcommand.equalsIgnoreCase(CMD_REG_LOCAL_AUTHORITY))
{
sOutput.append(
CMD_REG_LOCAL_AUTHORITY + ": CURRENTLY NOT IMPLEMENTED.\n");
}
else if (msSubcommand.equalsIgnoreCase(CMD_REG_SUBSEGMENT))
{
// args: parent_id subsegment auth_id auth_uri
// [-auth_type <type>] [-add_uri <uri>] [-service <service>]
// [-internal <synonym>] [-external <synonym]
//
// all optional args may have 0..n, except auth_type which is 0..1.
if (iLength != 4)
{
outputSubcommandArgError(sOutput, CMD_REG_SUBSEGMENT);
return FAILURE;
}
String sParentID = sSubcommandArgs[0];
String sSubsegment = sSubcommandArgs[1];
String sAuthID = sSubcommandArgs[2];
String sAuthURI = sSubcommandArgs[3];
// set up the uris. the non-optional one goes first, then append
// the optional ones
String[] sAuthURIs = new String[moAuthURIs.size() + 1];
sAuthURIs[0] = sAuthURI;
for (int i = 1; i < sAuthURIs.length; i++)
{
sAuthURIs[i] = (String) moAuthURIs.get(i - 1);
}
// set up the authority object
Service oChildAuthority = new Service();
oChildAuthority.setProviderID(sAuthID);
oChildAuthority.setType(msAuthType);
for (int i = 0; i < sAuthURIs.length; i++)
{
oChildAuthority.addURI(sAuthURIs[i]);
}
// invoke the command on the server. TODO: currently the services and
// synonyms are not supported
oAdmin.registerSubsegment(