diff --git a/src/main/java/org/ecocean/EncounterQueryProcessor.java b/src/main/java/org/ecocean/EncounterQueryProcessor.java index 9cb248acef..4f87d7aacd 100755 --- a/src/main/java/org/ecocean/EncounterQueryProcessor.java +++ b/src/main/java/org/ecocean/EncounterQueryProcessor.java @@ -306,7 +306,7 @@ public static String queryStringBuilder(HttpServletRequest request, StringBuffer jdoqlVariableDeclaration += ";org.ecocean.Annotation annot46;"; } else { - jdoqlVariableDeclaration=" VARIABLES org.ecocean.Annotation annot46;"; + jdoqlVariableDeclaration=" VARIABLES org.ecocean.Annotation annot46"; } } diff --git a/src/main/java/org/ecocean/acm/AcmUtil.java b/src/main/java/org/ecocean/acm/AcmUtil.java index f705a75484..3eea3c510c 100644 --- a/src/main/java/org/ecocean/acm/AcmUtil.java +++ b/src/main/java/org/ecocean/acm/AcmUtil.java @@ -36,7 +36,7 @@ public static int rectifyMediaAssetIds(List mas, List acmIds return numChanged; } - public static int rectifyAnnotationIds(List anns, List acmIds) { + public static int rectifyAnnotationIds(List anns, List acmIds, Shepherd myShepherd) { if ((anns == null) || (acmIds == null) || (anns.size() != acmIds.size())) { IA.log("ERROR: AcmUtil.rectifyAnnotationIds() has invalid lists passed; failing"); return -1; @@ -56,6 +56,8 @@ public static int rectifyAnnotationIds(List anns, List acmId numChanged++; } } + //persist this + if(numChanged>0)myShepherd.updateDBTransaction(); return numChanged; } } diff --git a/src/main/java/org/ecocean/ia/plugin/WildbookIAM.java b/src/main/java/org/ecocean/ia/plugin/WildbookIAM.java index 737f4b8fc7..14c581a5b4 100755 --- a/src/main/java/org/ecocean/ia/plugin/WildbookIAM.java +++ b/src/main/java/org/ecocean/ia/plugin/WildbookIAM.java @@ -292,7 +292,7 @@ public JSONObject sendAnnotations(ArrayList anns, boolean checkFirst if (acmIds == null) { IA.log("WARNING: WildbookIAM.sendAnnotations() could not get list of acmIds from response: " + rtn); } else { - int numChanged = AcmUtil.rectifyAnnotationIds(acmList, acmIds); + int numChanged = AcmUtil.rectifyAnnotationIds(acmList, acmIds, myShepherd); IA.log("INFO: WildbookIAM.sendAnnotations() updated " + numChanged + " Annotation(s) acmId(s) via rectifyAnnotationIds()"); } return rtn; diff --git a/src/main/java/org/ecocean/servlet/ServletUtilities.java b/src/main/java/org/ecocean/servlet/ServletUtilities.java index fd94637a3a..844afd1d55 100644 --- a/src/main/java/org/ecocean/servlet/ServletUtilities.java +++ b/src/main/java/org/ecocean/servlet/ServletUtilities.java @@ -521,7 +521,8 @@ public static boolean isUserAuthorizedForImportTask(ImportTask occ, HttpServletR //quick collaboration check between current user and bulk import owner //if(occ.getCreator() !=null && Collaboration.canCollaborate(request.getUserPrincipal().getName(), occ.getCreator().getUsername(), myShepherd.getContext()))return true; - if(Collaboration.collaborationBetweenUsers(myShepherd, request.getUserPrincipal().getName(), occ.getCreator().getUsername())!=null)return true; + Collaboration collab = Collaboration.collaborationBetweenUsers(myShepherd, request.getUserPrincipal().getName(), occ.getCreator().getUsername()); + if(collab!=null && collab.getState()!=null && (collab.getState().equals(Collaboration.STATE_EDIT_PRIV)||collab.getState().equals(Collaboration.STATE_APPROVED)) )return true; //quick orgAdminCheck diff --git a/src/main/java/org/ecocean/servlet/export/EncounterSearchExportExcelFile.java b/src/main/java/org/ecocean/servlet/export/EncounterSearchExportExcelFile.java index 967b972ae6..d1d120dd72 100755 --- a/src/main/java/org/ecocean/servlet/export/EncounterSearchExportExcelFile.java +++ b/src/main/java/org/ecocean/servlet/export/EncounterSearchExportExcelFile.java @@ -5,6 +5,7 @@ import java.io.*; import java.util.*; +import org.apache.commons.text.StringEscapeUtils; import org.ecocean.*; import org.ecocean.genetics.*; import org.ecocean.servlet.ServletUtilities; @@ -16,6 +17,8 @@ import jxl.write.*; import jxl.Workbook; +import jxl.WorkbookSettings; + import java.lang.Boolean; @@ -43,7 +46,6 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr context=ServletUtilities.getContext(request); Shepherd myShepherd = new Shepherd(context); myShepherd.setAction("EncounterSearchExportExcelFile.class"); - Vector rEncounters = new Vector(); @@ -91,7 +93,9 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr WritableCellFormat integerFormat = new WritableCellFormat(NumberFormats.INTEGER); //let's write out headers for the OBIS export file - WritableWorkbook workbookOBIS = Workbook.createWorkbook(excelFile); + WorkbookSettings ws = new WorkbookSettings(); + ws.setEncoding( "UTF-8" ); + WritableWorkbook workbookOBIS = Workbook.createWorkbook(excelFile,ws); WritableSheet sheet = workbookOBIS.createSheet("Search Results", 0); Label label0 = new Label(0, 0, "Date Last Modified"); sheet.addCell(label0); @@ -245,7 +249,7 @@ else if(CommonConfiguration.getProperty("genusSpecies0",context)!=null){ sheet.addCell(lNumberx22); } - Label lNumberx23 = new Label(22, count, enc.getLocation()); + Label lNumberx23 = new Label(22, count, StringEscapeUtils.unescapeHtml4(enc.getLocation())); sheet.addCell(lNumberx23); //check for available locale coordinates @@ -282,7 +286,7 @@ else if(CommonConfiguration.getProperty("genusSpecies0",context)!=null){ sheet.addCell(lSex); } if(enc.getComments()!=null){ - Label lNumberx26 = new Label(26, count, enc.getComments().replaceAll("
", ". ").replaceAll("\n", "").replaceAll("\r", "")); + Label lNumberx26 = new Label(26, count, StringEscapeUtils.unescapeHtml4(enc.getComments().replaceAll("
", ". ").replaceAll("\n", "").replaceAll("\r", ""))); sheet.addCell(lNumberx26); } if(enc.getSizeAsDouble()!=null){ @@ -290,7 +294,7 @@ else if(CommonConfiguration.getProperty("genusSpecies0",context)!=null){ sheet.addCell(lNumberx27); } if (enc.getIndividual()!=null) { - Label lNumberx28 = new Label(28, count, enc.getIndividual().getDisplayName(request, myShepherd)); + Label lNumberx28 = new Label(28, count, StringEscapeUtils.unescapeHtml4(enc.getIndividual().getDisplayName(request, myShepherd))); sheet.addCell(lNumberx28); } if (enc.getLocationCode() != null) { diff --git a/src/main/java/org/ecocean/servlet/export/EncounterSearchExportMetadataExcel.java b/src/main/java/org/ecocean/servlet/export/EncounterSearchExportMetadataExcel.java index 85dec85ff3..1a99713684 100755 --- a/src/main/java/org/ecocean/servlet/export/EncounterSearchExportMetadataExcel.java +++ b/src/main/java/org/ecocean/servlet/export/EncounterSearchExportMetadataExcel.java @@ -4,6 +4,8 @@ import java.io.*; import java.util.*; + +import org.apache.commons.text.StringEscapeUtils; import org.ecocean.*; import org.ecocean.media.*; import org.ecocean.genetics.*; @@ -13,10 +15,12 @@ import java.lang.StringBuffer; import jxl.write.*; import jxl.Workbook; +import jxl.WorkbookSettings; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; + public class EncounterSearchExportMetadataExcel extends HttpServlet { @@ -132,7 +136,9 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr // business logic start here - WritableWorkbook excelWorkbook = Workbook.createWorkbook(excelFile); + WorkbookSettings ws = new WorkbookSettings(); + ws.setEncoding( "UTF-8" ); + WritableWorkbook excelWorkbook = Workbook.createWorkbook(excelFile,ws); WritableSheet sheet = excelWorkbook.createSheet("Search Results", 0); List columns = new ArrayList(); diff --git a/src/main/java/org/ecocean/servlet/export/ExportColumn.java b/src/main/java/org/ecocean/servlet/export/ExportColumn.java index 3be68c7024..5f558e8a1c 100644 --- a/src/main/java/org/ecocean/servlet/export/ExportColumn.java +++ b/src/main/java/org/ecocean/servlet/export/ExportColumn.java @@ -16,6 +16,7 @@ import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; +import org.apache.commons.text.StringEscapeUtils; public class ExportColumn { @@ -63,7 +64,7 @@ public String getStringValue(Object obj) throws InvocationTargetException, Illeg if (value == null){ return null; } - return value.toString(); + return StringEscapeUtils.unescapeHtml4(value.toString()); } public int getMeasurementNum() {return measureNum;} diff --git a/src/main/java/org/ecocean/servlet/export/OccurrenceSearchExportMetadataExcel.java b/src/main/java/org/ecocean/servlet/export/OccurrenceSearchExportMetadataExcel.java index 18a6378358..63d8bbf376 100755 --- a/src/main/java/org/ecocean/servlet/export/OccurrenceSearchExportMetadataExcel.java +++ b/src/main/java/org/ecocean/servlet/export/OccurrenceSearchExportMetadataExcel.java @@ -16,6 +16,8 @@ import jxl.write.*; import jxl.Workbook; +import jxl.WorkbookSettings; +import org.apache.commons.text.StringEscapeUtils; public class OccurrenceSearchExportMetadataExcel extends HttpServlet { @@ -121,7 +123,9 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr WritableCellFormat integerFormat = new WritableCellFormat(NumberFormats.INTEGER); //let's write out headers for the OBIS export file - WritableWorkbook workbookOBIS = Workbook.createWorkbook(excelFile); + WorkbookSettings ws = new WorkbookSettings(); + ws.setEncoding( "UTF-8" ); + WritableWorkbook workbookOBIS = Workbook.createWorkbook(excelFile,ws); sheet = workbookOBIS.createSheet("Search Results", 0); String[] colHeaders = new String[]{ @@ -188,7 +192,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr writeCell("taxonomies", occ.getAllSpecies()); // the getAllSpecies List toStrings nicely writeCell("individualCount", occ.getIndividualCount()); writeCell("groupBehavior", occ.getGroupBehavior()); - writeCell("commments", occ.getComments()); + writeCell("commments", StringEscapeUtils.unescapeHtml4(occ.getComments())); writeCell("modified", occ.getDWCDateLastModified()); writeCell("dateTimeCreated", occ.getDateTimeCreated()); writeCell("fieldStudySite", occ.getFieldStudySite()); diff --git a/src/main/webapp/encounters/encounter.jsp b/src/main/webapp/encounters/encounter.jsp index ef7819eaab..9cbb97aea3 100644 --- a/src/main/webapp/encounters/encounter.jsp +++ b/src/main/webapp/encounters/encounter.jsp @@ -694,7 +694,7 @@ $(function() { <% //set a default date if we cann - if(enc.getDateInMilliseconds()!=null){ + if(isOwner && enc.getDateInMilliseconds()!=null){ //LocalDateTime jodaTime = new LocalDateTime(enc.getDateInMilliseconds()); @@ -868,10 +868,9 @@ else { <% -if(enc.getLocation()!=null){ +if(isOwner && enc.getLocation()!=null){ %> - -<%=encprops.getProperty("locationDescription")%> <%=enc.getLocation()%> + <%=encprops.getProperty("locationDescription")%> <%=enc.getLocation()%> <% } %> @@ -888,11 +887,14 @@ if(enc.getLocation()!=null){ List hier=LocationID.getIDForChildAndParents(enc.getLocationID(), null); int sizeHier=hier.size(); String displayPath=""; - for(int q=0;q <%=displayPath %> @@ -938,7 +940,7 @@ if(CommonConfiguration.showProperty("showCountry",context)){ %> <% - if(enc.getCountry()!=null){ + if(isOwner && enc.getCountry()!=null){ %> : <%=enc.getCountry()%> <% @@ -2480,7 +2482,7 @@ function checkIdDisplay() {

<%=encprops.getProperty("submitter") %>

<% - if(enc.getSubmitters()!=null){ + if(isOwner && enc.getSubmitters()!=null){ %> @@ -2564,7 +2566,7 @@ function checkIdDisplay() {

<%=encprops.getProperty("photographer") %>

<% - if(enc.getPhotographers()!=null){ + if(isOwner && enc.getPhotographers()!=null){ %>
@@ -3781,7 +3783,7 @@ else { <%}%>

- <%if(enc.getDateInMilliseconds()!=null && visible){ %> + <%if(isOwner && visible && enc.getDateInMilliseconds()!=null){ %> <%=enc.getDate()%> @@ -3798,7 +3800,7 @@ else {
<%=encprops.getProperty("verbatimEventDate")%>: <% - if(enc.getVerbatimEventDate()!=null){ + if(isOwner && enc.getVerbatimEventDate()!=null){ %> <%=enc.getVerbatimEventDate()%> <% diff --git a/src/main/webapp/import.jsp b/src/main/webapp/import.jsp index 825655784c..9b9a1c54ad 100644 --- a/src/main/webapp/import.jsp +++ b/src/main/webapp/import.jsp @@ -616,6 +616,7 @@ try{ int numWithACMID=0; int numAllowedIA=0; int numDetectionComplete=0; + ArrayList invalidMediaAssets=new ArrayList(); for(MediaAsset asset:allAssets){ if(asset.getAcmId()!=null)numWithACMID++; @@ -625,6 +626,10 @@ try{ } else if(asset.validateSourceImage()){numAllowedIA++;myShepherd.updateDBTransaction();} + if(asset.isValidImageForIA() == null || !asset.isValidImageForIA().booleanValue()){ + invalidMediaAssets.add(asset); + } + if(asset.getDetectionStatus()!=null && (asset.getDetectionStatus().equals("complete")||asset.getDetectionStatus().equals("pending"))) numDetectionComplete++; } @@ -634,6 +639,24 @@ try{

diff --git a/src/main/webapp/occurrence.jsp b/src/main/webapp/occurrence.jsp index fd18577b48..17ce0eedea 100755 --- a/src/main/webapp/occurrence.jsp +++ b/src/main/webapp/occurrence.jsp @@ -551,6 +551,7 @@ if (!Util.collectionIsEmptyOrNull(occ.getInformOthers())) { int total = dateSortedEncs.length; for (int i = 0; i < total; i++) { Encounter enc = dateSortedEncs[i]; + if(ServletUtilities.isUserAuthorizedForEncounter(enc, request, myShepherd)){ %> @@ -626,7 +627,11 @@ if (!Util.collectionIsEmptyOrNull(occ.getInformOthers())) { <%}%> - <%} //End of loop iterating over encounters. %> + <% + + }//end if user is authorized + + } //End of loop iterating over encounters. %>