Esempio n. 1
0
  protected void appendMessageFiles(
      IBasicFile sourceDashboardBaseMsgFile,
      IBasicFile globalBaseMessageFile,
      IBasicFile targetDashboardBaseMsgFile)
      throws IOException {

    Locale locale = CdeEngine.getEnv().getLocale();

    IUserContentAccess userContentAccess =
        CdeEngine.getEnv().getContentAccessFactory().getUserContentAccess(msgsRelativeDir);
    IRWAccess systemWriter =
        CdeEngine.getEnv()
            .getContentAccessFactory()
            .getPluginSystemWriter(Utils.joinPath(BASE_CACHE_DIR, msgsRelativeDir));

    // If localized global message file doesn't exists then use the standard base global message
    // file
    // and generate a fake global message file. So this way we're sure that we always have the file
    String localizedMsgGlobalName =
        BASE_GLOBAL_MESSAGE_SET_FILENAME + "_" + locale.getLanguage() + ".properties";

    if (userContentAccess.fileExists(localizedMsgGlobalName)) {

      systemWriter.saveFile(
          localizedMsgGlobalName, userContentAccess.getFileInputStream(localizedMsgGlobalName));

    } else if (globalBaseMessageFile != null) {

      systemWriter.saveFile(localizedMsgGlobalName, globalBaseMessageFile.getContents());
    }

    // Append specific message file only if it exists otherwise just use the global message files
    if (sourceDashboardBaseMsgFile != null) {

      systemWriter.saveFile(
          sourceDashboardBaseMsgFile.getName(), sourceDashboardBaseMsgFile.getContents());

      String localizedMsgTargetName =
          FilenameUtils.getBaseName(sourceDashboardBaseMsgFile.getName())
              + "_"
              + locale.getLanguage()
              + ".properties";

      if (userContentAccess.fileExists(localizedMsgTargetName)) {

        systemWriter.saveFile(
            localizedMsgTargetName, userContentAccess.getFileInputStream(localizedMsgTargetName));
      }
    }
  }
Esempio n. 2
0
  protected void copyStdGlobalMessageFileToCache() throws IOException {

    IBasicFile globalMsgCacheFile = getGlobalMsgCacheFile();

    if (globalMsgCacheFile != null && globalMsgCacheFile.getContents() != null) {
      return;

    } else {

      String globalMsgFileName = BASE_GLOBAL_MESSAGE_SET_FILENAME + ".properties";

      IBasicFile globalMsgFile =
          CdeEnvironment.getPluginSystemReader(SYSTEM_PLUGIN_GLOBAL_LANGUAGES_DIR)
              .fetchFile(globalMsgFileName);

      CdeEnvironment.getPluginSystemWriter()
          .saveFile(
              Utils.joinPath(BASE_CACHE_DIR, msgsRelativeDir, globalMsgFileName),
              globalMsgFile.getContents());
    }
  }