Beispiel #1
0
  /**
   * Update the passed in NCube. Only SNAPSHOT cubes can be updated.
   *
   * @param ncube NCube to be updated.
   * @return boolean true on success, false otherwise
   */
  public static boolean updateCube(ApplicationID appId, NCube ncube, String username) {
    validateAppId(appId);
    validateCube(ncube);

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

    appId.validateBranchIsNotHead();

    final String cubeName = ncube.getName();
    getPersister().updateCube(appId, ncube, username);
    ncube.setApplicationID(appId);

    if (CLASSPATH_CUBE.equalsIgnoreCase(
        cubeName)) { // If the sys.classpath cube is changed, then the entire class loader must be
                     // dropped.  It will be lazily rebuilt.
      clearCache(appId);
    }

    addCube(appId, ncube);
    broadcast(appId);
    return true;
  }
Beispiel #2
0
 public static NCube getNCubeFromResource(ApplicationID id, String name) {
   try {
     String json = getResourceAsString(name);
     NCube ncube = NCube.fromSimpleJson(json);
     ncube.setApplicationID(id);
     ncube.sha1();
     addCube(id, ncube);
     return ncube;
   } catch (Exception e) {
     if (e instanceof RuntimeException) {
       throw (RuntimeException) e;
     }
     throw new RuntimeException("Failed to load cube from resource: " + name, e);
   }
 }