Пример #1
0
  @Override
  public void createMember(RequestContext ctx, ResourceState state, Responder responder)
      throws Exception {

    if (state instanceof LazyResourceState) {
      LazyResourceState lazyResourceState = (LazyResourceState) state;
      ByteBuf content = lazyResourceState.contentAsByteBuf();
      setScriptFile(content.copy());

      parent.writeSourceFile(this.id(), content.copy());

      responder.resourceCreated(scriptFileResource);
      return;
    }
    responder.invalidRequest("The uploaded script must be a binary javascript file.");
  }
Пример #2
0
  @Override
  public void createMember(RequestContext ctx, ResourceState state, Responder responder)
      throws Exception {
    try {
      ResourceScript resourceScript = new ResourceScript(this, state);

      scripts.add(resourceScript.getScript());

      // Write to the file system
      ObjectNode objectNode = ConversionUtils.convert(state);
      writeMetadataFile(resourceScript.id(), objectNode);

      responder.resourceCreated(resourceScript);
    } catch (InvalidPropertyTypeException e) {
      responder.invalidRequest(e.getMessage());
    }
  }