com.apelon.dts.client.namespace
Class NamespaceQuery

java.lang.Object
  extended by com.apelon.apelonserver.client.BasicQuery
      extended by com.apelon.dts.client.namespace.NamespaceQuery

public abstract class NamespaceQuery
extends BasicQuery

A NamespaceQuery provides common methods for using namespaces.

The following events are fired in this class:

If you have two instances of NamespaceQuery and you would like to share the listeners between them, then you can code something like this.
 NamespaceQuery nq1 = null;
 NamespaceQuery nq2 = null;

 // Initialization code for nq1 and nq2

 nq2.addNamespaceListener(nq1.getNamespaceListener());
 nq2.addKBTypeListener(nq1.getKBTypeListener());
 // Now any event from nq2 will be available to nq1 listeners
 

Copyright: Copyright (c) 2003

Company: Apelon, Inc.

Since:
DTS 3.0
Version:
DTS 3.0
Author:
Apelon, Inc.

Field Summary
protected  KBTypeListener kbtypeListener
           
protected  NamespaceListener namespaceListener
           
 
Fields inherited from class com.apelon.apelonserver.client.BasicQuery
ADMIN, queryHeader
 
Constructor Summary
NamespaceQuery()
           
 
Method Summary
 boolean addAuthority(Authority authority)
          Adds an Authority to the DTS knowledgebase by sending a query to the server.
 void addKBTypeListener(KBTypeListener listener)
           
 boolean addNamespace(Namespace namespace)
          Adds a Namespace to the DTS knowledgebase by sending a query to the DTS server.
 void addNamespaceListener(NamespaceListener listener)
           
static NamespaceQuery createInstance(ServerConnection sc)
          Creates an instance of NamespaceQuery.
static NamespaceQuery createInstance(ServerConnection sc, boolean isValidating)
          Creates an instance of NamespaceQuery.
 boolean deleteAuthority(Authority authority)
           
 boolean deleteAuthorityByDescription(String authorityDescription)
          Deletes the Authority with the specified description from the DTS knowledgebase by sending a query to the server.
 boolean deleteAuthorityById(int authorityId)
          Deletes the Authority with the specified ID from the DTS knowledgebase by sending a query to the server.
 boolean deleteNamespaceByCode(String namespaceCode)
          Deletes the Namespace with the specified code from the DTS knowledgebase by sending a query to the server.
 boolean deleteNamespaceById(int namespaceId)
          Deletes the Namespace with the specified ID from the DTS knowledgebase by sending a query to the server.
 boolean deleteNamespaceByName(String namespaceName)
          Deletes the Namespace with the specified name from the DTS knowledgebase by sending a query to the server.
 Namespace findNamespaceByCode(String namespaceCode)
          Gets a Namespace object by passing the namespace code.
 Namespace findNamespaceById(int namespaceId)
          Gets a Namespace object by passing the namespace ID.
 Namespace findNamespaceByName(String namespaceName)
          Gets a Namespace object by passing the namespace name.
protected  void fireAuthorityAction(KBTypeEvent event)
           
protected  void fireNamespaceAction(NamespaceEvent event)
           
 Authority[] getAuthorities()
          Retrieves an array of Authoritys which represent the available namespace authorities in the DTS knowledgebase.
static Namespace getDefaultNamespace()
          Returns the Namespace that's been set as the default.
static int getDefaultNamespaceId()
          Return default namespace ID, if available.
 Namespace[] getExtendingNamespaces(int subsNamespaceId)
          Gets an array of Ontylog Extension Namespaces which the given subscription namespace extends
 KBTypeListener getKBTypeListener()
          Get the KBTypeListener.
 NamespaceListener getNamespaceListener()
          Get the NamespaceListener.
 Namespace[] getNamespaces()
          Retrieves an array of Namespaces which represent the available namespaces in the knowledgebase.
 ContentVersion[] getVersions(int namespaceId)
          Retrieves an array of ContentVersions which are the list of versions for the given namespace Id in the knowledgebase.
 boolean hasPermission(int namespaceId)
          Determine whether the currently logged on user has permission to write to the specified namespace.
 void removeKBTypeListener(KBTypeListener listener)
           
 void removeNamespaceListener(NamespaceListener listener)
           
 void setDefaultNamespace()
          Sets the Namespace to be used as the default Namespace in the system, if it can be determined by the system.
