Request for simple modeshape 3.x/infinispan SQL DB configuration - configuration

I've been trying to get modeshape 3.2 working with a MySQL database and I'm not getting very far. By default everything is in memory which is useless to me.
From what I've pieced together so far it appears I need to configure infinispan to persist the JCR. I've tried adapting various examples I've googled but to no avail.
This is a request for a working/proven configuration as opposed to trying to fix one of the broken configs on the jboss.org site.

As of Modeshape 3.2 you can't use infinispan xml config with simpleConnection due to a bug. But here's how you can do it programmatically...
Modeshape config
{
"name" : "My Repository",
"jndiName" : "",
"monitoring" : {
"enabled" : true
},
"workspaces" : {
"default" : "defaultWorkspace",
"allowCreation" : true
},
"storage" : {
"cacheName" : "myCache",
"binaryStorage" : {
"type" : "database",
"driverClass" : "com.mysql.jdbc.Driver",
"username" : "modeshape",
"password" : "modeshape",
"url" : "jdbc:mysql://127.0.0.1:3306/modeshape?autoReconnect=true"
}
},
"security" : {
"anonymous" : {
"roles" : ["readonly","readwrite","admin"],
"username" : "admin",
"useOnFailedLogin" : true
},
"providers" : []
},
}
Then in your code configure and include infinispan like this...
ConfigurationBuilder builder = new ConfigurationBuilder();
Configuration cacheConfig =
builder
.transaction()
.transactionManagerLookup(new GenericTransactionManagerLookup())
.transactionMode(TransactionMode.TRANSACTIONAL)
.lockingMode(LockingMode.OPTIMISTIC)
.loaders()
.addLoader(JdbcStringBasedCacheStoreConfigurationBuilder.class)
.fetchPersistentState(false)
.ignoreModifications(false)
.purgeOnStartup(false)
.table()
.dropOnExit(false)
.createOnStart(true)
.tableNamePrefix("ISPN_STRING_TABLE")
.idColumnName("ID_COLUMN").idColumnType("VARCHAR(255)")
.dataColumnName("DATA_COLUMN").dataColumnType("BLOB")
.timestampColumnName("TIMESTAMP_COLUMN").timestampColumnType("BIGINT")
.simpleConnection()
.connectionUrl("jdbc:mysql://127.0.0.1:3306/modeshape?autoReconnect=true")
.username("modeshape")
.password("modeshape")
.driverClass("com.mysql.jdbc.Driver").build();
LocalEnvironment environment = new LocalEnvironment();
environment.defineCache("myCache", cacheConfig); // Must match the cacheName property in your modeshape config
String confPath = "<path to modeshape config>";
RepositoryConfiguration repositoryConfiguration = RepositoryConfiguration.read(new File(confPath));
repositoryConfiguration = repositoryConfiguration.with(environment);
ModeShapeEngine engine = new ModeShapeEngine();
engine.start();
repository = engine.deploy(repositoryConfiguration);
Although, it is rather slow.

Related

Extending JSON object definition, not a schema

I am attempting to write a system which configures itself based on a set of JSON configuration files. I have some configuration options which are specific to certain processes but some which are common to all. Is there a way for me to include a common JSON configuration file into more specific ones. ex:
Common.json
# Common example
{
"log-level" : "debug",
"version" : "1.21"
}
Specific.json
# Specific example
# include <common.json> ????
{
"config" : {
"process" : "distro-center"
"id" : "12-3"
"log-path" : "/var/log/blah"
}
}
So the resulting JSON would effectively be
{
"log-level" : "debug",
"version" : "1.21"
"config" : {
"process" : "distro-center"
"id" : "12-3"
"log-path" : "/var/log/blah"
}
}
Ideas?

is it possible to use pm2 to watch and graceful reload?

I have pm2 running my node app, and was wondering if I can make sure it is reloading with zero downtime on the watch, rather than just restarting. Here is a sample json file that is setup how I am using pm2.
{
"name" : "server",
"cwd" : "/home/user/website",
"script" : "server/server.js",
"instances" : 2,
"max_restarts" : 0,
"watch" : true,
"ignore_watch" : ["some/files"],
"env_staging": {
"NODE_ENV": "staging"
},
"env_production": {
"NODE_ENV": "production"
}
}
nope, got the same problem, according to the documentation and source code, this is not possible

Unable to capture JSON response in Vugen using Web http/html

