# NameTokens.java

    /*
    ** Module   : NameTokens.java
    ** Abstract : Application places.
    **
    ** Copyright (c) 2017-2024, Golden Code Development Corporation.
    **
    ** -#- -I- --Date-- --------------------------------Description-----------------------------------
    ** 001 HC  20170612 Initial version.
    ** 002 EVL 20170926 Javadoc fixes.
    ** 003 GBB 20230825 Added OS users menu item / route.
    ** 004 GBB 20241010 Added OS /console/appservers route.
    */
    /*
    ** This program is free software: you can redistribute it and/or modify
    ** it under the terms of the GNU Affero General Public License as
    ** published by the Free Software Foundation, either version 3 of the
    ** License, or (at your option) any later version.
    **
    ** This program is distributed in the hope that it will be useful,
    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    ** GNU Affero General Public License for more details.
    **
    ** You may find a copy of the GNU Affero GPL version 3 at the following
    ** location: https://www.gnu.org/licenses/agpl-3.0.en.html
    **
    ** Additional terms under GNU Affero GPL version 3 section 7:
    **
    **   Under Section 7 of the GNU Affero GPL version 3, the following additional
    **   terms apply to the works covered under the License.  These additional terms
    **   are non-permissive additional terms allowed under Section 7 of the GNU
    **   Affero GPL version 3 and may not be removed by you.
    **
    **   0. Attribution Requirement.
    **
    **     You must preserve all legal notices or author attributions in the covered
    **     work or Appropriate Legal Notices displayed by works containing the covered
    **     work.  You may not remove from the covered work any author or developer
    **     credit already included within the covered work.
    **
    **   1. No License To Use Trademarks.
    **
    **     This license does not grant any license or rights to use the trademarks
    **     Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
    **     of Golden Code Development Corporation. You are not authorized to use the
    **     name Golden Code, FWD, or the names of any author or contributor, for
    **     publicity purposes without written authorization.
    **
    **   2. No Misrepresentation of Affiliation.
    **
    **     You may not represent yourself as Golden Code Development Corporation or FWD.
    **
    **     You may not represent yourself for publicity purposes as associated with
    **     Golden Code Development Corporation, FWD, or any author or contributor to
    **     the covered work, without written authorization.
    **
    **   3. No Misrepresentation of Source or Origin.
    **
    **     You may not represent the covered work as solely your work.  All modified
    **     versions of the covered work must be marked in a reasonable way to make it
    **     clear that the modified work is not originating from Golden Code Development
    **     Corporation or FWD.  All modified versions must contain the notices of
    **     attribution required in this license.
    */

    package com.goldencode.p2j.admin.client;

    import java.util.Map;

    import com.gwtplatform.mvp.shared.proxy.PlaceRequest;

    /**
     * Encapsulates all navigable application places.
     */
    public class NameTokens
    {
       /** Login place */
       public static final String LOGIN     = "/login";

       /** Home place */
       public static final String HOME      = "/home";

       /** Console Sessions place */
       public static final String SESSIONS  = "/console/sessions";

       /** Console Appservers place */
       public static final String APPSERVERS  = "/console/appservers";

       /** Console Locks place */
       public static final String LOCKS     = "/console/locks";

       /** Console Acquires Locks place */
       public static final String ACQUIRED_LOCKS = "/console/acquired-locks";

       /** Accounts Groups place */
       public static final String GROUPS    = "/accounts/groups";

       /** Accounts Users place */
       public static final String USERS     = "/accounts/users";

       /** Accounts OS Users place */
       public static final String OS_USERS  = "/accounts/os-users";

       /** Accounts Processes place */
       public static final String PROCESSES = "/accounts/processes";

       /** Accounts Certificates place */
       public static final String CERTS     = "/accounts/certificates";

       /** Custom Libraries place */
       public static final String CUSTOM_LIBRARIES = "/runtime/custom-libraries";

       /**
        * ACL place
        * may contain parameters r (resource type), a (account) and f (filter),
        * the resulting token value may be /acl?r=system&amp;a=somename&amp;f=whatever
        */
       public static final String ACL = "/acl";

       /** ACL Subjects place */
       public static final String ACL_SUBJECTS = "/acl/subjects";

       /** Messages place */
       public static final String SERVER_MESSAGES = "/help/messages";

       /** Print Preview place */
       public static final String PRINT_PREVIEW = "/print/preview";

       /** Token parameter name */
       private static final String TOKEN = "token";

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getLogin()
       {
          return LOGIN;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getSessions()
       {
          return SESSIONS;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getAppservers()
       {
          return APPSERVERS;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getGroups()
       {
          return GROUPS;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getCustomLibraries()
       {
          return CUSTOM_LIBRARIES;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getUsers()
       {
          return USERS;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getOsUsers()
       {
          return OS_USERS;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getProcesses()
       {
          return PROCESSES;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getCerts()
       {
          return CERTS;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getLocks()
       {
          return LOCKS;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getAcquiredLocks()
       {
          return ACQUIRED_LOCKS;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getACL()
       {
          return ACL;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getServerMessages()
       {
          return SERVER_MESSAGES;
       }

       /**
        * Place getter.
        *
        * @return  The place name.
        */
       public static String getPrintPreview()
       {
          return PRINT_PREVIEW;
       }

       /**
        * Builds ACL place request.
        *
        * @param   account
        *          The account name.
        *
        * @return  the place request reference
        */
       public static PlaceRequest buildACLPlaceRequest(String account)
       {
          return new PlaceRequest.Builder()
                      .nameToken(NameTokens.ACL)
                      .with("a", account)
                      .build();
       }

       /**
        * Builds ACL place request.
        *
        * @param   resourceType
        *          The resource type.
        *
        * @return  the place request reference
        */
       public static PlaceRequest buildACLResourcePlaceRequest(String resourceType)
       {
          return new PlaceRequest.Builder()
                      .nameToken(NameTokens.ACL)
                      .with("r", resourceType)
                      .build();
       }

       /**
        * Builds ACL place request.
        *
        * @param   resourceType
        *          The resource type.
        * @param   account
        *          The account name.
        * @param   name
        *          Resource instance name.
        *
        * @return  the place request reference
        */
       public static PlaceRequest buildACLResourcePlaceRequest(String resourceType,
                                                               String account,
                                                               String name)
       {
          PlaceRequest.Builder b = new PlaceRequest.Builder().nameToken(NameTokens.ACL);

          if (resourceType != null)
          {
             b = b.with("r", resourceType);
          }

          if (account != null)
          {
             b = b.with("a", account);
          }

          if (name != null)
          {
             b = b.with("n", name);
          }

          return b.build();
       }

       /**
        * Builds report place request.
        *
        * @param    path
        *           The path to the parent view.
        * @param    parametersMap
        *           The given parameters map
        *
        * @return   the place request reference
        */
       public static PlaceRequest getReportParentPlaceRequest(String path,
                                                              Map<String, String> parametersMap)
       {
          return new PlaceRequest.Builder().nameToken(path).with(parametersMap).build();
       }

       /**
        * Place getter.
        *
        *
        * @return   The place name.
        */
       public static PlaceRequest getHomeRequest()
       {
          return new PlaceRequest.Builder().nameToken(NameTokens.HOME).build();
       }

       /**
        * Returns the token parameter name to form GET request.
        *
        * @return   The token parameter name
        */
       public static String getTokenParameter()
       {
          return TOKEN;
       }
    }