tied the UniStore into the Index Manager by providing resolvers for the Index
Manager to use to retrieve UniStore messages
This commit is contained in:
parent
3328e56f07
commit
ce27befa54
|
@ -92,4 +92,10 @@ public interface Namespaces
|
||||||
public static final String UNISTORE_PERMISSIONS_NAMESPACE =
|
public static final String UNISTORE_PERMISSIONS_NAMESPACE =
|
||||||
"http://www.silverwrist.com/NS/dynamo/2003/06/10/unistore.permissions";
|
"http://www.silverwrist.com/NS/dynamo/2003/06/10/unistore.permissions";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default resolvers namespace for the Index Manager.
|
||||||
|
*/
|
||||||
|
public static final String DEFAULT_INDEX_RESOLVERS_NAMESPACE =
|
||||||
|
"http://www.silverwrist.com/NS/dynamo/2003/06/14/std.index.resolvers";
|
||||||
|
|
||||||
} // end interface Namespaces
|
} // end interface Namespaces
|
||||||
|
|
|
@ -55,4 +55,10 @@ public class IndexException extends ExternalException
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
public IndexException(DatabaseException de)
|
||||||
|
{
|
||||||
|
super(de);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
} // end class IndexException
|
} // end class IndexException
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
|
||||||
import org.w3c.dom.*;
|
import org.w3c.dom.*;
|
||||||
import com.silverwrist.util.*;
|
import com.silverwrist.util.*;
|
||||||
import com.silverwrist.util.xml.*;
|
import com.silverwrist.util.xml.*;
|
||||||
|
import com.silverwrist.dynamo.Namespaces;
|
||||||
import com.silverwrist.dynamo.db.NamespaceCache;
|
import com.silverwrist.dynamo.db.NamespaceCache;
|
||||||
import com.silverwrist.dynamo.db.UserManagement;
|
import com.silverwrist.dynamo.db.UserManagement;
|
||||||
import com.silverwrist.dynamo.event.*;
|
import com.silverwrist.dynamo.event.*;
|
||||||
|
@ -32,6 +33,118 @@ import com.silverwrist.dynamo.util.*;
|
||||||
|
|
||||||
public class UniStoreManager implements NamedObject, ComponentInitialize, ComponentShutdown, UniStore
|
public class UniStoreManager implements NamedObject, ComponentInitialize, ComponentShutdown, UniStore
|
||||||
{
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Internal class for resolving message references
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private class UniStoreResolver implements IndexedObjectResolver
|
||||||
|
{
|
||||||
|
/*====================================================================
|
||||||
|
* Constructor
|
||||||
|
*====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
UniStoreResolver()
|
||||||
|
{ // do nothing
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*====================================================================
|
||||||
|
* Implementations from interface IndexedObjectResolver
|
||||||
|
*====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getResolverTag(Object obj) throws IndexException
|
||||||
|
{
|
||||||
|
if (obj instanceof UniStoreMessage)
|
||||||
|
return String.valueOf(((UniStoreMessage)obj).getMessageID());
|
||||||
|
else if (obj instanceof UniStorePart)
|
||||||
|
return String.valueOf(((UniStorePart)obj).getMessageID());
|
||||||
|
else
|
||||||
|
throw new IndexException(UniStoreManager.class,"UniStoreMessages","resolver.must.be.message");
|
||||||
|
|
||||||
|
} // end getResolverTag
|
||||||
|
|
||||||
|
public Object resolveObject(String tag) throws IndexException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{ // parse tag into longint, get the message
|
||||||
|
return UniStoreManager.this.getMessage(Long.parseLong(tag));
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
|
{ // not a valid number
|
||||||
|
throw new IndexException(UniStoreManager.class,"UniStoreMessages","invalid.tag");
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
catch (DatabaseException de)
|
||||||
|
{ // just translate it straight across
|
||||||
|
throw new IndexException(de);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
} // end resolveObject
|
||||||
|
|
||||||
|
} // end class UniStoreResolver
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Internal class for resolving message part references
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private class UniStorePartResolver implements IndexedObjectResolver
|
||||||
|
{
|
||||||
|
/*====================================================================
|
||||||
|
* Constructor
|
||||||
|
*====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
UniStorePartResolver()
|
||||||
|
{ // do nothing
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*====================================================================
|
||||||
|
* Implementations from interface IndexedObjectResolver
|
||||||
|
*====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getResolverTag(Object obj) throws IndexException
|
||||||
|
{
|
||||||
|
if (obj instanceof UniStoreTextPart)
|
||||||
|
{ // return the message ID and the part namespace and name
|
||||||
|
QualifiedNameKey qname = ((UniStorePart)obj).getPartIdentity();
|
||||||
|
return String.valueOf(((UniStorePart)obj).getMessageID()) + "|" + qname.getNamespace() + "|" + qname.getName();
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
else
|
||||||
|
throw new IndexException(UniStoreManager.class,"UniStoreMessages","resolver.must.be.textpart");
|
||||||
|
|
||||||
|
} // end getResolverTag
|
||||||
|
|
||||||
|
public Object resolveObject(String tag) throws IndexException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{ // break up the tag and resolve it into a UniStoreTextPart
|
||||||
|
String[] bits = StringUtils.split1(tag,'|',3);
|
||||||
|
UniStoreMessage msg = UniStoreManager.this.getMessage(Long.parseLong(bits[0]));
|
||||||
|
return msg.getTextPart(bits[1],bits[2]);
|
||||||
|
|
||||||
|
} // end try
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
|
{ // not a valid number
|
||||||
|
throw new IndexException(UniStoreManager.class,"UniStoreMessages","invalid.tag");
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
catch (DatabaseException de)
|
||||||
|
{ // just translate it straight across
|
||||||
|
throw new IndexException(de);
|
||||||
|
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
} // end resolveObject
|
||||||
|
|
||||||
|
} // end class UniStorePartResolver
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Static data members
|
* Static data members
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
|
@ -57,6 +170,8 @@ public class UniStoreManager implements NamedObject, ComponentInitialize, Compon
|
||||||
private UserManagement m_users; // user management object
|
private UserManagement m_users; // user management object
|
||||||
private PostDynamicUpdate m_post; // dynamic update posting
|
private PostDynamicUpdate m_post; // dynamic update posting
|
||||||
private HardSoftCache m_msgcache; // message cache
|
private HardSoftCache m_msgcache; // message cache
|
||||||
|
private ComponentShutdown m_res1;
|
||||||
|
private ComponentShutdown m_res2;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -158,6 +273,13 @@ public class UniStoreManager implements NamedObject, ComponentInitialize, Compon
|
||||||
m_users = (UserManagement)(GetObjectUtils.getDynamoComponent(services,UserManagement.class,users_name));
|
m_users = (UserManagement)(GetObjectUtils.getDynamoComponent(services,UserManagement.class,users_name));
|
||||||
m_post = (PostDynamicUpdate)(services.queryService(PostDynamicUpdate.class));
|
m_post = (PostDynamicUpdate)(services.queryService(PostDynamicUpdate.class));
|
||||||
|
|
||||||
|
// Register our index resolvers.
|
||||||
|
IndexManagerConfig imcfg = (IndexManagerConfig)(services.queryService(IndexManagerConfig.class));
|
||||||
|
m_res1 = imcfg.registerResolver(Namespaces.DEFAULT_INDEX_RESOLVERS_NAMESPACE,"unistore.message",
|
||||||
|
new UniStoreResolver());
|
||||||
|
m_res2 = imcfg.registerResolver(Namespaces.DEFAULT_INDEX_RESOLVERS_NAMESPACE,"unistore.message.part",
|
||||||
|
new UniStorePartResolver());
|
||||||
|
|
||||||
} // end initialize
|
} // end initialize
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
|
@ -167,6 +289,10 @@ public class UniStoreManager implements NamedObject, ComponentInitialize, Compon
|
||||||
|
|
||||||
public void shutdown()
|
public void shutdown()
|
||||||
{
|
{
|
||||||
|
m_res1.shutdown();
|
||||||
|
m_res1 = null;
|
||||||
|
m_res2.shutdown();
|
||||||
|
m_res2 = null;
|
||||||
m_msgcache.clear();
|
m_msgcache.clear();
|
||||||
m_post = null;
|
m_post = null;
|
||||||
m_srm = null;
|
m_srm = null;
|
||||||
|
|
|
@ -32,3 +32,6 @@ no.deletePart=You are not authorized to delete a part from message #{0} in the U
|
||||||
part.deleted=This part has been deleted.
|
part.deleted=This part has been deleted.
|
||||||
no.deleteMessage=You are not authorized to delete message #{0} in the Universal Message Store.
|
no.deleteMessage=You are not authorized to delete message #{0} in the Universal Message Store.
|
||||||
message.deleted=This message has been deleted.
|
message.deleted=This message has been deleted.
|
||||||
|
resolver.must.be.message=The object passed to the resolver must be a UniStoreMessage.
|
||||||
|
invalid.tag=The message tag passed to the resolver was invalid.
|
||||||
|
resolver.must.be.textpart=The object passed to the resolver must be a UniStoreTextPart.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user