Step Functionality: creation of draft; success status shown by creation of draft id in server response
Call:
web_custom_request("draft",
"URL=https://xxx.yyy.com/__services/v2/rest/draft",
"Method=POST",
"Resource=0",
"RecContentType=text/xml",
"Referer=https://xxx.yyy.com/blog/create-post.jspa?containerType=14&containerID=1",
"Snapshot=t7.inf",
"Mode=HTML",
"EncType=application/json; charset=utf-8",
"Body={\"objectType\":38,\"draftObjectType\":2020,\"draftObjectID\":137742,\"subject\":\"perf test 2\",\"body\":\"<body><p>test data</p></body>\",\"properties\":{\"publishBar\":{\"container\":{\"objectType\":\"37\",\"objectID\":\"90094\"},\"visibility\":\"all\",\"commentStatus\":\"2\",\"blogPublishOption\":false,\"publishDate\":{\"selectedDate\":\"{p_Date}\",\"selectedHour\":\"1\",\"selectedMinute\":\"0\",\"selectedPeriod\":\"AM\"}}}}",
LAST);
Data correlated: draft ID; response of this call
Data parameterized: selectedDate
remaining values are constant
Recording response body:
{
"id" : 2814,
"objectType" : 38,
"draftObjectType" : 2020,
"draftObjectID" : 137742,
"subject" : "perf test",
"body" : "<body><p>this i</p></body>",
"modificationDate" : "2015-10-12T13:44:00.854+0000",
"properties" : {
"publishBar" : {
"container" : {
"objectType" : "37",
"objectID" : "90094"
},
"visibility" : "all",
"commentStatus" : "2",
"blogPublishOption" : false,
"publishDate" : {
"selectedDate" : "10/13/2015",
"selectedHour" : "1",
"selectedMinute" : "0",
"selectedPeriod" : "AM"
}
}
}
}
Error during replay:
{ "code" : 500, "message" :com.sun.istack.SAXException2: class java.util.LinkedHashMap nor any of its super class is known to this context.
javax.xml.bind.JAXBException: class java.util.LinkedHashMap nor any of its super class is known to this context." }
Kindly help.
It's obvious you're not correlating all that needs to be correlated.
Do some re-recordings and see what's different between the responses of each recording.
Without the complete script I can't say for sure, but at least change the following in your request:
"RecContentType=text/xml" to "RecContentType=application/json"
"Mode=HTML" to ""Mode=HTTP"
The 1st sets the expected response content type, and if it's not XML there might be problems. This is assuming the service responds with the correct content-type.
2nd sets the mode to HTTP as REST API responses usually do not need parsing of the content.

This Ember belongsTo relationship is working, but I can't see how

I've been developing an app for about a year now, so I started it mid-2014 and have been upgrading ember.js and ember-cli as things move forward on those projects. I'm at Ember 1.11 now.
EDIT: Application Adapter
var ApplicationAdapter = DS.RESTAdapter.extend( {
namespace: 'api',
host: null,
setHost: Ember.on('init', function() {
set(this, 'host', this.container._registry.resolve('config:environment').API_ENDPOINT);
})
});
export default ApplicationAdapter;
My JSON API returns a main projects object, along with other sideloaded objects (like projectStatus). What I can't understand is, since I don't have any adapters or serializers that specify this, how I'm it's able to use the returned JSON, because it looks like this:
{
"projects" : {
"id": 4462875
"projectName" : "New business from Acme",
"projectDescription" : "Just another great project",
"pmlinks" : [ 1, 2],
"statusLinks" : [ 1440 ],
"commentsLinks" : [ 39 ]
},
"projectResources" : [ {
"id" : 1,
"name" : "Wile E. Coyote"
}, {
"id" : 2,
"name" : "Roadrunner"
}],
"projectComments" : [ {
"id" : 39,
"projectComment" : "started the project",
} ],
"projectStatuses" : [ {
"id" : 1440,
"status" : "G",
"trending" : "N",
"comment" : null,
"lastModifiedDate" : "2015-07-17T13:46:11.037+0000",
"project" : 4462875
} ],
}
I can't find anything in the Ember docs that recommend this "*Links" format for the relationships, and in fact it suggests using something more like status_ids. But the example it shows doesn't use _ids so I'm even more confused.
Here's a snippet of my project model:
statusUpdates: DS.hasMany('projectStatus'),
projectComments: DS.hasMany('projectComment'),
projectResources: DS.hasMany('projectResource'),
What I'm trying to figure out is with my new belongsTo relationship to schedule, how should the JSON be formatted from the API? It seems to work if the project object has a property like this "scheduleLinks": [10] but not if it's like "schedule": 10 or "schedule_id": 10 and that seems to be what the documentation says should work.
EDIT:
Maybe it's because the other objects like projectComments are named the way my model expects, and they're all returned at the same time from one API, that it doesn't even matter what the properties in the projects object is? Is that only to look up relationships if they're not all sideloaded?
The sideloading definitely is the thing here. Because if I change "statusLinks" to "projectStatus" then, since I have that relationship established in the project model, it will try to hit the API for that, e.g. /api/projectstatuses/:id.
So what seems to be happening is that the relationship is being hooked up from the belongsTo side implicitly; if the data is sideloaded, I don't need any links or IDs on the main object.

Mongo find() query with embedded JSON object not returning data

I'm using Mongoose to query Mongo in Node.js, using this command:
var qw = {
'permissions': {'ownerID':req.user._id}
};
landmarkSchema.find(qw, function(err, lm) {
console.log(lm);
});
Where req.user._id = "53baf81408802a00002166b8"
But nothing is returning. I tried the same query in the Mongo terminal.
My data objects are constructed as:
{
"_id" : ObjectId("53bb736dbe211d0000f01837"),
"name" : "and",
"permissions" : {
"ownerID" : "53baf81408802a00002166b8",
"admins" : [ ],
"viewers" : [ ]
},
"__v" : 0
}
I also tried storing the ownerID as a Mongo ObjectID, i.e. ObjectId("53baf81408802a00002166b8") but that didn't seem to work either.
Use dot notation:
var qw = {
'permissions.ownerID': req.user._id
};
As written, your query above is searching for a document where the permissions property exactly matches your object, meaning it only has an ownerID property with that value but no other properties.