コード例 #1
0
 void handleArchivedForSavePackage(PackageConfigData data, PackageItem item) {
   for (Iterator<AssetItem> iter = item.getAssets(); iter.hasNext(); ) {
     AssetItem assetItem = iter.next();
     if (!assetItem.isArchived()) {
       assetItem.archiveItem(true);
       assetItem.checkin(data.getDescription());
     }
   }
 }
コード例 #2
0
 void handleUnarchivedForSavePackage(
     PackageConfigData data, PackageItem item, Calendar packageLastModified) {
   for (Iterator<AssetItem> iter = item.getAssets(); iter.hasNext(); ) {
     AssetItem assetItem = iter.next();
     // Unarchive the assets archived after the package
     // ( == at the same time that the package was archived)
     if (assetItem.getLastModified().compareTo(packageLastModified) >= 0) {
       assetItem.archiveItem(false);
       assetItem.checkin(data.getDescription());
     }
   }
 }
コード例 #3
0
 protected String[] listImagesInPackage(String packageName) throws SerializationException {
   // load package
   PackageItem item = rulesRepository.loadPackage(packageName);
   List<String> retList = new ArrayList<String>();
   Iterator<AssetItem> iter = item.getAssets();
   while (iter.hasNext()) {
     AssetItem pitem = iter.next();
     if (pitem.getFormat().equalsIgnoreCase("png")
         || pitem.getFormat().equalsIgnoreCase("gif")
         || pitem.getFormat().equalsIgnoreCase("jpg")) {
       retList.add(pitem.getName());
     }
   }
   return (String[]) retList.toArray(new String[] {});
 }
コード例 #4
0
 private ValidatedResponse validateBRMSSuggestionCompletionLoaderResponse(
     BRMSSuggestionCompletionLoader loader) {
   ValidatedResponse res = new ValidatedResponse();
   if (loader.hasErrors()) {
     res.hasErrors = true;
     String err = "";
     for (Iterator iter = loader.getErrors().iterator(); iter.hasNext(); ) {
       err += (String) iter.next();
       if (iter.hasNext()) err += "\n";
     }
     res.errorHeader = "Package validation errors";
     res.errorMessage = err;
   }
   return res;
 }
コード例 #5
0
  /** @deprecated in favour of {@link compareSnapshots(SnapshotComparisonPageRequest)} */
  protected SnapshotDiffs compareSnapshots(
      String packageName, String firstSnapshotName, String secondSnapshotName) {
    SnapshotDiffs diffs = new SnapshotDiffs();
    List<SnapshotDiff> list = new ArrayList<SnapshotDiff>();

    PackageItem leftPackage = rulesRepository.loadPackageSnapshot(packageName, firstSnapshotName);
    PackageItem rightPackage = rulesRepository.loadPackageSnapshot(packageName, secondSnapshotName);

    // Older one has to be on the left.
    if (isRightOlderThanLeft(leftPackage, rightPackage)) {
      PackageItem temp = leftPackage;
      leftPackage = rightPackage;
      rightPackage = temp;

      diffs.leftName = secondSnapshotName;
      diffs.rightName = firstSnapshotName;
    } else {
      diffs.leftName = firstSnapshotName;
      diffs.rightName = secondSnapshotName;
    }

    Iterator<AssetItem> leftExistingIter = leftPackage.getAssets();
    while (leftExistingIter.hasNext()) {
      AssetItem left = leftExistingIter.next();
      if (isPackageItemDeleted(rightPackage, left)) {
        SnapshotDiff diff = new SnapshotDiff();

        diff.name = left.getName();
        diff.diffType = SnapshotDiff.TYPE_DELETED;
        diff.leftUuid = left.getUUID();

        list.add(diff);
      }
    }

    Iterator<AssetItem> rightExistingIter = rightPackage.getAssets();
    while (rightExistingIter.hasNext()) {
      AssetItem right = rightExistingIter.next();
      AssetItem left = null;
      if (right != null && leftPackage.containsAsset(right.getName())) {
        left = leftPackage.loadAsset(right.getName());
      }

      // Asset is deleted or added
      if (right == null || left == null) {
        SnapshotDiff diff = new SnapshotDiff();

        if (left == null) {
          diff.name = right.getName();
          diff.diffType = SnapshotDiff.TYPE_ADDED;
          diff.rightUuid = right.getUUID();
        }

        list.add(diff);
      } else if (isAssetArchivedOrRestored(right, left)) { // Has the asset
        // been archived
        // or restored
        SnapshotDiff diff = new SnapshotDiff();

        diff.name = right.getName();
        diff.leftUuid = left.getUUID();
        diff.rightUuid = right.getUUID();

        if (left.isArchived()) {
          diff.diffType = SnapshotDiff.TYPE_RESTORED;
        } else {
          diff.diffType = SnapshotDiff.TYPE_ARCHIVED;
        }

        list.add(diff);
      } else if (isAssetItemUpdated(right, left)) { // Has the asset been
        // updated
        SnapshotDiff diff = new SnapshotDiff();

        diff.name = right.getName();
        diff.leftUuid = left.getUUID();
        diff.rightUuid = right.getUUID();
        diff.diffType = SnapshotDiff.TYPE_UPDATED;

        list.add(diff);
      }
    }

    diffs.diffs = list.toArray(new SnapshotDiff[list.size()]);
    return diffs;
  }