mn8 Language Reference | Index    

DSClient

SUMMARY: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

To administer the database with remote control, DataStore use some special XML blocks ( otherwise modified SEP store and fetch command ) in each administer program.
Have a lot of methods for :

Usage

            $ds = DSClient.create()
            #login to XMLDB named database with username and passwd
            if $ds.login("XMLDB", "username", "passwd") then [
                #create test2 subtree on root subtree and list the root subtree
                $resp = $ds.makeSubtree("test2")
                if $resp.hasAdditional then [
                    if $resp.hasInfo then [
                        print $resp/additional/info.toXML] else [
                        if $resp.hasWarning then [
                            print $resp/additional/warning.toXML]]]
                if $resp.hasError then [
                    print $resp/error.toXML]
                if $resp.hasBlock then [       print $resp/block.toXML]

                $resp = $ds.list("/")
                if $resp.hasAdditional then [
                    if $resp.hasInfo then [
                        print $resp/additional/info.toXML] else [
                        if $resp.hasWarning then [
                            print $resp/additional/warning.toXML]]]
                if $resp.hasError then [
                    print $resp/error.toXML]
                if $resp.hasBlock then [
                    print $resp/block.toXML]

                #remove test2 subtree recursively and list the root subtree
                $resp = $ds.removeSubtree("test2",true)
                if $resp.hasAdditional then [
                    if $resp.hasInfo then [
                        print $resp/additional/info.toXML] else [
                        if $resp.hasWarning then [
                            print $resp/additional/warning.toXML]]]
                if $resp.hasError then [
                    print $resp/error.toXML]

                if $resp.hasBlock then [
                    print $resp/block.toXML]

                #search the documents in the test subtree that contains the specified value
                #in the specified path
                $resp = $ds.fetch("test","person/name@first","Antal")
                if $resp.hasAdditional then [
                    if $resp.hasInfo then [
                        print $resp/additional/info.toXML] else [
                        if $resp.hasWarning then [
                            print $resp/additional/warning.toXML]]]
                if $resp.hasError then [
                    print $resp/error.toXML]
                if $resp.hasBlock then [
                    print $resp/block.toXML]] else [
                print "Connection failed !!!"]

Version: 0.1
Authors:Szabo Csaba ()
Location:
Inherits: Concept

Constructor List

create (String $host)
create (String $host, String $port)
create
top

Method List

DSResponseaddGroup (String $group)
DSResponseaddUser (String $username, String $password, String $home, String $group, String $groups)
DSResponseblockUser (String $username)
DSResponsechangeStoreType (String $subtree, String $mode, Logical $recursive)
DSResponsesetNamingFlag (String $subtree, String $naming, Logical $recursive)
DSResponsechmod (String $mode, String $subtree, Logical $recursive)
DSResponsechown (String $owner, String $subtree, Logical $recursive)
DSResponsecopy (String $src, String $dest, Logical $recursive)
DSResponsedelGroup (String $gname)
DSResponsedelUser (String $name)
DSResponsefetch (String $subtree, String $path, String $value)
DSResponselist (String $subtree)
DSResponselistGroup (String $group, String $user)
DSResponselistUser (String $name)
Logicallogin (String $dbName)
Logicallogin (String $dbName, String $userName, String $password)
Logicallogout
DSResponsemakeSubtree (String $subtree)
DSResponsemodGroup (String $oldName, String $newName)
DSResponsemodUser (String $oldName, String $newName, String $password, String $home, String $group, String $groups)
DSResponsemove (String $src, String $dest)
DSResponseremoveSubtree (String $subtree, Logical $force)
DSResponsestore (String $action, String $path, String  $block)
DSResponseunblockUser (String $userName)
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI

Detailed Constructor Info

create (String $host)
Parameters:
$host :The host name to be connected.

Constructs a new DSClient with the given host name on the default port.

top
create (String $host, String $port)
Parameters:
$host :The host name to be connected.
$port :The port to be connected.

Constructs a new DSClient with the given host name and port.

top
create

Constructs a new DSClient with the default host name on the default port.

top

Detailed Method Info

