Changeset 33712


Ignore:
Timestamp:
2019-11-21T14:23:49+13:00 (4 years ago)
Author:
kjdon
Message:

modified createBasicRequest to use userContext methods, and to include editEnabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r33670 r33712  
    304304    public static final String USERNAME_ATT = "username";
    305305    public static final String GROUPS_ATT = "groups";
    306   public static final String EDIT_ENABLED_ATT = "editEnabled";
     306    public static final String EDIT_ENABLED_ATT = "editEnabled";
    307307    public static final String BASE_URL = "baseURL";
    308308
     
    925925 
    926926
    927     /** returns a basic request message */
    928     public static Element createBasicRequest(Document owner, String request_type, String to, UserContext userContext)
    929     {
    930         Element request = owner.createElement(REQUEST_ELEM);
    931         request.setAttribute(TO_ATT, to);
    932         request.setAttribute(TYPE_ATT, request_type);
    933         if (userContext != null) { // should we allow this??
    934           request.setAttribute(LANG_ATT, userContext._lang);
    935           Element userContextElem = owner.createElement("userContext");
    936           request.appendChild(userContextElem);
    937           userContextElem.setAttribute(LANG_ATT, userContext._lang);
    938           userContextElem.setAttribute(USERNAME_ATT, userContext._username);
    939           userContextElem.setAttribute(USER_ID_ATT, userContext._userID);
    940          
    941           if (userContext._groups != null)
    942             {
    943               String groupString = "";
    944               for (int i = 0; i < userContext._groups.length; i++)
    945             {
    946               groupString += userContext._groups[i];
    947               if (i != userContext._groups.length - 1)
    948                 {
    949                   groupString += ",";
    950                 }
    951             }
    952              
    953               if (groupString.length() > 0)
    954             {
    955               userContextElem.setAttribute(GROUPS_ATT, groupString);
    956             }
    957             }
    958         }
    959         return request;
    960     }
     927    /** returns a basic request message */
     928    public static Element createBasicRequest(Document owner, String request_type, String to, UserContext userContext)
     929    {
     930    Element request = owner.createElement(REQUEST_ELEM);
     931    request.setAttribute(TO_ATT, to);
     932    request.setAttribute(TYPE_ATT, request_type);
     933    if (userContext == null) {
     934        return request; // should we allow this??
     935    }
     936    request.setAttribute(LANG_ATT, userContext.getLanguage());
     937    Element userContextElem = owner.createElement("userContext");
     938    request.appendChild(userContextElem);
     939    userContextElem.setAttribute(LANG_ATT, userContext.getLanguage());
     940    userContextElem.setAttribute(USERNAME_ATT, userContext.getUsername());
     941    userContextElem.setAttribute(USER_ID_ATT, userContext.getUserID());
     942    userContextElem.setAttribute(GROUPS_ATT, userContext.getGroupsString());
     943    userContextElem.setAttribute(EDIT_ENABLED_ATT, userContext.getEditEnabled());
     944   
     945    return request;
     946    }
    961947
    962948    public static Element createBasicResponse(Document owner, String from)
Note: See TracChangeset for help on using the changeset viewer.