コード例 #1
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
  /** Restore a previously deleted n-cube. */
  public static void restoreCubes(ApplicationID appId, Object[] cubeNames, String username) {
    validateAppId(appId);
    appId.validateBranchIsNotHead();

    if (appId.isRelease()) {
      throw new IllegalArgumentException(
          ReleaseStatus.RELEASE + " cubes cannot be restored, app: " + appId);
    }

    if (ArrayUtilities.isEmpty(cubeNames)) {
      throw new IllegalArgumentException(
          "Error, empty array of cube names passed in to be restored.");
    }

    // Batch restore
    getPersister().restoreCubes(appId, cubeNames, username);

    // Load cache
    for (Object name : cubeNames) {
      if ((name instanceof String)) {
        String cubeName = (String) name;
        NCube.validateCubeName(cubeName);
        NCube ncube = getPersister().loadCube(appId, cubeName);
        addCube(appId, ncube);
      } else {
        throw new IllegalArgumentException("Non string name given for cube to restore: " + name);
      }
    }
  }
コード例 #2
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
 /** Testing API (Cache validation) */
 static boolean isCubeCached(ApplicationID appId, String cubeName) {
   validateAppId(appId);
   NCube.validateCubeName(cubeName);
   Map<String, Object> ncubes = getCacheForApp(appId);
   Object cachedItem = ncubes.get(cubeName.toLowerCase());
   return cachedItem instanceof NCube || cachedItem instanceof NCubeInfoDto;
 }
コード例 #3
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
  /** Retrieve all cube names that are deeply referenced by ApplicationID + n-cube name. */
  public static void getReferencedCubeNames(ApplicationID appId, String name, Set<String> refs) {
    if (refs == null) {
      throw new IllegalArgumentException(
          "Could not get referenced cube names, null passed in for Set to hold referenced n-cube names, app: "
              + appId
              + ", n-cube: "
              + name);
    }
    validateAppId(appId);
    NCube.validateCubeName(name);
    NCube ncube = getCube(appId, name);
    if (ncube == null) {
      throw new IllegalArgumentException(
          "Could not get referenced cube names, n-cube: "
              + name
              + " does not exist in app: "
              + appId);
    }
    Set<String> subCubeList = ncube.getReferencedCubeNames();

    // TODO: Use explicit stack, NOT recursion

    for (String cubeName : subCubeList) {
      if (!refs.contains(cubeName)) {
        refs.add(cubeName);
        getReferencedCubeNames(appId, cubeName, refs);
      }
    }
  }
コード例 #4
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
  /** Duplicate the given n-cube specified by oldAppId and oldName to new ApplicationID and name, */
  public static void duplicate(
      ApplicationID oldAppId,
      ApplicationID newAppId,
      String oldName,
      String newName,
      String username) {
    validateAppId(oldAppId);
    validateAppId(newAppId);

    newAppId.validateBranchIsNotHead();

    if (newAppId.isRelease()) {
      throw new IllegalArgumentException(
          "Cubes cannot be duplicated into a "
              + ReleaseStatus.RELEASE
              + " version, cube: "
              + newName
              + ", app: "
              + newAppId);
    }

    NCube.validateCubeName(oldName);
    NCube.validateCubeName(newName);

    if (oldName.equalsIgnoreCase(newName) && oldAppId.equals(newAppId)) {
      throw new IllegalArgumentException(
          "Could not duplicate, old name cannot be the same as the new name when oldAppId matches newAppId, name: "
              + oldName
              + ", app: "
              + oldAppId);
    }

    getPersister().duplicateCube(oldAppId, newAppId, oldName, newName, username);

    if (CLASSPATH_CUBE.equalsIgnoreCase(
        newName)) { // If another cube is renamed into sys.classpath,
      // then the entire class loader must be dropped (and then lazily rebuilt).
      clearCache(newAppId);
    } else {
      Map<String, Object> appCache = getCacheForApp(newAppId);
      appCache.remove(newName.toLowerCase());
    }

    broadcast(newAppId);
  }
