*/
@Override
public void storeCode(final AuthorizationCode code) throws OmhException {
// Validate the parameter.
if(code == null) {
throw new OmhException("The code is null.");
}
// Get the authorization code collection.
JacksonDBCollection<AuthorizationCode, Object> collection =
JacksonDBCollection
.wrap(
MongoDao
.getInstance()
.getDb()
.getCollection(DB_NAME),
AuthorizationCode.class);
// Make sure the token doesn't already exist.
if(collection
.count(
new BasicDBObject(
AuthorizationCode.JSON_KEY_CODE,
code.getCode())) > 0) {
throw new OmhException("The token already exists.");
}
// Save it.
collection.insert(code);
}