static void setDefaultNamespace(Namespace namespace)
          Sets the Namespace to be used as the default Namespace in the system.
 boolean updateNamespace(Namespace oldNamespace, Namespace newNamespace)
          Updates an existing Namespace in the DTS knowledgebase with the values specified in a new one.
 boolean updateNamespaceAuthority(Namespace namespace, Authority newNamespaceAuthority)
          Deprecated. Use updateNamespace(Namespace oldNamespace, Namespace newNamespace) instead.
 boolean updateNamespaceType(Namespace namespace, NamespaceType namespaceType)
          Deprecated. Use updateNamespace(Namespace oldNamespace, Namespace newNamespace) instead.
 boolean updateNamespaceWritability(Namespace namespace, boolean isWritable)
          Deprecated. Use updateNamespace(Namespace oldNamespace, Namespace newNamespace) instead.
 
Methods inherited from class com.apelon.apelonserver.client.BasicQuery
executeQuery, executeQueryNoParse, getServerConnection, initializeDtds, initializeDtds, ping, setVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kbtypeListener

protected transient KBTypeListener kbtypeListener

namespaceListener

protected transient NamespaceListener namespaceListener
Constructor Detail

NamespaceQuery

public NamespaceQuery()
Method Detail

createInstance

public static NamespaceQuery createInstance(ServerConnection sc)
                                     throws IllegalArgumentException
Creates an instance of NamespaceQuery. Depending on the type of ServerConnection object passed in the argument, the server may be local(JDBC), socket, or another implementation.

Parameters:
sc - the type of server connection
Returns:
the created NamespaceQuery
Throws:
IllegalArgumentException - if a null server connection is passed
See Also:
ServerConnectionJDBC, ServerConnectionSocket

createInstance

public static NamespaceQuery createInstance(ServerConnection sc,
                                            boolean isValidating)
                                     throws IllegalArgumentException
Creates an instance of NamespaceQuery. Depending on the type of ServerConnection object passed in the argument, the server may be local(JDBC), socket, or another implementation. The second argument is a boolean value for XML validation.

Parameters:
sc - the type of server connection
isValidating - a boolean value. It is true if XML needs to be validated, otherwise it is false.
Returns:
the created NamespaceQuery
Throws:
IllegalArgumentException - if a null server connection is passed
See Also:
ServerConnectionJDBC, ServerConnectionSocket

addNamespace

public boolean addNamespace(Namespace namespace)
                     throws DTSException
Adds a Namespace to the DTS knowledgebase by sending a query to the DTS server. The id of the namespace must be equal to or greater than Namespace.LOCAL_NAMESPACE_ID_THRESHOLD and equal to or less than Namespace.MAXIMUM_NAMESPACE_ID (i.e., 32678 <= id <= 65535 ).

Parameters:
namespace - the Namespace to add
Returns:
a boolean indicating the success of the add
Throws:
DTSException - if any error occurs in the method

deleteNamespaceByName

public boolean deleteNamespaceByName(String namespaceName)
                              throws DTSException
Deletes the Namespace with the specified name from the DTS knowledgebase by sending a query to the server.

Parameters:
namespaceName - name of Namespace to be deleted
Returns:
boolean indicator of success of deletion
Throws:
DTSException - if any error occurs in the method

deleteNamespaceByCode

public boolean deleteNamespaceByCode(String namespaceCode)
                              throws DTSException
Deletes the Namespace with the specified code from the DTS knowledgebase by sending a query to the server.

Parameters:
namespaceCode - code of Namespace to be deleted
Returns:
boolean indicator of success of deletion
Throws:
DTSException - if any error occurs in the method

deleteNamespaceById

public boolean deleteNamespaceById(int namespaceId)
                            throws DTSException
Deletes the Namespace with the specified ID from the DTS knowledgebase by sending a query to the server.

