public Service registerLocalAuthority(
String sParentID, String sSubsegment, Service[] oServices,
String[] oInternals, String[] oExternals)
throws StoreException
{
Service oAuth = null;
synchronized (oSync)
{
if (subsegmentExists(sParentID, sSubsegment))
{
throw new StoreException(
Util.KEY_DUPNAME, "XRI Already exists");
}
// Okay to register the subsegment
Map oAuthMap = (Map) oIDAuthMap.get(sParentID);
if (oAuthMap == null)
{
// XXX what to do?
throw new StoreException(
Util.KEY_NOTFOUND,
"XRI authority for id '" + sParentID + "' not found");
}
Map oSubsegmentMap = (Map) oAuthMap.get("Subsegments");
if (oSubsegmentMap == null)
{
// No subsegments registered, yet
oSubsegmentMap = new HashMap();
oAuthMap.put("Subsegments", oSubsegmentMap);
}
Map oSubsegmentPartMap = new HashMap();
oSubsegmentMap.put(sSubsegment, oSubsegmentPartMap);
oAuth = createAuthority();
// Define the parts of the subsegment
oSubsegmentPartMap.put("LocalAuthority", oAuth.getProviderID());
oSubsegmentPartMap.put(
"Date", new Long(System.currentTimeMillis() / 1000));
oSubsegmentPartMap.put(
ssServicesPart,
Util.makeServices(new StringBuffer(), oServices).toString());
oSubsegmentPartMap.put(
ssInternalsPart,
Util.makeInternals(new StringBuffer(), oInternals).toString());
oSubsegmentPartMap.put(
ssExternalsPart,
Util.makeExternals(new StringBuffer(), oExternals).toString());
// Put the authority in the IDAuthMap
Map oNewAuthMap = new HashMap();
oNewAuthMap.put("AuthorityObject", oAuth);
// oNewAuthMap.put(
// "Authority",
// Util.makeAuthority(new StringBuffer(), oAuth).toString());
oIDAuthMap.put(oAuth.getProviderID(), oNewAuthMap);
} // synchronized
return oAuth;