public static String getSiteKey() {
   if (siteKey == null) {
     if (jahiaParamDictionary.keySet().contains(SITE_KEY)) {
       siteKey = jahiaParamDictionary.get(SITE_KEY);
     } else {
       siteKey = "";
     }
   }
   return siteKey;
 }
 public static String getWorkspace() {
   if (workspace == null) {
     if (jahiaParamDictionary.keySet().contains(WORKSPACE)) {
       workspace = jahiaParamDictionary.get(WORKSPACE);
     } else {
       workspace = "";
     }
   }
   return workspace;
 }
 public static String getSiteUUID() {
   if (siteUUID == null) {
     if (jahiaParamDictionary.keySet().contains(SITE_UUID)) {
       siteUUID = jahiaParamDictionary.get(SITE_UUID);
     } else {
       siteUUID = "";
     }
   }
   return siteUUID;
 }
Beispiel #4
0
  /**
   * Returns the string value associated with the given key.
   *
   * <p>If the {@code Dictionary} doesn't contain the value associated with given key, then return
   * the fallback value. If the fallback value isn't defined for given key, then return empty
   * string.
   *
   * @param key The key
   * @return The message, either from the {@code Dictionary} or the fallback value.
   */
  protected String getString(final DynamicMessageKey key) {
    try {
      if (dictionary != null) {
        return dictionary.get(key.getValue());
      }
    } catch (MissingResourceException mre) {
      // Do nothing, the key doesn't exist.
    }

    String fallback = fallbackValues.get(key);
    if (fallback == null) {
      // Use empty string for missing fallback value.
      fallback = ""; // $NON-NLS-1$
    }

    return fallback;
  }
 public static String getServiceEntryPoint() {
   return jahiaParamDictionary.get(SERVICE_ENTRY_POINT);
 }
/** Created by Jahia. User: ktlili Date: 31 oct. 2007 Time: 11:01:16 */
public class JahiaGWTParameters {
  public static final String SERVICE_ENTRY_POINT = "serviceEntryPoint";
  public static final String JAHIA_GWT_PARAMETERS = "jahiaGWTParameters";
  public static final String CURRENT_USER_NAME = "currentUser";
  public static final String COPYRIGHT = "copyright";
  public static final String UI_LANGUAGE = "uilang";
  public static final String UI_LANGUAGE_DISPLAY_NAME = "uilangdisplayname";
  public static final String LANGUAGE = "lang";
  public static final String LANGUAGE_DISPLAY_NAME = "langdisplayname";
  public static final String SITE_UUID = "siteUuid";
  public static final String SITE_KEY = "siteKey";
  public static final String WORKSPACE = "workspace";
  public static final String PATH_INFO = "pathInfo";
  public static final String CONTEXT_PATH = "contextPath";
  public static final String SERVLET_PATH = "servletPath";
  public static final String QUERY_STRING = "queryString";
  public static final String STUDIO_URL = "studioUrl";
  public static final String BASE_URL = "baseUrl";

  public static final String SYSTEM_USER = "******"; // org.jahia.jaas.JahiaLoginModule.SYSTEM

  private static Dictionary jahiaParamDictionary = Dictionary.getDictionary(JAHIA_GWT_PARAMETERS);
  private static String baseUrl;
  private static String language;
  private static String languageDisplayName;
  private static String siteUUID;
  private static String siteKey;
  private static String workspace;

  private static String sitesLocation;
  private static Map<String, GWTJahiaNode> sitesMap;
  private static GWTJahiaNode siteNode;

  public static String getServiceEntryPoint() {
    return jahiaParamDictionary.get(SERVICE_ENTRY_POINT);
  }

  public static String getCurrentUser() {
    return jahiaParamDictionary.get(CURRENT_USER_NAME);
  }

  public static String getPathInfo() {
    return jahiaParamDictionary.get(PATH_INFO);
  }

  public static String getQueryString() {
    return jahiaParamDictionary.get(QUERY_STRING);
  }

  public static String getCopyright() {
    return jahiaParamDictionary.get(COPYRIGHT);
  }

  public static String getUILanguage() {
    return jahiaParamDictionary.get(UI_LANGUAGE);
  }