Parameters:
namespaceId - ID of Namespace to be deleted
Returns:
boolean indicator of success of deletion
Throws:
DTSException - if any error occurs in the method

findNamespaceByName

public Namespace findNamespaceByName(String namespaceName)
                              throws DTSException
Gets a Namespace object by passing the namespace name.

Parameters:
namespaceName - the namespace name
Returns:
a Namespace object corresponding to the specified namespace name
Throws:
DTSException - if any error occurs in the method

findNamespaceById

public Namespace findNamespaceById(int namespaceId)
                            throws DTSException
Gets a Namespace object by passing the namespace ID.

Parameters:
namespaceId - the namespace ID
Returns:
a Namespace object corresponding to the specified namespace ID
Throws:
DTSException - if any error occurs in the method

findNamespaceByCode

public Namespace findNamespaceByCode(String namespaceCode)
                              throws DTSException
Gets a Namespace object by passing the namespace code.

Parameters:
namespaceCode - the namespace code
Returns:
a Namespace object corresponding to the specified namespace Code
Throws:
DTSException - if any error occurs in the method

updateNamespace

public boolean updateNamespace(Namespace oldNamespace,
                               Namespace newNamespace)
                        throws DTSException
Updates an existing Namespace in the DTS knowledgebase with the values specified in a new one. Updating the name, code, Authority, NamespaceType, and writability is allowed, Updating the namespaced ID is not.

Parameters:
oldNamespace - the Namespace to be updated
newNamespace - the Namespace object containing the new values
Returns:
boolean indicator of the success of the update
Throws:
DTSException - if any error occurs in the method

updateNamespaceType

public boolean updateNamespaceType(Namespace namespace,
                                   NamespaceType namespaceType)
                            throws DTSException
Deprecated. Use updateNamespace(Namespace oldNamespace, Namespace newNamespace) instead.

Updates the namespace type of the passed Namespace in the DTS knowledgebase.

Parameters:
namespace - the Namespace to be updated
namespaceType - the NamespaceType of the namespace
Returns:
boolean indicator of the success of the update
Throws:
DTSException - if any error occurs in the method

updateNamespaceWritability

public boolean updateNamespaceWritability(Namespace namespace,
                                          boolean isWritable)
                                   throws DTSException
Deprecated. Use updateNamespace(Namespace oldNamespace, Namespace newNamespace) instead.

Updates the namespace writability of the passed Namespace in the DTS knowledgebase.

Parameters:
namespace - the Namespace to be updated
isWritable - the new namespace access: 'T' - read/write, 'F' - read only
Returns:
boolean indicator of the success of the update
Throws:
DTSException - if any error occurs in the method

updateNamespaceAuthority

public boolean updateNamespaceAuthority(Namespace namespace,
                                        Authority newNamespaceAuthority)
                                 throws DTSException
Deprecated. Use updateNamespace(Namespace oldNamespace, Namespace newNamespace) instead.

Updates the namespace Authority of the passed Namespace in the DTS knowledgebase.

Parameters:
namespace - the Namespace to be updated
newNamespaceAuthority - the new namespace authority
Returns:
boolean indicator of the success of the update
Throws:
DTSException - if any error occurs in the method

getNamespaces

public Namespace[] getNamespaces()
                          throws DTSException
Retrieves an array of Namespaces which represent the available namespaces in the knowledgebase.

Returns:
the namespaces in the knowledgebase
Throws:
DTSException - if any error occurs in the method

getVersions

public ContentVersion[] getVersions(int namespaceId)
                             throws DTSException
Retrieves an array of ContentVersions which are the list of versions for the given namespace Id in the knowledgebase.

Parameters:
namespaceId - the namespace ID
Returns:
the ContentVersions of the given namespace
Throws:
DTSException - if unable to retrieve any versions

addAuthority

public boolean addAuthority(Authority authority)
                     throws DTSException
Adds an Authority to the DTS knowledgebase by sending a query to the server.

Parameters:
authority - the Authority to add
Returns:
a boolean indicating the success of the add
Throws:
DTSException - if any error occurs in the method

deleteAuthority

