Пример #1
0
  public Object load() {
    Object result = new JSONArray();

    try {
      GenericBasicFileFilter jsonFilter = new GenericBasicFileFilter(null, ".cdfde");

      List<IBasicFile> defaultTemplatesList =
          CdeEnvironment.getPluginSystemReader(SYSTEM_CDF_DD_TEMPLATES)
              .listFiles(null, jsonFilter, IReadAccess.DEPTH_ALL);

      if (defaultTemplatesList != null) {
        loadFiles(defaultTemplatesList.toArray(new IBasicFile[] {}), (JSONArray) result, "default");
      } else {
        result = Messages.getString("CdfTemplates.ERROR_002_LOADING_TEMPLATES_EXCEPTION");
      }

      List<IBasicFile> customTemplatesList =
          CdeEnvironment.getPluginRepositoryReader(REPOSITORY_CDF_DD_TEMPLATES_CUSTOM)
              .listFiles(null, jsonFilter, IReadAccess.DEPTH_ALL);
      if (customTemplatesList != null) {
        loadFiles(customTemplatesList.toArray(new IBasicFile[] {}), (JSONArray) result, "custom");
      }

    } catch (IOException e) {
      logger.error(e);
      result = Messages.getString("CdfTemplates.ERROR_002_LOADING_EXCEPTION");
    }
    return result;
  }
Пример #2
0
  public void save(String file, String structure) throws DashboardStructureException, IOException {
    logger.info("Saving File:" + file);
    IRWAccess access = CdeEnvironment.getPluginRepositoryWriter();

    if (!access.fileExists(REPOSITORY_CDF_DD_TEMPLATES_CUSTOM)) {
      access.createFolder(REPOSITORY_CDF_DD_TEMPLATES_CUSTOM);
    }

    structure = addDashboardStyleAndRendererTypeToTemplate(structure);

    byte[] fileData = structure.getBytes(CharsetHelper.getEncoding());
    if (!access.saveFile(
        Utils.joinPath(REPOSITORY_CDF_DD_TEMPLATES_CUSTOM, file),
        new ByteArrayInputStream(fileData))) {
      throw new DashboardStructureException(
          Messages.getString("DashboardStructure.ERROR_006_SAVE_FILE_ADD_FAIL_EXCEPTION"));
    }
  }
Пример #3
0
 // useful to mock message bundle when unit testing SyncronizerApi
 protected String getMessage(String key) {
   return Messages.getString(key);
 }