Skip to content

Commit

Permalink
reformatting code
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurizio Turatti committed Dec 17, 2014
1 parent 1ffa7e6 commit 64f0098
Show file tree
Hide file tree
Showing 92 changed files with 350 additions and 353 deletions.
9 changes: 5 additions & 4 deletions src/main/java/com/softinstigate/restheart/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @author Andrea Di Cesare
*/
public class Configuration {

/**
* the restheart version
*/
Expand All @@ -46,7 +47,7 @@ public class Configuration {
* URL pointing to the online documentation specific for this version.
*/
public static final String RESTHEART_ONLINE_DOC_URL = "http://www.restheart.org/docs/v0.9";

private static final Logger LOGGER = LoggerFactory.getLogger(Configuration.class);

private final boolean httpsListener;
Expand Down Expand Up @@ -141,12 +142,12 @@ public class Configuration {
* default am implementation class.
*/
public static final String DEFAULT_AM_IMPLEMENTATION_CLASS = "com.softinstigate.restheart.security.impl.SimpleAccessManager";

/**
* default idm implementation class.
*/
public static final String DEFAULT_IDM_IMPLEMENTATION_CLASS = "com.softinstigate.restheart.security.impl.SimpleFileIdentityManager";

/**
* the key for the local-cache-enabled property.
*/
Expand Down Expand Up @@ -550,7 +551,7 @@ public Configuration(final String confFilePath) {
amImpl = getAsStringOrDefault(am, IMPLEMENTATION_CLASS_KEY, DEFAULT_AM_IMPLEMENTATION_CLASS);
amArgs = am;

logFilePath = getAsStringOrDefault(conf, LOG_FILE_PATH_KEY,
logFilePath = getAsStringOrDefault(conf, LOG_FILE_PATH_KEY,
URLUtilis.removeTrailingSlashes(System.getProperty("java.io.tmpdir"))
.concat(File.separator + "restheart.log"));
String _logLevel = getAsStringOrDefault(conf, LOG_LEVEL_KEY, "WARN");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* @author Andrea Di Cesare
*/
public class CollectionDAO {

private static final MongoClient client = MongoDBClientSingleton.getInstance().getClient();

private static final Logger logger = LoggerFactory.getLogger(CollectionDAO.class);
Expand Down Expand Up @@ -97,8 +98,7 @@ public static DBCollection getCollection(String dbName, String collName) {
}

/**
* Checks if the given collection is empty.
* Note that RESTHeart creates a
* Checks if the given collection is empty. Note that RESTHeart creates a
* reserved properties document in every collection (with _id
* '_properties'). This method returns true even if the collection contains
* such document.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/softinstigate/restheart/db/DAOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* @author Andrea Di Cesare
*/
public class DAOUtils {

/**
* @param rows list of DBObject rows as returned by getDataFromCursor()
* @return
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/softinstigate/restheart/db/DBDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* @author Andrea Di Cesare
*/
public class DBDAO {

private static final MongoClient client = MongoDBClientSingleton.getInstance().getClient();

private static final Logger logger = LoggerFactory.getLogger(DBDAO.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* @author Andrea Di Cesare
*/
public class DocumentDAO {

private static final MongoClient client = MongoDBClientSingleton.getInstance().getClient();

private static final Logger logger = LoggerFactory.getLogger(DocumentDAO.class);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/softinstigate/restheart/db/IndexDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* @author Andrea Di Cesare
*/
public class IndexDAO {

private static final MongoClient client = MongoDBClientSingleton.getInstance().getClient();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @author Andrea Di Cesare
*/
public class MongoDBClientSingleton {

private static boolean initialized = false;

private static transient List<Map<String, Object>> mongoServers;
Expand Down Expand Up @@ -115,6 +116,7 @@ public static MongoDBClientSingleton getInstance() {
}

private static class MongoDBClientSingletonHolder {

private static final MongoDBClientSingleton INSTANCE = new MongoDBClientSingleton();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @author Andrea Di Cesare
*/
public class PropsFixer {

private static final MongoClient client = MongoDBClientSingleton.getInstance().getClient();

private static final Logger logger = LoggerFactory.getLogger(PropsFixer.class);
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/softinstigate/restheart/db/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Data Access Object Classes to decouple the handling logic from the db
*
* Data Access Object Classes to decouple the handling logic from the db
*
* @author Andrea Di Cesare
*/

package com.softinstigate.restheart.db;
*/
package com.softinstigate.restheart.db;
1 change: 1 addition & 0 deletions src/main/java/com/softinstigate/restheart/hal/Link.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @author Andrea Di Cesare
*/
public class Link {

private final BasicDBObject dbObject = new BasicDBObject();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @author Andrea Di Cesare
*/
public class Relationship {

private static final Logger logger = LoggerFactory.getLogger(Relationship.class);

/**
Expand All @@ -43,17 +44,14 @@ public enum TYPE {
*
*/
ONE_TO_ONE,

/**
*
*/
ONE_TO_MANY,

/**
*
*/
MANY_TO_ONE,

/**
*
*/
Expand All @@ -69,7 +67,6 @@ public enum ROLE {
*
*/
OWNING,

/**
*
*/
Expand Down Expand Up @@ -151,15 +148,13 @@ public Relationship(String rel, String type, String role, String targetDb, Strin

try {
this.type = TYPE.valueOf(type);
}
catch (IllegalArgumentException iae) {
} catch (IllegalArgumentException iae) {
throw new InvalidMetadataException("invalid type value: " + type + ". valid values are " + Arrays.toString(TYPE.values()), iae);
}

try {
this.role = ROLE.valueOf(role);
}
catch (IllegalArgumentException iae) {
} catch (IllegalArgumentException iae) {
throw new InvalidMetadataException("invalid role value " + role + ". valid values are " + Arrays.toString(ROLE.values()), iae);
}

Expand Down Expand Up @@ -273,8 +268,7 @@ public String getRelationshipLink(RequestContext context, String dbName, String
}

reference = (String) _referenceValue;
}
else {
} else {
if (!(_referenceValue instanceof BasicDBList)) {
throw new IllegalArgumentException("in resource " + dbName + "/" + collName + "/" + data.get("_id")
+ " the " + type.name() + " relationship ref-field " + this.referenceField + " should be an array, but is " + _referenceValue);
Expand All @@ -288,8 +282,7 @@ public String getRelationshipLink(RequestContext context, String dbName, String

reference = Arrays.toString(ids);
}
}
else // INVERSE
} else // INVERSE
{
reference = "'" + data.get("_id").toString() + "'";
}
Expand All @@ -299,16 +292,13 @@ public String getRelationshipLink(RequestContext context, String dbName, String
if (role == ROLE.OWNING) {
if (type == TYPE.ONE_TO_ONE || type == TYPE.MANY_TO_ONE) {
return URLUtilis.getUriWithDocId(context, db, targetCollection, reference);
}
else if (type == TYPE.ONE_TO_MANY || type == TYPE.MANY_TO_MANY) {
} else if (type == TYPE.ONE_TO_MANY || type == TYPE.MANY_TO_MANY) {
return URLUtilis.getUriWithFilterMany(context, db, targetCollection, referenceField, reference);
}
}
else {
} else {
if (type == TYPE.ONE_TO_ONE || type == TYPE.ONE_TO_MANY) {
return URLUtilis.getUriWithFilterOne(context, db, targetCollection, referenceField, reference);
}
else if (type == TYPE.MANY_TO_ONE || type == TYPE.MANY_TO_MANY) {
} else if (type == TYPE.MANY_TO_ONE || type == TYPE.MANY_TO_MANY) {
return URLUtilis.getUriWithFilterManyInverse(context, db, targetCollection, referenceField, reference);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Classes to deal with HAL documents properties that have a special semantic
* in RESTHeart and thus are called metadata
*
* Classes to deal with HAL documents properties that have a special semantic in
* RESTHeart and thus are called metadata
*
* @author Andrea Di Cesare
*/

package com.softinstigate.restheart.hal.metadata;
*/
package com.softinstigate.restheart.hal.metadata;
10 changes: 4 additions & 6 deletions src/main/java/com/softinstigate/restheart/hal/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Classes to deal with HAL documents
*
* Classes to deal with HAL documents
*
* @author Andrea Di Cesare
*/

package com.softinstigate.restheart.hal;
*/
package com.softinstigate.restheart.hal;
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* @author Andrea Di Cesare
*/
public class ErrorHandler implements HttpHandler {

private final HttpHandler next;

private Logger logger = LoggerFactory.getLogger(ErrorHandler.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* @author Andrea Di Cesare
*/
public class GzipEncodingHandler extends EncodingHandler {

private boolean forceCompression = false;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @author Andrea Di Cesare
*/
public class OptionsHandler extends PipedHttpHandler {

/**
* Creates a new instance of OptionsHandler
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @author Andrea Di Cesare
*/
public class PipedWrappingHandler extends PipedHttpHandler {

private final HttpHandler wrapped;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* @author Andrea Di Cesare
*/
public class RequestDispacherHandler extends PipedHttpHandler {

private final GetRootHandler rootGet;
private final GetDBHandler dbGet;
private final PutDBHandler dbPut;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class ApplicationLogicHandler extends PipedHttpHandler {

/**
* Creates a new instance of the ApplicationLogicHandler
*
* @param next
* @param args
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class GetRoleHandler extends ApplicationLogicHandler {

/**
* Creates a new instance of GetRoleHandler
*
* @param next
* @param args
* @throws Exception
Expand All @@ -98,7 +99,7 @@ public GetRoleHandler(PipedHttpHandler next, Map<String, Object> args) throws Ex

/**
* Handles the request.
*
*
* @param exchange
* @param context
* @throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @author Andrea Di Cesare
*/
public class PingHandler extends ApplicationLogicHandler {

private final String msg;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Abstract handler to define custom application logic services and some generic example implementations
*
* Abstract handler to define custom application logic services and some generic
* example implementations
*
* @author Andrea Di Cesare
*/

package com.softinstigate.restheart.handlers.applicationlogic;
*/
package com.softinstigate.restheart.handlers.applicationlogic;
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* @author Andrea Di Cesare
*/
public class CollectionRepresentationFactory {

private static final Logger logger = LoggerFactory.getLogger(CollectionRepresentationFactory.class);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @author Andrea Di Cesare
*/
public class DeleteCollectionHandler extends PipedHttpHandler {

private static final Logger logger = LoggerFactory.getLogger(DeleteCollectionHandler.class);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @author Andrea Di Cesare
*/
public class GetCollectionHandler extends PipedHttpHandler {

private static final Logger logger = LoggerFactory.getLogger(GetCollectionHandler.class);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @author Andrea Di Cesare
*/
public class PatchCollectionHandler extends PipedHttpHandler {

/**
* Creates a new instance of PatchCollectionHandler
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @author Andrea Di Cesare
*/
public class PostCollectionHandler extends PutCollectionHandler {

/**
* Creates a new instance of PostCollectionHandler
*/
Expand Down
Loading

0 comments on commit 64f0098

Please sign in to comment.