Package com.zaranux.client.api.exceptions

Examples of com.zaranux.client.api.exceptions.InvalidParameter


        response = new Response(atts);
      }else if("create".equals(systemcall))
      {

        if(parameters.length != 1)
          throw new InvalidParameter();
       
        String type = parameters[0];
        if(!("d".equals(type) || "f".equals(type) || "ds".equals(type) ))
        {
          throw new InvalidParameter();
        }
       
        path = normalize(path,requester);
        systemCallACL.create(path, type, requester);
        boolean success = create(path, type );
        response = new Response(success);

      }else if("createuser".equals(systemcall))
      {
        if(parameters.length != 2)
          throw new InvalidParameter();
       
        String id = parameters[0];
        String pass = parameters[1];
       
        systemCallACL.createuser(id, pass,requester);

        boolean success = createuser(id, pass);
        response = new Response(success);

      }else if("delegate".equals(systemcall))
      {
        if(parameters.length != 3)
          throw new InvalidParameter();
       
        String accesses = parameters[0];
        String grantee = parameters[1];
        long TTL = Long.parseLong(parameters[2]);
       
        path = normalize(path,requester);
       
        String[] acessesStringList = accesses.split(":");
        Access[] accessList = new Access[acessesStringList.length];
        for(int i=0; i< acessesStringList.length; i++) // String access:acessesStringList)
        {
          if( acessesStringList[i].equals((Access.READ).toString()))
          {
            accessList[i] = Access.READ;
          }else if(acessesStringList[i].equals((Access.WRITE).toString()))
          {
            accessList[i] = Access.WRITE;
          }else if(acessesStringList[i].equals((Access.DELEGATE).toString()))
          {
            accessList[i] = Access.DELEGATE;
          }else if(acessesStringList[i].equals((Access.DELETE).toString()))
          {
            accessList[i] = Access.LIST;
          }else if(acessesStringList[i].equals((Access.LIST).toString()))
          {
            accessList[i] = Access.LIST;
          }else
          {
            throw new InvalidParameter(acessesStringList[i] + " is not a valide access.");
          }
        }
        path = normalize(path,requester);
        systemCallACL.delegate(path, grantee,accessList, TTL, requester);
        String token = delegate(path, grantee,accessList, TTL, requester);

        response = new Response(token);

      }else if("delete".equals(systemcall))
      {
        path = normalize(path,requester);
        systemCallACL.delete(path, requester);
       
        boolean success = delete(path);
        response = new Response(success);
      }else if("http".equals(systemcall))
      {
        if(parameters.length != 3)
          throw new InvalidParameter();
       
        String type = parameters[0];
        String url  = parameters[1];
        String params = parameters[2];

        systemCallACL.http(type, url,params, requester);
       
        String output = http(type, url, params );
        response = new Response(output);
      }else if("list".equals(systemcall))
      {
        path = normalize(path,requester);
        systemCallACL.list(path, requester);
       
        String[] list = list(path);
        response = new Response(list);
      }else if("login".equals(systemcall))
      {
        if(parameters.length != 2)
          throw new InvalidParameter();
       
        String id = parameters[0];
        String pass = parameters[1];
       
        systemCallACL.login(id, pass,requester);

        String token = login(id, pass);
        response = new Response(token);
      }else if("move".equals(systemcall))
      {
        if(parameters.length != 1)
          throw new InvalidParameter();
       
        String to = parameters[0];

        path = normalize(path,requester);
        to = normalize(to,requester);
        systemCallACL.move(path, to, requester);
       
        boolean success = move(path, to);
        response = new Response(success);
      }else if("notify".equals(systemcall))
      {
        parameters = parameterList.split(",", 3);
        if(parameters.length != 3)
          throw new InvalidParameter();
       
        String reciever = parameters[0];
        String type = parameters[1];
        String notification = parameters[2];
       
        systemCallACL.notify(reciever, type,notification, requester);
       
        boolean success = notify(reciever, type, notification);
        response = new Response(success);

      }else if("read".equals(systemcall))
      {
        parameters = parameterList.split(",");
        if(parameters.length != 2)
          throw new InvalidParameter();
       
        long from = -1;
        int len = -1;
        try
        {
          from = Long.parseLong(parameters[0]);
          len = Integer.parseInt(parameters[1]);
        }catch(NumberFormatException e)
        {
          throw new InvalidParameter(e.getMessage());
        }
        path = normalize(path,requester);
        systemCallACL.read(path, from,len, requester);
        if(isBase64)
        {
          byte[] bytes = read(path, from, len );
          response = new Response(bytes);
        }else
        {
          InputStream inputStream = readStream(path, from , len);
          response = new Response(inputStream, len);
        }

      }else if("write".equals(systemcall))
      {
        parameters = parameterList.split(",", 3);
        if(parameters.length != 1)
          throw new InvalidParameter();
       
        boolean append = Boolean.parseBoolean(parameters[0]);
       
        path = normalize(path,requester);
        systemCallACL.write(path, append, isBase64, requester);
View Full Code Here


      if(id != null && !id.equals(""))
      {
        normalizedPath = "@" + id + path;
      }else
      {
        throw new InvalidParameter("path " + path + " is not normalizable, id missing: @id/path ");
      }
    }
    logger.finest("normalizedPath = " + normalizedPath);
    return normalizedPath;
  }
View Full Code Here

TOP

Related Classes of com.zaranux.client.api.exceptions.InvalidParameter

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.