org.elkoserver.server.context.caps
Class Definer

java.lang.Object
  extended by org.elkoserver.server.context.Mod
      extended by org.elkoserver.server.context.caps.Cap
          extended by org.elkoserver.server.context.caps.Definer
All Implemented Interfaces:
Cloneable, DispatchTarget, Encodable, ItemMod, ObjectCompletionWatcher, UserMod

public class Definer
extends Cap
implements ItemMod, UserMod

Capability to enable external definition of persistent C-U-I objects.


Constructor Summary
Definer(JSONObject raw)
          JSON-driven constructor.
 
Method Summary
 void define(User from, OptString into, OptString ref, BasicObject obj)
          Message handler for a 'define' message.
 JSONLiteral encode(EncodeControl control)
          Encode this mod for transmission or persistence.
 
Methods inherited from class org.elkoserver.server.context.caps.Cap
delete, encodeDefaultParameters, ensureValid, isExpired, objectIsComplete, setlabel, spawn, transfer
 
Methods inherited from class org.elkoserver.server.context.Mod
attachTo, clone, context, ensureHolding, ensureInContext, ensureReachable, ensureSameContext, ensureSameUser, holder, isEphemeral, markAsChanged, markAsEphemeral, object
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Definer

@JSONMethod
public Definer(JSONObject raw)
        throws JSONDecodingException
JSON-driven constructor.

Throws:
JSONDecodingException
Method Detail

define

@JSONMethod(value={"into","ref","obj"})
public void define(User from,
                                   OptString into,
                                   OptString ref,
                                   BasicObject obj)
            throws MessageHandlerException
Message handler for a 'define' message. This is a request to define a new context, item, or user.

recv: { to:REF, op:"define", into:optREF, ref:optREF, obj:OBJDESC }
send: { to:REF, op:"define", ref:REF }

Parameters:
into - Container into which the new object should be placed (optional, defaults to no container).
ref - Reference string for the new object (optional, defaults to an automatically generated ref).
obj - JSON descriptor for the object itself
Throws:
MessageHandlerException - if 'from' is not the holder of this definer capability, or if an explicit ID is given but an object of that ID is loaded, or if a container is given and that container object is loaded, or if the object descriptor is not a valid context, item or user descriptor.

encode

public JSONLiteral encode(EncodeControl control)
Encode this mod for transmission or persistence.

Specified by:
encode in interface Encodable
Parameters:
control - Encode control determining what flavor of encoding should be done.
Returns:
a JSON literal representing this object.