Changeset 29421


Ignore:
Timestamp:
2014-11-10T14:47:05+13:00 (9 years ago)
Author:
kjdon
Message:

adding in debug stuff for a collection, eg so that can run greenbug. Now the user can be all-collections-editor or collname-collection-editor. They are more likely to be one of these and want to use greenbug than they are to be an administrator

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r28966 r29421  
    678678
    679679            inlineTemplate = (String) params.get(GSParams.INLINE_TEMPLATE);
    680 
    681             if (params.get(GSParams.DEBUG) != null && (((String) params.get(GSParams.DEBUG)).equals("on") || ((String) params.get(GSParams.DEBUG)).equals("1") || ((String) params.get(GSParams.DEBUG)).equals("true")))
     680            String debug_p = (String) params.get(GSParams.DEBUG);
     681            if (debug_p != null && (debug_p.equals("on") || debug_p.equals("1") || debug_p.equals("true")))
    682682            {
    683683                String[] groups = new UserContext(request).getGroups();
     
    689689                    {
    690690                        found = true;
     691                        break;
     692                    }
     693                    if (!collection.equals("")) {
     694                      if (g.equals("all-collections-editor")) {
     695                        found = true;
     696                        break;
     697                      }
     698                     
     699                      if (g.equals(collection+"-collection-editor")) {
     700                        found = true;
     701                        break;
     702                      }
    691703                    }
    692704                }
     
    10351047            formatFile = "text_fragment_format.xsl";
    10361048        }
     1049
    10371050        String configStylesheet_file = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, formatFile);
    10381051        Document configStylesheet_doc = this.converter.getDOM(new File(configStylesheet_file));
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java

    r28966 r29421  
    8989        }
    9090
    91         UserContext context = new UserContext(request);
    92         boolean found = false;
    93         for (String group : context.getGroups())
    94         {
    95             if (group.equals("administrator"))
    96             {
    97                 found = true;
    98             }
    99         }
    100 
    101         if (!found)
    102         {
    103             GSXML.addError(result, "This user does not have the required permissions to perform this action.");
    104             return result;
    105         }
    106 
    10791        // Get the parameters of the request
    10892        Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     
    116100        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
    117101
     102        String collectionName = (String) params.get("collectionName");
     103
     104        // check permissions
     105        if (!userHasEditPermissions(collectionName, request)) {
     106          GSXML.addError(result, "This user does not have the required permissions to perform this action.");
     107          return result;
     108        }
    118109        String interfaceName = (String) params.get("interfaceName");
    119110        String siteName = (String) params.get("siteName");
    120         String collectionName = (String) params.get("collectionName");
    121111        String fileName = (String) params.get("fileName");
    122112        String nameToGet = (String) params.get("templateName");
     
    164154        }
    165155
    166         UserContext context = new UserContext(request);
    167         boolean found = false;
    168         for (String group : context.getGroups())
    169         {
    170             if (group.equals("administrator"))
    171             {
    172                 found = true;
    173             }
    174         }
    175 
    176         if (!found)
    177         {
    178             GSXML.addError(result, "This user does not have the required permissions to perform this action.");
    179             return result;
    180         }
    181 
    182156        // Get the parameters of the request
    183157        Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     
    190164
    191165        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
     166
     167
     168        String collectionName = (String) params.get("collectionName");
     169        // check permissions
     170        if (!userHasEditPermissions(collectionName, request)) {
     171          GSXML.addError(result, "This user does not have the required permissions to perform this action.");
     172          return result;
     173        }
    192174
    193175        String locationName = (String) params.get("locationName");
    194176        String interfaceName = (String) params.get("interfaceName");
    195177        String siteName = (String) params.get("siteName");
    196         String collectionName = (String) params.get("collectionName");
    197178        String fileName = (String) params.get("fileName");
    198179        String namespace = (String) params.get("namespace");
     
    202183        String xPath = (String) params.get("xpath");
    203184
     185
     186
    204187        String fullNamespace;
    205188        if (namespace.toLowerCase().equals("gsf"))
     
    318301        }
    319302
    320         UserContext context = new UserContext(request);
    321         boolean foundGroup = false;
    322         for (String group : context.getGroups())
    323         {
    324             if (group.equals("administrator"))
    325             {
    326                 foundGroup = true;
    327             }
    328         }
    329 
    330         if (!foundGroup)
    331         {
    332             GSXML.addError(result, "This user does not have the required permissions to perform this action.");
    333             return result;
    334         }
    335 
    336303        // Get the parameters of the request
    337304        Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     
    344311
    345312        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
     313
     314        String collectionName = (String) params.get("collectionName");
     315        // check permissions
     316        if (!userHasEditPermissions(collectionName, request)) {
     317          GSXML.addError(result, "This user does not have the required permissions to perform this action.");
     318          return result;
     319        }
    346320
    347321        String locationName = (String) params.get("locationName");
     
    349323        String interfaceName = (String) params.get("interfaceName");
    350324        String siteName = (String) params.get("siteName");
    351         String collectionName = (String) params.get("collectionName");
    352325        String namespace = (String) params.get("namespace");
    353326        String nodeName = (String) params.get("nodename");
     
    485458        }
    486459
    487         UserContext context = new UserContext(request);
    488         boolean found = false;
    489         for (String group : context.getGroups())
    490         {
    491             if (group.equals("administrator"))
    492             {
    493                 found = true;
    494             }
    495         }
    496 
    497         if (!found)
    498         {
    499             GSXML.addError(result, "This user does not have the required permissions to perform this action.");
    500             return result;
    501         }
    502 
    503460        // Get the parameters of the request
    504461        Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     
    512469        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
    513470
     471        String collectionName = (String) params.get("collectionName");
     472        // check permissions
     473        if (!userHasEditPermissions(collectionName, request)) {
     474          GSXML.addError(result, "This user does not have the required permissions to perform this action.");
     475          return result;
     476        }
    514477        String locationName = (String) params.get("locationName");
    515478        String siteName = (String) params.get("siteName");
    516         String collectionName = (String) params.get("collectionName");
    517479        String interfaceName = (String) params.get("interfaceName");
    518480        String fileName = (String) params.get("fileName");
     
    597559        }
    598560
    599         UserContext context = new UserContext(request);
    600         boolean found = false;
    601         for (String group : context.getGroups())
    602         {
    603             if (group.equals("administrator"))
    604             {
    605                 found = true;
    606             }
    607         }
    608 
    609         if (!found)
    610         {
    611             GSXML.addError(result, "This user does not have the required permissions to perform this action.");
    612             return result;
    613         }
    614 
    615561        // Get the parameters of the request
    616562        Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     
    624570        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
    625571
     572        String collectionName = (String) params.get("collectionName");
     573        // check permissions
     574        if (!userHasEditPermissions(collectionName, request)) {
     575          GSXML.addError(result, "This user does not have the required permissions to perform this action.");
     576          return result;
     577        }
    626578        String interfaceName = (String) params.get("interfaceName");
    627579        String siteName = (String) params.get("siteName");
    628         String collectionName = (String) params.get("collectionName");
    629580
    630581        Element fileList = result_doc.createElement("fileListJSON");
     
    700651        return result;
    701652    }
     653
     654  protected boolean userHasEditPermissions(String collection, Element request) {
     655    UserContext context = new UserContext(request);
     656    for (String group : context.getGroups()) {
     657      // administrator always has permission
     658      if (group.equals("administrator")) {
     659    return true;
     660      }
     661      // all-collections-editor can edit any collection
     662      if (!collection.equals("")) {
     663    if (group.equals("all-collections-editor")) {
     664      return true;
     665    }
     666    if (group.equals(collection+"-collection-editor")) {
     667      return true;
     668    }
     669      }
     670    }
     671    // haven't found a group with edit permissions
     672    return false;
     673   
     674  }
    702675}
     676
Note: See TracChangeset for help on using the changeset viewer.