コード例 #1
0
  @Override
  public void importData(ImportStrategy importStrategy) throws Exception {
    PortalData dst =
        dataStorage.getPortalConfig(new PortalKey(siteKey.getTypeName(), siteKey.getName()));

    switch (importStrategy) {
        // Really doesn't make sense to "merge" site layout data.  Really two modes, conserve (keep)
        // and overwrite.
      case CONSERVE:
        if (dst == null) {
          dst = data;
          rollbackDelete = data;
        } else {
          dst = null;
        }
        break;
      case MERGE:
      case OVERWRITE:
        if (dst == null) {
          rollbackDelete = data;
        } else {
          rollbackSave = dst;
        }
        dst = data;
        break;
    }

    if (dst != null) {
      if (rollbackDelete == null) {
        dataStorage.save(dst);
      } else {
        dataStorage.create(dst);
      }
    }
  }
コード例 #2
0
 @Override
 public void rollback() throws Exception {
   if (rollbackDelete != null) {
     dataStorage.remove(rollbackDelete);
   } else if (rollbackSave != null) {
     dataStorage.save(rollbackSave);
   }
 }