Hi Zhang,

In the portal : System/Security/Roles you can create your own role like "myUserRole".

When created you have in the role definition a tab "Sql Tables".

In this tab you can add the tables which the role can access.

If you assign the created role to a user, he can access the tables.

hardcopy of the Sql Tables Tab in System/Security/Roles (in french)

Thanks Julius,

It was exactly what i needed. My goal was to copy properties from a dynamic object to a persistent object, but in dynamic object for reference, I have only id, not a ref.

So i made this : (main class)

Class Bna.Utils.DynToPersistent Extends %RegisteredObject
{

Property DynObject As %Library.DynamicObject;

Property PersistentObject;

Method %OnNew(dynObject As %Library.DynamicObject, persistentObject) As %Status
{
    Set ..DynObject = dynObject
    Set ..PersistentObject = persistentObject
    Return $$$OK
}

Method copyDynToPersistent()
{
    set pClass = ..PersistentObject.%ClassName(1)
    Set iterator = ..DynObject.%GetIterator()
    while iterator.%GetNext(.pProp, .pValue) {
        Set pType = ##class(Bna.Utils.Common).GetPersistentObjectPropertyType(pClass,pProp)
        Set isRef = ##class(Bna.Utils.Common).PersistentObjectPropertyTypeIsReference(pType)
        if isRef {
            set value = $ZOBJCLASSMETHOD(pType, "%OpenId", pValue)
        } else {
            set value = pValue
        }
        Set $ZOBJPROPERTY(..PersistentObject, pProp) = value
    }
}

}

(utility methods) :


ClassMethod GetPersistentObjectPropertyType(pClass As %String, pKey As %String) As %String
{
	set def=##class(%Dictionary.PropertyDefinition).%OpenId(pClass_"||"_pKey)
	if def Return def.Type
}

ClassMethod PersistentObjectPropertyTypeIsReference(pType) As %Boolean
{
	if $EXTRACT(pType,1,1) = "%" { Return 0 }
	else { Return 1 }
}

 I think my test for reference detection can be light, but enough in my context

Hi Ashok,

Thanks for your reply, overriding OnPreDispatch Method doesn't not work with login, refresh, logout (special routes) but with my own routes it's work. So It's not a solution for me

This the beginning of my class which extends %CSP.REST,  I missed something ?

Class Bna.Api.Bna2024 Extends %CSP.REST
{
Parameter HandleCorsRequest = 1;
Parameter CHARSET = "UTF-8";
Parameter CONTENTTYPE = "application/json";
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
    <Route Url="/lists" Method="GET" Call="GetLists" />
    <Route Url="/me" Method="GET" Call="GetUserInformations" />
    <Route Url="/reset-password" Method="POST" Call="ResetUtilisateurPassword" />
    <Route Url="/utilisateurs" Method="GET" Call="GetUtilisateur" />
    <Route Url="/utilisateurs" Method="POST" Call="CreateUtilisateur" />
    <Route Url="/utilisateurs" Method="PATCH" Call="ModifyUtilisateur" />
    <Route Url="/utilisateurs" Method="DELETE" Call="DeleteUtilisateur" />
</Routes>
}
ClassMethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue As %Boolean) As %Status
{
    Set ^Pierre("login")="on login (by overrided method pre dispatch)"
    return $$$OK
}
...

Thanks Eduard,

That's my first try  (doesn't work, global ^Pierre not set with login)

It seems that method in my class doesn't override the methods on %CSP/REST.

This the beginning of my class which extends %CSP.REST, Do I miss something ?

Class Bna.Api.Bna2024 Extends %CSP.REST
{
Parameter HandleCorsRequest = 1;
Parameter CHARSET = "UTF-8";
Parameter CONTENTTYPE = "application/json";
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
    <Route Url="/lists" Method="GET" Call="GetLists" />
    <Route Url="/me" Method="GET" Call="GetUserInformations" />
    <Route Url="/reset-password" Method="POST" Call="ResetUtilisateurPassword" />
    <Route Url="/utilisateurs" Method="GET" Call="GetUtilisateur" />
    <Route Url="/utilisateurs" Method="POST" Call="CreateUtilisateur" />
    <Route Url="/utilisateurs" Method="PATCH" Call="ModifyUtilisateur" />
    <Route Url="/utilisateurs" Method="DELETE" Call="DeleteUtilisateur" />
</Routes>
}

ClassMethod Login(skipheader As %Boolean = 1) As %Status [ ProcedureBlock = 0 ]
{
    Set ^Pierre("login")="on login (by overrided Login method)"
    Return ##super(skipheader)
}
...