Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some comments and API hardening

  • Loading branch information...
commit e6417ca84a7c02f6063004424c2b00d2371e6513 1 parent bd8b7e6
nka11 nka11 authored
2  README.md
View
@@ -29,7 +29,7 @@ Repository = new nocrMongo.Repository({
// you may use the session object as describes in NoCR API
session.getRootNode(function(err, rootNode) {
rootNode.addNode('myNode', 'nt:undefined', function(err, myNode) {
- myNode.setAttribute("myproperty", "mavaleur", function(err, myProperty){
+ myNode.setProperty("myproperty", "mavaleur", function(err, myProperty){
//do whatever you want with property, or something else.
session.save(); //persist data and indexes in mongodb
});
7 lib/Repository.js
View
@@ -54,7 +54,12 @@ function Repository(config, callback) {
this.getItemsCollection = getItemsCollection;
this.login = function(credentials, workspaceName, callback) {
var
- session = new Session(self,credentials, function(err,sess) {
+ session;
+ if (typeof workspaceName === "function") {
+ callback = workspaceName;
+ }
+ //TODO: implement wsName
+ session = new Session(self,credentials, function(err,sess) {
if (callback !== undefined) {
callback(err, sess);
}
16 lib/Session.js
View
@@ -42,20 +42,25 @@ Session = function(repository, credentials, callback) {
client.collection('repository_users', processUsersCollection);
}
function assignWorkspace() {
+ self.logger.info("assign workspace");
workspaces.find({'name':self.user.workspace}).limit(1).
toArray(function(err, items) {
if (items.length === 0) {
+ self.logger.info("workspace not found");
callback("Error while fetching item", null);
+ } else {
+ self.logger.info("workspace found");
+ new Workspace(self,items[0],function(err, ws) {
+ self.workspace = ws;
+ callback(err,self);
+
+ });
}
- new Workspace(self,items[0],function(err, ws) {
- self.workspace = ws;
- callback(err,self);
-
- });
});
}
function setUserContext(){
self.logger = log4js.getLogger("nocr-mongo.Session." + self.user.username);
+ self.logger.info("setting user workspace");
client.collection('repository.workspaces', function(err, collection) {
workspaces = collection;
workspaces.count(function(err, count) {
@@ -109,6 +114,7 @@ Session = function(repository, credentials, callback) {
* @returns
*/
function validateAuth() {
+
if (credentials === null) {
self.logger.debug('No credentials provided, providing anonymous user');
setAnonymous();
1  lib/types/nodeTypeManager.js
View
@@ -20,6 +20,7 @@ nodeTypeManager = {
}
},
getNodeType: function getNodeType(typeName) {
+ logger.info("getting typedef for " + typeName);
return typesMap[typeName]['typedef'];
},
getMixinNodeTypes: function getMixinNodeTypes(callback) {
Please sign in to comment.
Something went wrong with that request. Please try again.