addGroup (String $group)
Parameters:
$group :The group name to add.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
Unable to execute the SEP command.

Adds the specified group to the specified database.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.addGroup("friends")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              The group has been added.
            error
            block
            

top
addUser (String $username, String $password, String $home, String $group, String $groups)
Parameters:
$username :The user's name.
$password :The user's password.
$home :The user's home directory.
$group :

The group name of the user's initial login group. If the group name not exist, then a new group will be created with the given name.

$groups :

A list of supplementary groups which the user is also a member of. each group is separated from the next by a comma, with no intervening whitespace.

Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Adds the specified user to the specified database.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.addUser("John", "Johnpwd", "", "friends", "")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              The user has been added.
            error
            block
            

top
blockUser (String $username)
Parameters:
$username :The user's name to block.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Blocks the specified user. After this command the user can't log in until he is not unblocked.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.blockUser("John")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              The user has been blocked.
            error
            block
            

top
changeStoreType (String $subtree, String $mode, Logical $recursive)
Parameters:
$subtree :The subtree which mode will be changed.
$mode :The store mode. (strict/flexible/free/free_tag)
$recursive :If true change recursivelly.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Change subtree store mode.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.changeStoreType("/root/test", "free", TRUE)
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              '/root/test' subtree are converted to 'free' mode.
            error
            block
            

top
setNamingFlag (String $subtree, String $naming, Logical $recursive)
Parameters:
$subtree :The subtree which naming flag will be changed.
$naming :The naming flag. (auto/manual)
$recursive :If true change recursivelly.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Set subtree naming flag.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.setNamingFlag("/root/test", "manual", TRUE)
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              '/root/test' subtree naming flag is set to 'manual'.
            error
            block
            

top
chmod (String $mode, String $subtree, Logical $recursive)
Parameters:
$mode :The permission mode.
$subtree :The subtree which mode will be changed.
$recursive :If true change recursivelly.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Change acces permissions for subtrees and documents.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.chmod("a+rw", "/docs/txt", TRUE)
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              Chmod command has been executed.
            error
            block
            

top
chown (String $owner, String $subtree, Logical $recursive)
Parameters:
$owner :The owner of document.
$subtree :The subtree which owner will be changed.
$recursive :If true change recursivelly.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Change owner.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.chown("John", "/docs/txt", TRUE)
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              Chown command has been executed.
            error
            block
            

top
copy (String $src, String $dest, Logical $recursive)
Parameters:
$src :The subtree which will be copied.
$dest :The target subtree name.
$recursive :If true copy subtrees recursivelly.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Copy the subtree given as $src to the target subtree given as $dest.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.copy("/root/test", "/root/sbtree", TRUE)
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              1 file(s) copied to  '/root/sbtree'.
            error
            block
            

top
delGroup (String $gname)
Parameters:
$gname :The group name which you want to delete.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Deletes the specified group.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.delGroup("friends")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              The group has been deleted.
            error
            block
            

top
delUser (String $name)
Parameters:
$name :The user name which you want to delete.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Deletes the specified user.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.delUser("John")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              The user has been deleted.
            error
            block
            

top
fetch (String $subtree, String $path, String $value)
Parameters:
$subtree :The subtree where the value will be searched.
$path :

Relative path in the XML document to the searched value. If the path is not specified then the value will be searched in the whole document.

$value :

The value to be searched. If the value is missing then you can't specify a path. In this case all documents in the given subtree will be returned recursively.

Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
Unable to execute the SEP command.

Returns the XML document if in the subtree was specified the path to the document else returns the document names where the specified value was found.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.fetch("/root/test", "", "this")
            print $ds.fetch("/root/test", "", "")
            -- the result is --
            DSResponse
            additional
            block
              name: /root/test/1
            error

            DSResponse
            additional
            error
            block
              testdoc
              I want to write this into the database.
            

top
list (String $subtree)
Parameters:
$subtree :The subtree name to be listed.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Lists the specified subtree.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.list("/root/test")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              -rwr---  root  root  2002-07-23 22:47:03  /root/test/1
            error
            block
            

top
listGroup (String $group, String $user)
Parameters:
$group :The group name to list.
$user :The user's groups to list.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