  public static String getUILanguageDisplayName() {
    return jahiaParamDictionary.get(UI_LANGUAGE_DISPLAY_NAME);
  }

  public static String getLanguageDisplayName() {
    if (languageDisplayName == null) {
      languageDisplayName = jahiaParamDictionary.get(LANGUAGE_DISPLAY_NAME);
    }
    return languageDisplayName;
  }

  public static String getLanguage() {
    if (language == null) {
      language = jahiaParamDictionary.get(LANGUAGE);
    }
    return language;
  }

  public static void setLanguage(GWTJahiaLanguage newLanguage) {
    language = newLanguage.getLanguage();
    languageDisplayName = newLanguage.getDisplayName();

    for (UrlUpdater urlUpdater : updaters) {
      urlUpdater.updateEntryPointUrl();
    }
    baseUrl = getBaseUrl();
    baseUrl = baseUrl.substring(0, baseUrl.lastIndexOf('/') + 1) + language;
    setNativeLanguage(newLanguage.getLanguage());
  }

  private static native void setNativeLanguage(String newLanguage) /*-{
        $wnd.jahiaGWTParameters.lang  = newLanguage;
        if ($wnd.contextJsParameters) {
            $wnd.contextJsParameters.lang = newLanguage;
        }
    }-*/;

  public static String getSiteUUID() {
    if (siteUUID == null) {
      if (jahiaParamDictionary.keySet().contains(SITE_UUID)) {
        siteUUID = jahiaParamDictionary.get(SITE_UUID);
      } else {
        siteUUID = "";
      }
    }
    return siteUUID;
  }

  private static void setSiteUUID(String newSiteUUID) {
    siteUUID = newSiteUUID;
    for (UrlUpdater urlUpdater : updaters) {
      urlUpdater.updateEntryPointUrl();
    }
    setNativeSiteUUID(newSiteUUID);
  }

  private static native void setNativeSiteUUID(String newSiteUUID) /*-{
        $wnd.jahiaGWTParameters.siteUuid  = newSiteUUID;
        if ($wnd.contextJsParameters) {
            $wnd.contextJsParameters.siteUuid = newSiteUUID;
        }
    }-*/;

  public static String getSiteKey() {
    if (siteKey == null) {
      if (jahiaParamDictionary.keySet().contains(SITE_KEY)) {
        siteKey = jahiaParamDictionary.get(SITE_KEY);
      } else {
        siteKey = "";
      }
    }
    return siteKey;
  }

  private static void setSiteKey(String newSiteKey) {
    siteKey = newSiteKey;
    setNativeSiteKey(newSiteKey);
  }

  private static native void setNativeSiteKey(String newSiteKey) /*-{
        $wnd.jahiaGWTParameters.siteKey  = newSiteKey;
    }-*/;

  public static GWTJahiaNode getSiteNode() {
    return siteNode;
  }

  public static void setSiteNode(GWTJahiaNode siteNode) {
    JahiaGWTParameters.siteNode = siteNode;

    setSiteUUID(siteNode.getSiteUUID());
    setSiteKey(siteNode.getSiteKey());
  }

  public static List<GWTJahiaLanguage> getSiteLanguages() {
    return (List<GWTJahiaLanguage>) getSiteNode().get(GWTJahiaNode.SITE_LANGUAGES);
  }

  public static String getSitesLocation() {
    return sitesLocation;
  }

  public static void setSitesLocation(String sitesLocation) {
    JahiaGWTParameters.sitesLocation = sitesLocation;
  }

  public static Map<String, GWTJahiaNode> getSitesMap() {
    return sitesMap;
  }

  public static void setSitesMap(Map<String, GWTJahiaNode> sitesMap) {
    JahiaGWTParameters.sitesMap = sitesMap;
  }

  public static void setSite(GWTJahiaNode node, Linker linker) {
    setSiteNode(sitesMap.get(node.getSiteUUID()));
    if (linker != null) {
      DeployTemplatesActionItem.refreshAllMenus(linker);
    }
  }

  public static String getWorkspace() {
    if (workspace == null) {
      if (jahiaParamDictionary.keySet().contains(WORKSPACE)) {
        workspace = jahiaParamDictionary.get(WORKSPACE);
      } else {
        workspace = "";
      }
    }
    return workspace;
  }

