Package org.persvr.data

Examples of org.persvr.data.Identification


      if (object.containsKey("$ref")) {
       
        return Identification.idForRelativeString(path, (String) object.get("$ref"));
      }
      if (object.containsKey("id")) {
        Identification currentId = Identification.idForRelativeString(path, object.remove("id").toString());

        if (currentId.source instanceof ClientData) // TODO: Surely we can do this more consistently
          target = Client.getCurrentObjectResponse().getConnection().clientSideObject(currentId.toString(),createInitialObject(object));
        else {
          if (currentId instanceof ObjectId){
            if(mustMatchId){
              if(targetId != currentId){
                throw new RuntimeException("id does not match location");
              }
            }
            else {
              targetId = (ObjectId) currentId;
            }
           
          }
          else {
            target = (Persistable) currentId.getTarget();
            if(mustMatchId && target.getId() != targetId){
              throw new RuntimeException("id does not match location");
            }
          }
        }
View Full Code Here


          Persistable object = null;
              //Id requestedId = new Id(requestedObject); // removes the leading underscore
              //requestedId.source = sourceURL;
          String field = null;
              Object value = null;
            Identification id = Identification.idForString(requestedPath);
            value = getClientSideObject(requestedPath);
            if(value != null){
              object = (Persistable) value;
            }
            else{
              if (id instanceof ObjectId || id instanceof JsonPath){
                if(id instanceof ObjectId){
                  value = put ? ((ObjectId)id).getOrCreateTarget() : ((ObjectId)id).getTarget(); // We can't use getOrCreateTarget or else it would create objects on GETs
                }
                else {
                  value = ((Identification<Object>)id).getTarget();
                }
                if (value instanceof Persistable){
                  object = (Persistable)value;
                }
              }
              else {
                object = ((ObjectPath)id).getSecondToLastTarget();
                field = ((ObjectPath)id).getLastPath().toString();
                value = id.getTarget();
              }
            }
            setRequestedPath(requestedPath,id);
         
View Full Code Here

         * source = DataSourceManager.getSource(sourceName); if (source ==
         * null) source = AliasIds.getAliasHandler(sourceName); } else
         * source = null;
         */
        String method = request.getMethod().toUpperCase();
        Identification targetId = Identification.idForString(path);

        if (log.isDebugEnabled()) {
          log.debug("Identification targetId:" + targetId);
          log.debug("Request Method: " + method);
        }

        reason = null;
        if ("GET".equals(method) || "POST".equals(method)) {
          // allow the HTTP method to be defined with a parameter
          String explicitMethod = getHeader(request, "method");
          if (explicitMethod != null)
            method = explicitMethod;
          else if ("GET".equals(method))
            // if there is not explicit method, than we can assume cookie authorization is allowed
            requestHelper.authorizeCookieAuthentication();
        }
        try {
          if (targetId instanceof ObjectNotFoundId ||
            (targetId.getSource() instanceof LocalDataSource && ((LocalDataSource) targetId.getSource()).passThrough()) ||
            ("GET".equals(method) && !objectExistsForId(targetId))) {
            if ("PUT".equals(method)) {
              if (UserSecurity.hasPermission(SystemPermission.javaScriptCoding)) {
                // if the user has permission they can also update files with PUT
                File targetFile = new File(((HttpServletRequest) request).getRealPath(path));
View Full Code Here

          && "id".equals(expression.getLastChild().getString())) {
      name = expression.getFirstChild().getLastChild().getString();
      sql.append("field='" + makeStringSQLSafe(name) + "'");
      if (valueNode.getType() != Token.STRING || (conditionType != Token.EQ && conditionType != Token.SHEQ))
        throw new QueryCantBeHandled("The id must be a string");
      Identification id = Identification.idForString(valueNode.getString());
      if (!(id instanceof ObjectId)){
        throw new QueryCantBeHandled("The id must be an object id");
      }
      if(!(id.source instanceof DynaObjectDBSource)){
        throw new QueryCantBeHandled("The id must be an object id of the object db");
      }
      sql.append(" AND value_type=" + OBJECT_TYPE + " AND value=" + ((DynaObjectDBSource)id.source).convertId(id.subObjectId));
      return sql.toString();
     
    }
    if (expression.getType() == Token.GETPROP && expression.getFirstChild().getType() == Token.THIS
        && "id".equals(expression.getLastChild().getString())) {
      Identification id = Identification.idForString(valueNode.getString());
      if (!(id instanceof ObjectId)){
        throw new QueryCantBeHandled("The id must be an object id");
      }
      if(!(id.source instanceof DynaObjectDBSource)){
        throw new QueryCantBeHandled("The id must be an object id of the object db");
View Full Code Here

                    }
                    PersistableObject.enableSecurity(security);
                    writeNewLine(writer,commaNeeded);
                    writer.write(JSON.quote(key));
                    writer.write(":");
                    Identification valueId;
                    if(value instanceof Identification)
                      valueId = (Identification)value;
                    else if(value instanceof Persistable){
                      valueId = ((Persistable)value).getId();
                    }
View Full Code Here

  }
  protected Object convertJsonToJavaScript(Object value, String id) {
    String fullId = (id.startsWith("http://") || id.startsWith("https://")) ? id : (getId() + '/' + id);
    if (value instanceof Map || value instanceof List){
      if (value instanceof Map && ((Map)value).containsKey("$ref")){
          Identification refId = Identification.idForRelativeString(fullId, (String) ((Map)value).get("$ref"));
          if(refId instanceof ObjectId && ((ObjectId)refId).subObjectId == null){
            refId = ObjectId.idForObject(DataSourceManager.getMetaClassSource(), ((ObjectId)refId).source.getId());
          }
          return refId;
      }
      Identification objId;
      if (value instanceof Map && ((Map)value).containsKey("id") && useIds())
          objId= Identification.idForRelativeString(fullId, (String) ((Map)value).get("id"));
      else
        objId = ObjectId.idForObject(this, id, true);
      if(!(objId instanceof ObjectId))
View Full Code Here

    }
  }
  protected Object mapJson(PersistableInitializer initializer, final Object object, final String objectId) {
    // the id might resolve differently after downloading a class
    ObjectId objId = ObjectId.idForObject(this, objectId);
    Identification newId = Identification.idForString(getId() + '/' + objectId);

    if(newId instanceof ObjectId && objId.source != newId.source){
      objId.source = newId.source;
      objId.subObjectId = newId.subObjectId;
      return ((HttpJsonSource)newId.source).mapJson(initializer, object, newId.subObjectId);
View Full Code Here

TOP

Related Classes of org.persvr.data.Identification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.