If the group name is given then returns all users in that group, else if the user name is given then returns the group names in which the user is in, if both is missing then returns all groups name.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.listGroup("friends", "")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              List of specified group users: John
            error
            block
            

top
listUser (String $name)
Parameters:
$name :The user's name which data will be listed.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Lists the specified user's data or if there is no username specified then list all users name.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.listUser("John")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              Username : John
              Home subtree : 
              Groups : friends, 
              Status : 
            error
            block
            

top
login (String $dbName)
Parameters:
$dbName :The database name to connenct.
Returns: Logical
Exceptions:
connectionException :
(Error)
If unable to login to the DataStore server.

Connects to the specified database.

            $ds = DSClient.create
            print $ds.login("DBName")
            -- the result is --
            true
            

top
login (String $dbName, String $userName, String $password)
Parameters:
$dbName :The database name to connenct.
$userName :The user name.
$password :The user's password.
Returns: Logical
Exceptions:
connectionException :
(Error)
If unable to login to the DataStore server.

Connects to the specified database with the given user name and password.

            $ds = DSClient.create
            print $ds.login("DBName", "root", "root_pass")
            -- the result is --
            true
            

top
logout
Returns: Logical
Exceptions:
connectionException :
(Error)
If unable to logout from the DataStore server.

Disconnects from DataStore server.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.logout
            -- the result is --
            true
            

top
makeSubtree (String $subtree)
Parameters:
$subtree :The absolute path to the subtree with the subtree name to create.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Creates a new subtree with the given path and name.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.makeSubtree("/root/test")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              /root/test subtree has been created.
            error
            block
            

top
modGroup (String $oldName, String $newName)
Parameters:
$oldName :The group name to change.
$newName :The new name of the group.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Modifies a group name from the oldName to the newName.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.modGroup("friends", "buddies")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              The group has been updated.
            error
            block
            

top
modUser (String $oldName, String $newName, String $password, String $home, String $group, String $groups)
Parameters:
$oldName :The user name whom data will be modified.
$newName : The new user name if you want to change it, if not leave this empty.
$password :

The new password for the user if you want to change it, if not leave this empty.

$home :

The new home for the user if you want to change it, if not leave this empty.

$group :

The new group for the user if you want to change it, if not leave this empty.

$groups :

The new groups for the user if you want to change it, if not leave this empty.

Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Modify existing user dates.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.modUser("John", "Chris", "chrispass", "", "buddies", "")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              The user has been updated.
            error
            block
            

top
move (String $src, String $dest)
Parameters:
$src :The subtree which will be moved.
$dest :The target subtree name.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Moves the subtree given as $src to the target subtree given as $dest.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.move("/root/sbtree", "/root/test")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              
            error
            block
            

top
removeSubtree (String $subtree, Logical $force)
Parameters:
$subtree :The subtree name which will be removed.
$force :If true removes the nonempty subtrees too.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Removes the specified subtree.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.removeSubtree("/root/sbtree", TRUE)
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              /root/sbtree subtree(document) has been removed.
            error
            block
            

top
store (String $action, String $path, String  $block)
Parameters:
$action :The store action, can be write, update or delete.
$path :

If the action is update or delete this must be contain the document name and subtree, else only the subtree.

$block :

If the action is write or update this will be the document which will be stored or with which will be overwrite the specified subtree in the $path. If the action is delete leave this empty.

Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Executes the specified action to the given $path.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            $xml = "<testdoc><text>I want to write this into the database.</text></testdoc>"
            print $ds.("write", "/root/test", $xml)
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              write action has been executed.
            error
            block
            

top
unblockUser (String $userName)
Parameters:
$userName :The user's name to unblock.
Returns: DSResponse
Exceptions:
executeSEPException :
(Error)
If unable to execute the SEP command.

Unblocks the specified user. After this command the user can log in again.

            $ds = DSClient.create
            $ds.login("DBName", "root", "root_pass")
            print $ds.unblockUser("John")
            -- the result is --
            DSResponse
            additional
            info
              code: 0
              The user has been unblocked.
            error
            block
            

top