public boolean deleteAuthority(Authority authority)
                        throws DTSException
Throws:
DTSException

deleteAuthorityByDescription

public boolean deleteAuthorityByDescription(String authorityDescription)
                                     throws DTSException
Deletes the Authority with the specified description from the DTS knowledgebase by sending a query to the server. Note: this method doesn't fire AuthorityEvent.

Parameters:
authorityDescription - description of Authority to be deleted
Returns:
boolean indicator of success of deletion
Throws:
DTSException - if any error occurs in the method

deleteAuthorityById

public boolean deleteAuthorityById(int authorityId)
                            throws DTSException
Deletes the Authority with the specified ID from the DTS knowledgebase by sending a query to the server. Note: this method doesn't fire AuthorityEvent.

Parameters:
authorityId - ID of Authority to be deleted
Returns:
boolean indicator of success of deletion
Throws:
DTSException - if any error occurs in the method

getAuthorities

public Authority[] getAuthorities()
                           throws DTSException
Retrieves an array of Authoritys which represent the available namespace authorities in the DTS knowledgebase.

Returns:
the available namespace authorities
Throws:
DTSException - if any error occurs in the method

getDefaultNamespace

public static Namespace getDefaultNamespace()
                                     throws DTSException
Returns the Namespace that's been set as the default.

Returns:
the currently set default namespace
Throws:
DTSException - if the default namespace has not been set

getDefaultNamespaceId

public static int getDefaultNamespaceId()
Return default namespace ID, if available.

Returns:
the default namespace ID, if available. Returns -1 if the default namespace has not been set.

setDefaultNamespace

public static void setDefaultNamespace(Namespace namespace)
Sets the Namespace to be used as the default Namespace in the system. This needs to be done at least once before getDefaultNamespace() can be called. The default Namespace can be changed as many times as necessary.

Parameters:
namespace - the Namespace to be used as the default in API methods where it's not explicitly specified

setDefaultNamespace

public void setDefaultNamespace()
                         throws DTSException
Sets the Namespace to be used as the default Namespace in the system, if it can be determined by the system. This is possible if it has already been set by setDefaultNamespace(Namespace namespace), or if there is only one namespace.

Throws:
DTSException - if any error occurs in the method

hasPermission

public boolean hasPermission(int namespaceId)
                      throws DTSException
Determine whether the currently logged on user has permission to write to the specified namespace. This is only effective if the application connects to the server using a secure socket connection.

Parameters:
namespaceId - the ID of the namespace to check for permission
Returns:
true if using a secure socket connection and the currently logged on user has permission to write to this namespace, or if using any other type of server connection; otherwise false
Throws:
DTSException - if any error occurs in the method

getExtendingNamespaces

public Namespace[] getExtendingNamespaces(int subsNamespaceId)
                                   throws DTSException
Gets an array of Ontylog Extension Namespaces which the given subscription namespace extends

Parameters:
subsNamespaceId - The Subscription Namespace id
Returns:
an array of Ontylog Extension Namespace Ids which are extended by above subscription namespace
Throws:
DTSException - for any other error
Since:
DTS 3.3

fireAuthorityAction

protected void fireAuthorityAction(KBTypeEvent event)

getKBTypeListener

public KBTypeListener getKBTypeListener()
Get the KBTypeListener. This can be used to link the chain of kbtype listeners of this class to kbtype listener of another instance of NamespaceQuery.

Returns:
KBTypeListener

addKBTypeListener

public void addKBTypeListener(KBTypeListener listener)

removeKBTypeListener

public void removeKBTypeListener(KBTypeListener listener)

fireNamespaceAction

protected void fireNamespaceAction(NamespaceEvent event)

getNamespaceListener

public NamespaceListener getNamespaceListener()
Get the NamespaceListener. This can be used to link the chain of namespace listeners of this class to namespace listener of another instance of NamespaceQuery.

Returns:
NamespaceListener

addNamespaceListener

public void addNamespaceListener(NamespaceListener listener)

removeNamespaceListener

public void removeNamespaceListener(NamespaceListener listener)


Copyright © 2011. All Rights Reserved.