Ejemplo n.º 1
0
 /** For the time being, module == package */
 public void updateWorkspace(
     String workspace, String[] selectedModules, String[] unselectedModules) {
   for (String moduleName : selectedModules) {
     ModuleItem module = rulesRepository.loadModule(moduleName);
     module.addWorkspace(workspace);
     module.checkin("Add workspace");
   }
   for (String moduleName : unselectedModules) {
     ModuleItem module = rulesRepository.loadModule(moduleName);
     module.removeWorkspace(workspace);
     module.checkin("Remove workspace");
   }
 }
Ejemplo n.º 2
0
  /** This will create a new asset which refers to an existing asset */
  public String createNewImportedRule(String sharedAssetName, String initialPackage)
      throws SerializationException {
    log.info(
        "USER:"******" CREATING shared asset imported from global area named ["
            + sharedAssetName
            + "] in package ["
            + initialPackage
            + "]");

    try {
      ModuleItem packageItem = rulesRepository.loadModule(initialPackage);
      AssetItem asset = packageItem.addAssetImportedFromGlobalArea(sharedAssetName);
      rulesRepository.save();

      return asset.getUUID();
    } catch (RulesRepositoryException e) {
      // If we want to display an explicit error message of "duplicate asset", we can achieve this
      // in client error handler.
      /*            if ( e.getCause() instanceof ItemExistsException ) {
          return "DUPLICATE";
      }*/
      log.error(
          "An error occurred creating shared asset"
              + sharedAssetName
              + "] in package ["
              + initialPackage
              + "]: ",
          e);
      throw new SerializationException(e.getMessage());
    }
  }
Ejemplo n.º 3
0
 /** @deprecated in favour of {@link #findAssetPage(AssetPageRequest)} */
 @WebRemote
 @LoggedIn
 public TableDataResult listAssetsWithPackageName(
     String packageName, String formats[], int skip, int numRows, String tableConfig)
     throws SerializationException {
   ModuleItem pkg = rulesRepository.loadModule(packageName);
   return listAssets(pkg.getUUID(), formats, skip, numRows, tableConfig);
 }
Ejemplo n.º 4
0
  /**
   * This will create a new asset. It will be saved, but not checked in. The initial state will be
   * the draft state. Returns the UUID of the asset.
   */
  public String createNewRule(
      NewAssetWithContentConfiguration<? extends PortableObject> configuration)
      throws SerializationException {

    final String assetName = configuration.getAssetName();
    final String description = configuration.getDescription();
    final String initialCategory = configuration.getInitialCategory();
    final String packageName = configuration.getPackageName();
    final String format = configuration.getFormat();
    final PortableObject content = configuration.getContent();

    log.info(
        "USER:"******" CREATING new asset name ["
            + assetName
            + "] in package ["
            + packageName
            + "]");

    try {

      // Create new Asset
      ModuleItem pkg = rulesRepository.loadModule(packageName);
      AssetItem assetItem = pkg.addAsset(assetName, description, initialCategory, format);

      // Set the Assets content - no need to use AssetTemplateCreator().applyPreBuiltTemplates() as
      // we are provided a model
      // Use a transient Asset object so we can use ContentHandler to convert between model and
      // persisted format correctly.
      Asset asset = new AssetPopulator().populateFrom(assetItem);
      ContentHandler handler = ContentManager.getHandler(assetItem.getFormat());
      asset.setContent(content);
      handler.storeAssetContent(asset, assetItem);

      rulesRepository.save();

      push("categoryChange", initialCategory);
      push("packageChange", pkg.getName());

      return assetItem.getUUID();

    } catch (RulesRepositoryException e) {
      // If we want to display an explicit error message of "duplicate asset", we can achieve this
      // in client error handler.
      /*            if ( e.getCause() instanceof ItemExistsException ) {
          return "DUPLICATE";
      }*/
      log.error(
          "An error occurred creating new asset ["
              + assetName
              + "] in package ["
              + packageName
              + "]: ",
          e);
      throw new SerializationException(e.getMessage());
    }
  }
Ejemplo n.º 5
0
  /**
   * Check whether an asset exists in a package
   *
   * @param assetName
   * @param moduleName
   * @return True if the asset already exists in the module
   * @throws SerializationException
   */
  public boolean doesAssetExistInModule(String assetName, String moduleName)
      throws SerializationException {
    try {

      ModuleItem moduleItem = rulesRepository.loadModule(moduleName);
      return moduleItem.containsAsset(assetName);

    } catch (RulesRepositoryException e) {
      log.error(
          "An error occurred checking if asset ["
              + assetName
              + "] exists in module ["
              + moduleName
              + "]: ",
          e);
      throw new SerializationException(e.getMessage());
    }
  }
Ejemplo n.º 6
0
  /**
   * This will create a new asset. It will be saved, but not checked in. The initial state will be
   * the draft state. Returns the UUID of the asset.
   */
  public String createNewRule(
      String ruleName,
      String description,
      String initialCategory,
      String initialPackage,
      String format)
      throws SerializationException {
    log.info(
        "USER:"******" CREATING new asset name ["
            + ruleName
            + "] in package ["
            + initialPackage
            + "]");

    try {

      ModuleItem pkg = rulesRepository.loadModule(initialPackage);
      AssetItem asset = pkg.addAsset(ruleName, description, initialCategory, format);

      new AssetTemplateCreator().applyPreBuiltTemplates(ruleName, format, asset);
      rulesRepository.save();

      push("categoryChange", initialCategory);
      push("packageChange", pkg.getName());

      return asset.getUUID();
    } catch (RulesRepositoryException e) {
      // If we want to display an explicit error message of "duplicate asset", we can achieve this
      // in client error handler.
      /*            if ( e.getCause() instanceof ItemExistsException ) {
          return "DUPLICATE";
      }*/
      log.error(
          "An error occurred creating new asset"
              + ruleName
              + "] in package ["
              + initialPackage
              + "]: ",
          e);
      throw new SerializationException(e.getMessage());
    }
  }