Exemple #1
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"));
    }
  }