/** {@inheritDoc} */
 @Override
 public boolean updateReportModel(ReportDesignModel model, boolean modelInCache) {
   ReportDesignModel persModel = DeepcopyUtils.deepCopy(model);
   // 如果当前model在编辑状态,需要更新持久化的model的name
   if (isNameExist(model.getName(), model.getId())) {
     return false;
   }
   if (modelInCache) {
     persModel = getModelByIdOrName(model.getId(), false);
   }
   try {
     try {
       this.deleteModel(persModel, true);
     } catch (Exception e) {
       try {
         fileService.rm(generateOriDevReportLocation(persModel));
       } catch (FileServiceException e1) {
         throw new ReportModelOperationException(e1);
       }
     }
     persModel.setName(model.getName());
     this.saveOrUpdateModel(persModel);
   } catch (ReportModelOperationException e) {
     logger.error(e.getMessage(), e);
     return false;
   }
   return true;
 }
 @Deprecated
 private String getOriReleaseReportLocation(ReportDesignModel model) {
   if (model == null) {
     return null;
   }
   String name = model.getName();
   String productLine = ContextManager.getProductLine();
   try {
     String[] listFile = fileService.ls(this.getReleaseReportDir());
     for (String file : listFile) {
       if (file.startsWith(model.getId())) {
         return productLine
             + File.separator
             + reportBaseDir
             + File.separator
             + "release"
             + File.separator
             + file;
       }
     }
   } catch (FileServiceException e) {
     logger.error(e.getMessage(), e);
   }
   return productLine
       + File.separator
       + reportBaseDir
       + File.separator
       + "release"
       + File.separator
       + model.getId()
       + Constants.FILE_NAME_SEPERATOR
       + name;
 }
 /**
  * 依据model对象生成持久化文件名称
  *
  * @param model
  * @return
  */
 private String generateDevReportLocation(ReportDesignModel model) {
   if (model == null) {
     return null;
   }
   StringBuilder builder = new StringBuilder();
   builder.append(getDevReportDir());
   builder.append(File.separator);
   builder.append(model.getId());
   builder.append(Constants.FILE_NAME_SEPERATOR);
   builder.append(model.getName().hashCode());
   builder.append(Constants.FILE_NAME_SEPERATOR);
   builder.append(model.getDsId());
   return builder.toString();
 }
 /**
  * 获取发布的报表的存储路径
  *
  * @return
  */
 private String getReleaseReportLocation(ReportDesignModel model) {
   if (model == null) {
     return null;
   }
   String productLine = ContextManager.getProductLine();
   return productLine
       + File.separator
       + reportBaseDir
       + File.separator
       + "release"
       + File.separator
       + model.getId()
       + Constants.FILE_NAME_SEPERATOR
       + model.getName().hashCode();
 }
  /** {@inheritDoc} */
  @Override
  public ReportDesignModel saveOrUpdateModel(ReportDesignModel model)
      throws ReportModelOperationException {
    if (model == null) {
      logger.warn("current model is null");
      throw new ReportModelOperationException("model can not be null");
    }
    if (StringUtils.isEmpty(model.getName())) {
      logger.debug("model's name can not be empty");
      throw new ReportModelOperationException("model's name can not be empty");
    }
    if (StringUtils.isEmpty(model.getId())) {
      model.setId(UuidGeneratorUtils.generate());
    }
    try {
      ReportDesignModel oldReport = getModelByIdOrName(model.getId(), false);
      if (oldReport != null) {
        try {
          this.deleteModel(oldReport, true);
        } catch (Exception e) {
          try {
            fileService.rm(generateOriDevReportLocation(model));
          } catch (Exception e1) {
            logger.error(e.getMessage(), e);
          }
        }
      }
      boolean rs =
          fileService.write(generateDevReportLocation(model), SerializationUtils.serialize(model));
      if (rs) {
        return model;
      }
    } catch (FileServiceException e) {
      logger.error(e.getMessage(), e);
    }

    return null;
  }