Skip to content

Commit

Permalink
Merge pull request #882 from WildMeOrg/indocet-removal
Browse files Browse the repository at this point in the history
removal of indocet custom org work
  • Loading branch information
naknomum authored Nov 8, 2024
2 parents 1b6dce8 + 08b6ccf commit c51f9fc
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 1,266 deletions.
21 changes: 12 additions & 9 deletions src/main/java/org/ecocean/LocationID.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public static List<String> getIDForParentAndChildren(String locationID, ArrayLis
/*
* Starting with a childID, get the IDs of its root parent all the way down to the child ID
* @childLocationID - dig for a child with this @id
* @qualifier to use in the digging (e.g., to define user or org value, such as use the 'indocet' qualifier)
* @qualifier to use in the digging (e.g., to define user or org value)
* @return a List of Strings of the lineage of the child ID, starting with its highest parent down to the ID itself.
*/
public static List<String> getIDForChildAndParents(String childLocationIDToFind,
Expand Down Expand Up @@ -329,8 +329,8 @@ private static void recurseToFindIDStrings(JSONObject jsonobj, ArrayList<String>
/*
* Return an HTML selector of hierarchical locationIDs with indenting
*/
public static String getHTMLSelector(boolean multiselect, List<String> selectedIDs, String qualifier,
String htmlID, String htmlName, String htmlClass) {
public static String getHTMLSelector(boolean multiselect, List<String> selectedIDs,
String qualifier, String htmlID, String htmlName, String htmlClass) {
String multiselector = "";

if (multiselect) multiselector = " multiple=\"multiple\"";
Expand All @@ -343,14 +343,17 @@ public static String getHTMLSelector(boolean multiselect, List<String> selectedI
selector.append("</select>\n\r");
return selector.toString();
}

public static String getHTMLSelector(boolean multiselect, String selectedID, String qualifier, String htmlID, String htmlName, String htmlClass) {
ArrayList<String> locationIDs = new ArrayList<String>();
locationIDs.add(selectedID);
return getHTMLSelector(multiselect, locationIDs, qualifier, htmlID, htmlName, htmlClass);

public static String getHTMLSelector(boolean multiselect, String selectedID, String qualifier,
String htmlID, String htmlName, String htmlClass) {
ArrayList<String> locationIDs = new ArrayList<String>();

locationIDs.add(selectedID);
return getHTMLSelector(multiselect, locationIDs, qualifier, htmlID, htmlName, htmlClass);
}

private static void createSelectorOptions(JSONObject jsonobj, StringBuffer selector, int nestingLevel, List<String> selectedIDs) {
private static void createSelectorOptions(JSONObject jsonobj, StringBuffer selector,
int nestingLevel, List<String> selectedIDs) {
int localNestingLevel = nestingLevel;
String selected = "";
String spacing = "";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/ecocean/MultiValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public static List<String> valuesForKey(String nameKey, Shepherd myShepherd) {
}

// returns N, where N is the lowest number that is NOT a value in a name w/ nameKey.
// valuePrefix comes before N for weird double-labeled values like indocet-
// valuePrefix comes before N for weird double-labeled values

public static String nextUnusedValueForKey(String nameKey, String valuePrefix,
Shepherd myShepherd) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/ecocean/Organization.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class Organization implements java.io.Serializable {
private List<Organization> children = null;

// if individualNameKey != null, this organization has a special nameKey that is used to create an org-wide catalog
// e.g. IndoCet wants to generate IndoCet names;
private String individualNameKey = null;

public Organization() {
Expand Down Expand Up @@ -294,7 +293,7 @@ public boolean canManage(User user, Shepherd myShepherd) {
if (user == null) return false;
if (user.hasRoleByName("admin", myShepherd) || user.hasRoleByName(ROLE_ADMIN, myShepherd))
return true;
if (!this.hasMember(user)) return false;
if (!this.hasMember(user)) return false;
return user.hasRoleByName(ROLE_MANAGER, myShepherd);
}

Expand Down
20 changes: 0 additions & 20 deletions src/main/java/org/ecocean/ShepherdProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
import javax.servlet.http.HttpServletRequest;

public class ShepherdProperties {
public static final String[] overrideOrgsArr = { "indocet" };
// set for easy .contains() checking
public static final Set<String> overrideOrgs = new HashSet<>(Arrays.asList(overrideOrgsArr));

public static Properties getProperties(String fileName) {
return getProperties(fileName, "en");
}
Expand Down Expand Up @@ -65,12 +61,6 @@ public static Properties getOverwriteProps(HttpServletRequest request) {
public static String getOverwriteStringForUser(HttpServletRequest request,
Shepherd myShepherd) {
if (request == null) return null;
String manualOrgName = request.getParameter("organization");
// manual request params
if (Util.stringExists(manualOrgName)) {
String overwrite = getOverwriteStringForOrgName(manualOrgName);
if (Util.stringExists(overwrite)) return overwrite;
}
// now try based on the user's organizations
User user = myShepherd.getUser(request);
if (user == null) return null;
Expand All @@ -94,20 +84,10 @@ public static String getOverwriteStringForUser(User user) {
String name = org.getName();
if (name == null) continue;
name = name.toLowerCase();
if (overrideOrgs.contains(name)) return name + ".properties";
}
return null;
}

public static String getOverwriteStringForOrgName(String orgName) {
if (overrideOrgs.contains(orgName)) return orgName + ".properties";
return null;
}

public static boolean orgHasOverwrite(String orgName) {
return (getOverwriteStringForOrgName(orgName) != null);
}

public static boolean userHasOverrideString(User user) {
return (getOverwriteStringForUser(user) != null);
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/org/ecocean/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ public static boolean hasCustomProperties(HttpServletRequest request, Shepherd m

public static boolean hasCustomProperties(Shepherd myShepherd, HttpServletRequest request) {
if (request == null) return false;
String manualOrg = request.getParameter("organization");
if (Util.stringExists(manualOrg)) {
if (ShepherdProperties.orgHasOverwrite(manualOrg)) return true;
}
User user = myShepherd.getUser(request);
if (user == null) return false;
return user.hasCustomProperties();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/ecocean/servlet/ServletUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,7 @@ public static void importJsp(String filename, HttpServletRequest request,
request.getRequestDispatcher(filename).include(request, response);
}

// used to determine if we want to apply a custom UI style, e.g. for IndoCet or
// the New England Aquarium to a web page
// used to determine if we want to apply a custom UI style, e.g. the New England Aquarium to a web page
public static boolean useCustomStyle(HttpServletRequest request, String orgName) {
// check url for "organization=____" arg
String organization = request.getParameter("organization");
Expand Down
Loading

0 comments on commit c51f9fc

Please sign in to comment.