Skip to content

Commit

Permalink
For #196 and #197
Browse files Browse the repository at this point in the history
  • Loading branch information
thehabes committed Mar 15, 2021
1 parent 62a484d commit 0c1fa58
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
35 changes: 15 additions & 20 deletions src/java/edu/slu/common/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,33 @@
* @author hanyan
*/
public class Constant {
public static final String RERUM_API_VERSION="1.0.0";

//Mongo Connection String
public static final String DATABASE_CONNECTION = "mongodb://some-user:SomePassword@some-server:27017/DBNAME?w=majority&authMechanism=PICK-ONE";

//permission of annotation
public static final int PERMISSION_PRIVATE = 0;
public static final int PERMISSION_PROJECT = 1;
public static final int PERMISSION_PUBLIC = 2;
//Mongo Database Name
public static final String DATABASE_NAME = "annotationStore"; // NOTE this changes between dev and prod

//collection name
public static final String COLLECTION_ANNOTATION = "alpha"; // for RERUM alpha
public static final String COLLECTION_ACCEPTEDSERVER = "acceptedServer";
public static final String COLLECTION_USER = "user";
public static final String COLLECTION_PROJECT_USER_PROFILE = "projectUserProfile";
public static final String COLLECTION_AGENT = "agent";
//Database Collection Name
public static final String COLLECTION_ANNOTATION = "alpha"; //db.alpha.doStuff()

public static final String AGENT_DEPENDENCY_TYPE_USER = "user";
public static final String AGENT_DEPENDENCY_TYPE_STRING = "string";
//Legacy Collection Names
public static final String COLLECTION_ACCEPTEDSERVER = "acceptedServer"; //db.acceptedServer.doStuff()
public static final String COLLECTION_V0 = "annotation"; // db.annotation.doStuff()

//RERUM URL and endpoint paterns
public static final String RERUM_BASE="http://test-store.rerum.io";
public static final String RERUM_PREFIX="http://test-store.rerum.io/prd02-img01/";
public static final String RERUM_ID_PREFIX="http://test-store.rerum.io/prd02-img01/id/";
public static final String RERUM_AGENT_PREFIX="http://devstore.rerum.io/v1/agent";
public static final String RERUM_AGENT_ClAIM="http://devstore.rerum.io/v1/agent";

//RERUM API Linked Data context
public static final String RERUM_CONTEXT="http://test-store.rerum.io/prd02-img01/context.json";
public static final String RERUM_API_VERSION="1.0.0";

//The location of the public API documents. This is necessary for JSON-LD context purposes.
public static final String RERUM_API_DOC="https://github.com/CenterForDigitalHumanities/rerum_server/blob/master/API.md#__rerum";

//number of annotation versions
public static final int NUMBER_OF_ANNO_VERSION = 10;

//get by objectID url
//public static final String GET_BY_OBJECTid_URL = "http://test-store.rerum.io/rerumserver/anno/getAnnotationByObjectID";

//return result message
public static final String DUPLICATED = "duplicated";
public static final String SUCCESS = "success";
Expand Down
7 changes: 3 additions & 4 deletions src/java/edu/slu/util/MongoDBUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import edu.slu.common.Constant;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -38,11 +39,9 @@ public static MongoDBUtil getInstance() {
final MongoClientOptions options = MongoClientOptions.builder()
.connectionsPerHost(100)
.build();
MongoClientURI uri = new MongoClientURI(
"mongodb://USER:PASS@f-vl-cdh-img-01:27017/DATABASE?w=majority&authMechanism=PICK_ONE"
);
MongoClientURI uri = new MongoClientURI(Constant.DATABASE_CONNECTION);
mg = new MongoClient(uri);
db = mg.getDB("annotationStoreDev");
db = mg.getDB(Constant.DATABASE_NAME);
} catch (Exception e) {
Logger.getLogger(MongoDBUtil.class.getName()).log(Level.SEVERE, null, e);
}
Expand Down
19 changes: 10 additions & 9 deletions src/java/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@

<package name="default" extends="struts-default">
<!-- this tells the package what to do when the result is an expected string. @see RequestServerAuthenticationFilter.java && AnnotationAction.java &&DownTimeOverride.java -->
<!-- Only put handlers here that need to apply to ALL PACKAGES -->
<interceptors>
<interceptor name="downTimeOverride" class="edu.slu.filter.DownTimeOverride"></interceptor>
</interceptors>

<!-- Only put handlers here that need to apply to ALL PACKAGES -->
<global-results>
<result name="403">/403.jsp</result>
<result name="503">/down.html</result>
Expand All @@ -30,7 +26,6 @@
<!-- INTERCEPTOR -->
<interceptors>
<interceptor-stack name="myDefault">
<interceptor-ref name="downTimeOverride" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
Expand All @@ -43,7 +38,6 @@
<!-- INTERCEPTOR -->
<interceptors>
<interceptor-stack name="myDefault">
<interceptor-ref name="downTimeOverride" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
Expand All @@ -56,7 +50,6 @@
<!-- INTERCEPTOR -->
<interceptors>
<interceptor-stack name="myDefault">
<interceptor-ref name="downTimeOverride" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
Expand All @@ -69,13 +62,21 @@
<!-- INTERCEPTOR -->
<interceptors>
<interceptor name="getRequestClientInfoRecorder" class="edu.slu.filter.GetRequestClientInfoRecorder">
<param name="includeMethods">askAuth0, getByProperties, getByID, getAllAncestors, getAllDescendants, getAllVersions</param>
<param name="includeMethods">askAuth0, getByProperties, getByID, getAllAncestors, getAllDescendants, getAllVersions</param>
</interceptor>

<interceptor name="DownTimeOverride" class="edu.slu.filter.DownTimeOverride">
<param name="includeMethods">
saveNewObject, batchSaveFromCopy, releaseObject, patchUpdateObject, putUpdateObject, overwriteObject, patchSetUpdate, patchUnsetUpdate, deleteObject
</param>
</interceptor>

<interceptor-stack name="myDefault">
<interceptor-ref name="downTimeOverride" />
<interceptor-ref name="getRequestClientInfoRecorder" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>

</interceptors>
<default-interceptor-ref name="myDefault" />

Expand Down

0 comments on commit 0c1fa58

Please sign in to comment.