Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minor security and shark-specific message removal

committing Locus constructor fix
fixing a horrible marked individual persistence method!
  • Loading branch information...
commit 60a42a3982f0f5dd1ef40f211aa5e0a5f9b52036 1 parent 513b4ba
@RichardJune RichardJune authored
View
42 src/main/java/org/ecocean/Shepherd.java
@@ -129,6 +129,21 @@ public String storeNewEncounter(Encounter enc, String uniqueID) {
}
return (uniqueID);
}
+
+ public boolean storeNewMarkedIndividual(MarkedIndividual indie) {
+
+ beginDBTransaction();
+ try {
+ pm.makePersistent(indie);
+ commitDBTransaction();
+ } catch (Exception e) {
+ rollbackDBTransaction();
+ System.out.println("I failed to create a new MarkedIndividual in Shepherd.storeNewMarkedIndividual().");
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
/**
* Persists a new adoption in the database.
@@ -707,32 +722,7 @@ public boolean isMarkedIndividual(String name) {
* @see MarkedIndividual
*/
public boolean addMarkedIndividual(MarkedIndividual newShark) {
- if(newShark.getIndividualID().trim().equals("")){
- System.out.println("Returning false because newShark.getIndividualID() equals: "+newShark.getIndividualID());
- return false;
- }
- Extent sharkClass = pm.getExtent(MarkedIndividual.class, true);
- Query query = pm.newQuery(sharkClass);
- Iterator allsharks = getAllMarkedIndividuals(query);
- while (allsharks.hasNext()) {
- MarkedIndividual tempShark = (MarkedIndividual) allsharks.next();
- System.out.println(tempShark.getName()+" vs "+newShark.getIndividualID());
- if (tempShark.getName().equals(newShark.getName())) {
- System.out.println("failed in addMarkedIndividual");
- query.closeAll();
- query = null;
- sharkClass = null;
- return false;
- }
- }
-
- pm.makePersistent(newShark);
-
- query.closeAll();
- query = null;
- sharkClass = null;
- return true;
-
+ return storeNewMarkedIndividual(newShark);
}
View
2  src/main/java/org/ecocean/genetics/Locus.java
@@ -24,7 +24,7 @@ public Locus(){}
* @param allelle0
* @param allelle1
*/
- public Locus(String name, Integer allelle0, Integer allelle1){
+ public Locus(String name, Integer allele0, Integer allele1){
this.allele0=allele0;
this.allele1=allele1;
View
8 src/main/java/org/ecocean/servlet/ServletUtilities.java
@@ -335,11 +335,11 @@ public static boolean isUserAuthorizedForEncounter(Encounter enc, HttpServletReq
boolean isOwner = false;
if (request.isUserInRole("admin")) {
isOwner = true;
- } else if (request.isUserInRole("admin")) {
- isOwner = true;
- } else if ((request.isUserInRole(enc.getLocationCode())) && (request.isUserInRole("admin"))) {
+ }
+ else if (request.isUserInRole(enc.getLocationCode())) {
isOwner = true;
- } else if ((((enc.getSubmitterID() != null) && (request.getRemoteUser() != null) && (enc.getSubmitterID().equals(request.getRemoteUser())) && (request.isUserInRole("admin"))))) {
+ }
+ else if ((((enc.getSubmitterID() != null) && (request.getRemoteUser() != null) && (enc.getSubmitterID().equals(request.getRemoteUser()))))) {
isOwner = true;
}
return isOwner;
View
2  src/main/webapp/confirmSubmit.jsp
@@ -90,7 +90,7 @@
<div id="maintext">
<%
StringBuffer new_message = new StringBuffer();
- new_message.append("The library has received a new whale shark encounter submission. You can " +
+ new_message.append("The "+CommonConfiguration.getProperty("htmlTitle")+" library has received a new encounter submission. You can " +
"view it at:\nhttp://" + CommonConfiguration.getURLLocation(request) +
"/encounters/encounter" +
".jsp?number="+ number);
Please sign in to comment.
Something went wrong with that request. Please try again.