  public static void setWorkspace(String newWorkspace) {
    workspace = newWorkspace;
    for (UrlUpdater urlUpdater : updaters) {
      urlUpdater.updateEntryPointUrl();
    }
    setNativeWorkspace(newWorkspace);
  }

  private static native void setNativeWorkspace(String newWorkspace) /*-{
        $wnd.jahiaGWTParameters.workspace  = newWorkspace;
    }-*/;

  public static String getContextPath() {
    return jahiaParamDictionary.get(CONTEXT_PATH);
  }

  public static String getServletPath() {
    return jahiaParamDictionary.get(SERVLET_PATH);
  }

  public static String getParameter(String name) {
    return jahiaParamDictionary.get(name);
  }

  public static String getBaseUrl() {
    if (baseUrl == null) {
      baseUrl = jahiaParamDictionary.get(BASE_URL);
    }
    return baseUrl;
  }

  /**
   * @param name the parameter to get
   * @return return null if the param is not present in the dictionary instead of throwing a missing
   *     resource exception
   */
  public static String getParam(String name) {
    if (!jahiaParamDictionary.keySet().contains(name)) {
      return null;
    }
    return jahiaParamDictionary.get(name);
  }

  public static void addUpdater(UrlUpdater updater) {
    updaters.add(updater);
  }

  static List<UrlUpdater> updaters = new ArrayList<UrlUpdater>();

  public static interface UrlUpdater {
    void updateEntryPointUrl();
  }

  public static void refreshSitesList() {
    JahiaContentManagementService.App.getInstance()
        .getRoot(
            Arrays.asList(sitesLocation),
            Arrays.asList("jnt:virtualsite"),
            null,
            null,
            GWTJahiaNode.DEFAULT_SITE_FIELDS,
            null,
            null,
            false,
            false,
            null,
            null,
            new BaseAsyncCallback<List<GWTJahiaNode>>() {
              public void onSuccess(List<GWTJahiaNode> sites) {
                sitesMap.clear();
                for (GWTJahiaNode site : sites) {
                  sitesMap.put(site.getUUID(), site);
                }
              }
            });
  }
}
 /**
  * @param name the parameter to get
  * @return return null if the param is not present in the dictionary instead of throwing a missing
  *     resource exception
  */
 public static String getParam(String name) {
   if (!jahiaParamDictionary.keySet().contains(name)) {
     return null;
   }
   return jahiaParamDictionary.get(name);
 }
 public static String getBaseUrl() {
   if (baseUrl == null) {
     baseUrl = jahiaParamDictionary.get(BASE_URL);
   }
   return baseUrl;
 }
 public static String getParameter(String name) {
   return jahiaParamDictionary.get(name);
 }
Beispiel #10
0
 public BaseDynamicMessages() {
   this(Dictionary.getDictionary(MESSAGES_DICTIONARY_NAME));
 }
 public static String getQueryString() {
   return jahiaParamDictionary.get(QUERY_STRING);
 }
 public static String getLanguage() {
   if (language == null) {
     language = jahiaParamDictionary.get(LANGUAGE);
   }
   return language;
 }
 public static String getLanguageDisplayName() {
   if (languageDisplayName == null) {
     languageDisplayName = jahiaParamDictionary.get(LANGUAGE_DISPLAY_NAME);
   }
   return languageDisplayName;
 }
 public static String getUILanguageDisplayName() {
   return jahiaParamDictionary.get(UI_LANGUAGE_DISPLAY_NAME);
 }
 public static String getUILanguage() {
   return jahiaParamDictionary.get(UI_LANGUAGE);
 }
 public static String getCurrentUser() {
   return jahiaParamDictionary.get(CURRENT_USER_NAME);
 }
 public static String getPathInfo() {
   return jahiaParamDictionary.get(PATH_INFO);
 }
 public static String getContextPath() {
   return jahiaParamDictionary.get(CONTEXT_PATH);
 }
 public static String getCopyright() {
   return jahiaParamDictionary.get(COPYRIGHT);
 }
 public static String getServletPath() {
   return jahiaParamDictionary.get(SERVLET_PATH);
 }