コード例 #5
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
  public static boolean renameCube(
      ApplicationID appId, String oldName, String newName, String username) {
    validateAppId(appId);
    appId.validateBranchIsNotHead();

    if (appId.isRelease()) {
      throw new IllegalArgumentException(
          "Cannot rename a "
              + ReleaseStatus.RELEASE
              + " cube, cube: "
              + oldName
              + ", app: "
              + appId);
    }

    NCube.validateCubeName(oldName);
    NCube.validateCubeName(newName);

    if (oldName.equalsIgnoreCase(newName)) {
      throw new IllegalArgumentException(
          "Could not rename, old name cannot be the same as the new name, name: "
              + oldName
              + ", app: "
              + appId);
    }

    boolean result = getPersister().renameCube(appId, oldName, newName, username);

    if (CLASSPATH_CUBE.equalsIgnoreCase(oldName)
        || CLASSPATH_CUBE.equalsIgnoreCase(
            newName)) { // If the sys.classpath cube is renamed, or another cube is renamed into
                        // sys.classpath,
      // then the entire class loader must be dropped (and then lazily rebuilt).
      clearCache(appId);
    } else {
      Map<String, Object> appCache = getCacheForApp(appId);
      appCache.remove(oldName.toLowerCase());
      appCache.remove(newName.toLowerCase());
    }

    broadcast(appId);
    return result;
  }
コード例 #6
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
  public static String getNotes(ApplicationID appId, String cubeName) {
    validateAppId(appId);
    NCube.validateCubeName(cubeName);
    Map<String, Object> options = new HashMap<>();
    options.put(SEARCH_INCLUDE_NOTES, true);
    options.put(SEARCH_EXACT_MATCH_NAME, true);

    List<NCubeInfoDto> infos = search(appId, cubeName, null, options);
    if (infos.size() == 0) {
      throw new IllegalArgumentException(
          "Could not fetch notes, no cube: " + cubeName + " in app: " + appId);
    }
    return infos.get(0).notes;
  }
コード例 #7
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
  /**
   * Fetch an n-cube by name from the given ApplicationID. If no n-cubes are loaded, then a
   * loadCubes() call is performed and then the internal cache is checked again. If the cube is not
   * found, null is returned.
   */
  public static NCube getCube(ApplicationID appId, String name) {
    validateAppId(appId);
    NCube.validateCubeName(name);
    Map<String, Object> cubes = getCacheForApp(appId);
    final String lowerCubeName = name.toLowerCase();

    if (cubes.containsKey(lowerCubeName)) { // pull from cache
      final Object cube = cubes.get(lowerCubeName);
      return Boolean.FALSE == cube ? null : ensureLoaded(cube);
    }

    // now even items with metaProperties(cache = 'false') can be retrieved
    // and normal app processing doesn't do two queries anymore.
    // used to do getCubeInfoRecords() -> dto
    // and then dto -> loadCube(id)
    NCube ncube = getPersister().loadCube(appId, name);
    if (ncube == null) {
      cubes.put(lowerCubeName, Boolean.FALSE);
      return null;
    }
    return prepareCube(ncube);
  }
コード例 #8
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
 /** Get a List<NCubeInfoDto> containing all history for the given cube. */
 public static List<NCubeInfoDto> getRevisionHistory(ApplicationID appId, String cubeName) {
   validateAppId(appId);
   NCube.validateCubeName(cubeName);
   List<NCubeInfoDto> revisions = getPersister().getRevisions(appId, cubeName);
   return revisions;
 }
コード例 #9
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
 static void validateCube(NCube cube) {
   if (cube == null) {
     throw new IllegalArgumentException("NCube cannot be null");
   }
   NCube.validateCubeName(cube.getName());
 }
コード例 #10
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
 public static boolean updateNotes(ApplicationID appId, String cubeName, String notes) {
   validateAppId(appId);
   NCube.validateCubeName(cubeName);
   return getPersister().updateNotes(appId, cubeName, notes);
 }
コード例 #11
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
 public static String getTestData(ApplicationID appId, String cubeName) {
   validateAppId(appId);
   NCube.validateCubeName(cubeName);
   return getPersister().getTestData(appId, cubeName);
 }
コード例 #12
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
 public static boolean updateTestData(ApplicationID appId, String cubeName, String testData) {
   validateAppId(appId);
   NCube.validateCubeName(cubeName);
   return getPersister().updateTestData(appId, cubeName, testData);
 }