Skip to content

Commit

Permalink
Merge pull request #684 from giastfader/master
Browse files Browse the repository at this point in the history
fixed #604
  • Loading branch information
giastfader committed Feb 22, 2015
2 parents 4017b12 + ce00761 commit 00154b7
Show file tree
Hide file tree
Showing 119 changed files with 1,390 additions and 998 deletions.
2 changes: 0 additions & 2 deletions app/com/baasbox/BBInternalConstants.java
Expand Up @@ -18,8 +18,6 @@

package com.baasbox;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class BBInternalConstants {
public static final String FIELD_AUDIT = "_audit";
Expand Down
8 changes: 4 additions & 4 deletions app/com/baasbox/Global.java
Expand Up @@ -33,7 +33,7 @@
import play.Application;
import play.Configuration;
import play.GlobalSettings;
import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;
import play.Play;
import play.api.mvc.EssentialFilter;
import play.core.j.JavaResultExtractor;
Expand Down Expand Up @@ -311,7 +311,7 @@ public F.Promise<SimpleResult> onBadRequest(RequestHeader request, String error)
result.put("http_code", 400);
SimpleResult resultToReturn = badRequest(result);
try {
if (Logger.isDebugEnabled()) Logger.debug("Global.onBadRequest:\n + result: \n" + result.toString() + "\n --> Body:\n" + result.toString(),"UTF-8");
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Global.onBadRequest:\n + result: \n" + result.toString() + "\n --> Body:\n" + result.toString(),"UTF-8");
}finally{
return F.Promise.pure (resultToReturn);
}
Expand All @@ -325,7 +325,7 @@ public F.Promise<SimpleResult> onHandlerNotFound(RequestHeader request) {
result.put("http_code", 404);
SimpleResult resultToReturn= notFound(result);
try {
if (Logger.isDebugEnabled()) Logger.debug("Global.onBadRequest:\n + result: \n" + result.toString() + "\n --> Body:\n" + new String(JavaResultExtractor.getBody(resultToReturn),"UTF-8"));
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Global.onBadRequest:\n + result: \n" + result.toString() + "\n --> Body:\n" + new String(JavaResultExtractor.getBody(resultToReturn),"UTF-8"));
}finally{
return F.Promise.pure (resultToReturn);
}
Expand All @@ -341,7 +341,7 @@ public F.Promise<SimpleResult> onError(RequestHeader request, Throwable throwabl
error(ExceptionUtils.getFullStackTrace(throwable));
SimpleResult resultToReturn= internalServerError(result);
try {
if (Logger.isDebugEnabled()) Logger.debug("Global.onBadRequest:\n + result: \n" + result.toString() + "\n --> Body:\n" + new String(JavaResultExtractor.getBody(resultToReturn),"UTF-8"));
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Global.onBadRequest:\n + result: \n" + result.toString() + "\n --> Body:\n" + new String(JavaResultExtractor.getBody(resultToReturn),"UTF-8"));
} finally{
return F.Promise.pure (resultToReturn);
}
Expand Down
4 changes: 2 additions & 2 deletions app/com/baasbox/commands/DBResource.java
Expand Up @@ -3,7 +3,7 @@
import java.util.Map;
import java.util.UUID;

import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;

import com.baasbox.commands.exceptions.CommandException;
import com.baasbox.commands.exceptions.CommandExecutionException;
Expand Down Expand Up @@ -88,7 +88,7 @@ private static JsonNode switchUser(JsonNode command,JsonCallback callback) throw
DbHelper.reconnectAsAuthenticatedUser();
}catch(OSecurityAccessException e){
//if the script has changed username or password of the actual user, her credentials are not valid anymore and the db connection is lost
Logger.warn("Database connection is not available inside a Plugin Script");
BaasBoxLogger.warn("Database connection is not available inside a Plugin Script");
//swallow
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/com/baasbox/commands/DocumentsResource.java
Expand Up @@ -45,7 +45,7 @@

import org.apache.commons.lang.exception.ExceptionUtils;

import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -130,7 +130,7 @@ private JsonNode grant(JsonNode command, boolean grant) throws CommandException
alterGrants(command, coll, rid, true, grant);
alterGrants(command, coll, rid, false, grant);
} catch (Exception e){
Logger.error("error",e);
BaasBoxLogger.error("error",e);
throw e;
}
} catch (UserNotFoundException e) {
Expand Down
2 changes: 1 addition & 1 deletion app/com/baasbox/commands/LinksResource.java
Expand Up @@ -27,7 +27,7 @@
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang3.ObjectUtils;

import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;

import com.baasbox.commands.exceptions.CommandException;
import com.baasbox.commands.exceptions.CommandExecutionException;
Expand Down
4 changes: 3 additions & 1 deletion app/com/baasbox/commands/ScriptsResource.java
Expand Up @@ -40,12 +40,14 @@
import java.util.Date;
import java.util.Map;

import org.apache.commons.lang.time.FastDateFormat;

/**
* Created by Andrea Tortorella on 01/07/14.
*/
class ScriptsResource extends Resource {
public static final Resource INSTANCE = new ScriptsResource();
private static SimpleDateFormat SDF = new SimpleDateFormat(BBInternalConstants.DATE_FORMAT_STRING);
private static FastDateFormat SDF = FastDateFormat.getInstance(BBInternalConstants.DATE_FORMAT_STRING);

@Override
public String name() {
Expand Down
12 changes: 6 additions & 6 deletions app/com/baasbox/configuration/Application.java
Expand Up @@ -18,7 +18,7 @@

package com.baasbox.configuration;

import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;

import com.baasbox.configuration.index.IndexApplicationConfiguration;
import com.baasbox.security.ISessionTokenProvider;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void setValue(Object newValue) throws IllegalStateException{
@Override
public void _setValue(Object newValue) {
Object parsedValue=null;
if (Logger.isDebugEnabled()) Logger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (newValue != null)
if (type == Boolean.class)
parsedValue = Boolean.parseBoolean(newValue.toString());
Expand All @@ -92,7 +92,7 @@ else if (type == String.class)
idx = new IndexApplicationConfiguration();
idx.put(key, parsedValue);
} catch (Exception e) {
Logger.error("Could not store key " + key, e);
BaasBoxLogger.error("Could not store key " + key, e);
throw new RuntimeException("Could not store key " + key,e);
}
}
Expand All @@ -108,10 +108,10 @@ public Object _getValue() {
IndexApplicationConfiguration idx;
try {
idx = new IndexApplicationConfiguration();
if (Logger.isDebugEnabled()) Logger.debug("getting "+key+" from index");
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("getting "+key+" from index");
return idx.get(key);
} catch (Exception e) {
Logger.error("Could not retrieve key " + key, e);
BaasBoxLogger.error("Could not retrieve key " + key, e);
}
return null;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ public static String getEnumDescription() {
public void override(Object newValue) {
Object parsedValue=null;

if (Logger.isDebugEnabled()) Logger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (changeCallback != null) changeCallback.change(getValue(), newValue);
if (newValue != null)
if (type == Boolean.class)
Expand Down
8 changes: 4 additions & 4 deletions app/com/baasbox/configuration/ImagesConfiguration.java
Expand Up @@ -25,7 +25,7 @@

import com.baasbox.configuration.index.IndexPasswordRecoveryConfiguration;

import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;

public enum ImagesConfiguration implements IProperties{
IMAGE_ALLOWS_AUTOMATIC_RESIZE("image.allows.automatic.resize", "Enable or disable automatic resizing of images", Boolean.class),
Expand Down Expand Up @@ -105,7 +105,7 @@ else if (type == String.class)
idx = new IndexPasswordRecoveryConfiguration();
idx.put(key, parsedValue);
} catch (Exception e) {
Logger.error("Could not store key " + key, e);
BaasBoxLogger.error("Could not store key " + key, e);
throw new RuntimeException("Could not store key " + key,e);
}
}
Expand All @@ -123,7 +123,7 @@ public Object _getValue() {
idx = new IndexPasswordRecoveryConfiguration();
return idx.get(key);
} catch (Exception e) {
Logger.error("Could not retrieve key " + key, e);
BaasBoxLogger.error("Could not retrieve key " + key, e);
}
return null;
}
Expand Down Expand Up @@ -183,7 +183,7 @@ public static String getEnumDescription() {
public void override(Object newValue) {
Object parsedValue=null;

if (Logger.isDebugEnabled()) Logger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (changeCallback != null) changeCallback.change(getValue(), newValue);
if (newValue != null)
if (type == Boolean.class)
Expand Down
6 changes: 3 additions & 3 deletions app/com/baasbox/configuration/Internal.java
Expand Up @@ -20,7 +20,7 @@

import com.baasbox.configuration.index.IndexInternalConfiguration;

import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;


/***
Expand Down Expand Up @@ -84,7 +84,7 @@ else if (type == String.class)
idx = new IndexInternalConfiguration();
idx.put(key, parsedValue);
} catch (Exception e) {
Logger.error("Could not store key " + key, e);
BaasBoxLogger.error("Could not store key " + key, e);
throw new RuntimeException("Could not store key " + key,e);
}
}
Expand All @@ -102,7 +102,7 @@ public Object _getValue() {
idx = new IndexInternalConfiguration();
return idx.get(key);
} catch (Exception e) {
Logger.error("Could not retrieve key " + key, e);
BaasBoxLogger.error("Could not retrieve key " + key, e);
}
return null;
}
Expand Down
20 changes: 10 additions & 10 deletions app/com/baasbox/configuration/IosCertificateHandler.java
Expand Up @@ -28,7 +28,7 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;
import play.Play;

import com.baasbox.BBConfiguration;
Expand Down Expand Up @@ -61,7 +61,7 @@ public void change(Object iCurrentValue, Object iNewValue) {
try {
currentValue =new ObjectMapper().readValue(iCurrentValue.toString(), ConfigurationFileContainer.class);
} catch (Exception e) {
if (Logger.isDebugEnabled()) Logger.debug("unable to convert value to ConfigurationFileContainer");
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("unable to convert value to ConfigurationFileContainer");
}
}else if (iCurrentValue instanceof ConfigurationFileContainer){
currentValue = (ConfigurationFileContainer)iCurrentValue;
Expand All @@ -73,7 +73,7 @@ public void change(Object iCurrentValue, Object iNewValue) {
try{
FileUtils.forceDelete(oldFile);
}catch(Exception e){
Logger.error(e.getMessage());
BaasBoxLogger.error(e.getMessage());
}
}
}
Expand All @@ -96,7 +96,7 @@ public void change(Object iCurrentValue, Object iNewValue) {
}

}else{
Logger.warn("Ios Certificate Handler invoked with wrong parameters");
BaasBoxLogger.warn("Ios Certificate Handler invoked with wrong parameters");
//TODO:throw an exception?
}

Expand All @@ -120,7 +120,7 @@ public static void init(){
ConfigurationFileContainer sandbox3 = Push.PROFILE3_SANDBOX_IOS_CERTIFICATE.getValueAsFileContainer();

if(prod!=null){
if (Logger.isDebugEnabled()) Logger.debug("Creating production certificate for default profile:"+prod.getName());
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Creating production certificate for default profile:"+prod.getName());
File prodCertificate = new File(folder+sep+prod.getName());
if(!prodCertificate.exists()){
try{
Expand All @@ -135,7 +135,7 @@ public static void init(){
}
}
if(sandbox!=null){
if (Logger.isDebugEnabled()) Logger.debug("Creating sandbox certificate for default profile:"+sandbox.getName());
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Creating sandbox certificate for default profile:"+sandbox.getName());
File sandboxCertificate = new File(folder+sep+sandbox.getName());
if(!sandboxCertificate.exists()){
try{
Expand All @@ -151,7 +151,7 @@ public static void init(){
}

if(prod2!=null){
if (Logger.isDebugEnabled()) Logger.debug("Creating production certificate for profile 2:"+prod2.getName());
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Creating production certificate for profile 2:"+prod2.getName());
File prodCertificate = new File(folder+sep+prod2.getName());
if(!prodCertificate.exists()){
try{
Expand All @@ -166,7 +166,7 @@ public static void init(){
}
}
if(sandbox2!=null){
if (Logger.isDebugEnabled()) Logger.debug("Creating sandbox certificate for profile 2:"+sandbox2.getName());
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Creating sandbox certificate for profile 2:"+sandbox2.getName());
File sandboxCertificate = new File(folder+sep+sandbox2.getName());
if(!sandboxCertificate.exists()){
try{
Expand All @@ -182,7 +182,7 @@ public static void init(){
}

if(prod3!=null){
if (Logger.isDebugEnabled()) Logger.debug("Creating production certificate for profile 3:"+prod3.getName());
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Creating production certificate for profile 3:"+prod3.getName());
File prodCertificate = new File(folder+sep+prod3.getName());
if(!prodCertificate.exists()){
try{
Expand All @@ -197,7 +197,7 @@ public static void init(){
}
}
if(sandbox3!=null){
if (Logger.isDebugEnabled()) Logger.debug("Creating sandbox certificate for profile 3:"+sandbox3.getName());
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("Creating sandbox certificate for profile 3:"+sandbox3.getName());
File sandboxCertificate = new File(folder+sep+sandbox3.getName());
if(!sandboxCertificate.exists()){
try{
Expand Down
10 changes: 5 additions & 5 deletions app/com/baasbox/configuration/PasswordRecovery.java
Expand Up @@ -18,7 +18,7 @@

package com.baasbox.configuration;

import play.Logger;
import com.baasbox.service.logging.BaasBoxLogger;

import org.apache.commons.lang3.BooleanUtils;

Expand Down Expand Up @@ -89,15 +89,15 @@ else if (type == String.class)
else
parsedValue = newValue;
}catch (Exception e){
Logger.warn(newValue + " value is invalid for key " + key + "\nNULL will be stored");
BaasBoxLogger.warn(newValue + " value is invalid for key " + key + "\nNULL will be stored");
}
if (changeCallback != null) changeCallback.change(getValue(), newValue);
IndexPasswordRecoveryConfiguration idx;
try {
idx = new IndexPasswordRecoveryConfiguration();
idx.put(key, parsedValue);
} catch (Exception e) {
Logger.error("Could not store key " + key, e);
BaasBoxLogger.error("Could not store key " + key, e);
throw new RuntimeException("Could not store key " + key,e);
}
}
Expand All @@ -115,7 +115,7 @@ public Object _getValue() {
idx = new IndexPasswordRecoveryConfiguration();
return idx.get(key);
} catch (Exception e) {
Logger.error("Could not retrieve key " + key, e);
BaasBoxLogger.error("Could not retrieve key " + key, e);
}
return null;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ public static String getEnumDescription() {
public void override(Object newValue) {
Object parsedValue=null;

if (Logger.isDebugEnabled()) Logger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (BaasBoxLogger.isDebugEnabled()) BaasBoxLogger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (changeCallback != null) changeCallback.change(getValue(), newValue);
if (newValue != null)
if (type == Boolean.class)
Expand Down

0 comments on commit 00154b7

Please sign in to comment.