Reputation: 425
the method getCatalog()
of the wakanda javascript client returns the following error, if no data class array is passed to the method and one of the describe permissions in the model is missing for the current user (this is most likely the case).
Error:
{
"__ERROR": [
{
"message": "No permission to describe the User datastore class",
"componentSignature": "dbmg",
"errCode": 1609
}
]
}
What is considered best practice to use the getCatalog()
method? Is it best to pass the data class needed to the getCatalog()
method on every call made to the server?
Example of angular company service:
@Injectable()
export class CompanyService {
constructor(private wakandaService: WakandaService,
private exceptionService: ExceptionService) {
}
getCompanyList(): any {
return this.wakandaService.getCatalog(['Company'])
.then(data => {
return data.UserProfile.getProfile();
})
.then(data => {
return data;
})
.catch(error => this.exceptionService.error(error));
}
}
UPDATE:
DataModel
Permissions
Role & User data class need "Admin" permissions. UserProfile data class needs "User" permissions and is extended from the User data class.
Error
When logged in as User and call getCatalog(['UserProfile'])
the error "Needed Role dataClass is not present on catalog" is returned. -> Is this correct? Why is the same thing through the REST API working?
http://localhost:8081/rest/$catalog/UserProfile works just fine.
When logged in as User and call getCatalog(['UserProfile', 'Role'])
the error "No permission to describe the Role datastore class" is returned. -> OK
Upvotes: 1
Views: 97
Reputation: 66
Really sorry, I totally missed the fact you had updated your post. Thanks for the update btw, it's now perfectly clear. Well I made a quick solution to try reproducing yr issue. (it's not exactly the same but it helped)
Several points :
DEV
version, when you have an Extended Dataclass and a related Dataclass you have to add in the getCatalog all the dataclasses
In your case it would be :getCatalog(['UserProfile', 'Role', User])
When doing this you are able
wakClient.getCatalog(['UserProfile', 'User', 'Role']).then(function (ds) {
console.log(ds);
ds.UserProfile.query().then(function (result)
{
console.log(result)
}
)
});
And it works
read Permissions
and not describe as we currently have a bug on the describe
permission.
As soon as we have fix it, i'll redo the same test with describe permissions and get back to you asap.Upvotes: 1
Reputation: 66
Not sure yet to have all the details needed to perfectly answer you (not sure about how your model is defined (User, UserProfile..) . But however here's how it works. When passing a Dataclass in the getCatalog() method it retrieves only the specified dataclass.
Attention If your dataclasses are linked (relation <> ) you must add the related dataclasses (the expand is automatically needed )
You should be able to make it work by simply writing return this.wakandaService.getCatalog(['Company', 'User'])
Of course you can also pass an empty array to get the whole catalog
this.wakandaService.getCatalog()
Could you confirm me that it solves your issue ?
Thanks :)
Upvotes: 1