Package org.cybergarage.upnp

Examples of org.cybergarage.upnp.ArgumentList


      UPnPAction[] actions = services[i].getActions();
      for (int j = 0; j < actions.length; j++) {
                boolean valid=true;
        Action act = new Action(ser.getServiceNode());
        act.setName(actions[j].getName());
        ArgumentList al = new ArgumentList();
       
        String[] names=actions[j].getInputArgumentNames();       
        if(names!=null){
          for (int k = 0; k < names.length; k++) {
                        UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
                        if(variable==null){
                            /*
                             * //TODO Create a stict and relaxed behavior of the base driver which
                             * export as much it can or export only 100% complaint UPnPDevice service
                             */
                            Activator.logger.WARNING(
                                "UPnP Device that cotains serviceId="+id+" contains the action "
                                +actions[j].getName()+" with the Input argument "+names[k]
                                +" not related to any UPnPStateVariable. Thus this action won't be exported");
                            valid=false;
                            break;
                        }
                        Argument a = new Argument();
            a.setDirection(Argument.IN);
            a.setName(names[k]);
            a.setRelatedStateVariableName(variable.getName());           
            al.add(a);           
          }
        }
        names=actions[j].getOutputArgumentNames();
        if(names!=null && valid){
          for (int k = 0; k < names.length; k++) {
                        UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
                        if(variable==null){
                            /*
                             * //TODO Create a stict and relaxed behavior of the base driver which
                             * export as much it can or export only 100% complaint UPnPDevice service
                             */
                            Activator.logger.WARNING(
                                "UPnP Device that cotains serviceId="+id+" contains the action "
                                +actions[j].getName()+" with the Output argument "+names[k]
                                +" not related to any UPnPStateVariable. Thus this action won't be exported");                           
                        }
            Argument a = new Argument();
            a.setDirection(Argument.OUT);
            a.setName(names[k]);
            a.setRelatedStateVariableName(variable.getName());           
            al.add(a);           
          }
        }
                if(valid) {
            act.setArgumentList(al);
            ser.addAction(act);
View Full Code Here


    if(osgiServ==null)
      return exiting(false);
   
    UPnPAction osgiAct = osgiServ.getAction(upnpAct.getName());
    Properties inArgs = null;
    ArgumentList alIn = upnpAct.getInputArgumentList();
    ArgumentList alOut = upnpAct.getOutputArgumentList();
    String[] inArg = osgiAct.getInputArgumentNames();
    boolean invalidAction=false;
    if(inArg!=null){
      inArgs = new Properties();
      Argument arg;
      for (int j = 0; j < inArg.length; j++) {
        arg=alIn.getArgument(inArg[j]);
        try {
          inArgs.put(
              inArg[j],
              Converter.parseString(
                  arg.getValue(),
                  arg.getRelatedStateVariable().getDataType()
                  /*osgiServ.getStateVariable(arg.getRelatedStateVariableName()).getUPnPDataType()*/
              )
          );
        } catch (Exception e) {
          invalidAction=true;
          break;
        }
      }
    }
    Dictionary outArgs=null;
    try {
      outArgs=osgiAct.invoke(inArgs);
    } catch (UPnPException e) {
      //TODO Activator.logger.log()
      upnpAct.setStatus(e.getUPnPError_Code(),e.getMessage());
      invalidAction=true;
    } catch (Exception e){
      //TODO Activator.logger.log()
      upnpAct.setStatus(UPnPStatus.ACTION_FAILED);
      invalidAction=true;
    }   
    if(invalidAction)
      return exiting(false);
    String[] outArg = osgiAct.getOutputArgumentNames();
    if(outArg!=null){
      Argument arg;
      for (int j = 0; j < outArg.length; j++) {
        arg = alOut.getArgument(outArg[j]);               
        try {
          arg.setValue(
            Converter.toString(
                outArgs.get(outArg[j]),
                arg.getRelatedStateVariable().getDataType()
View Full Code Here

      UPnPAction[] actions = services[i].getActions();
      for (int j = 0; j < actions.length; j++) {
                boolean valid=true;
        Action act = new Action(ser.getServiceNode());
        act.setName(actions[j].getName());
        ArgumentList al = new ArgumentList();
       
        String[] names=actions[j].getInputArgumentNames();       
        if(names!=null){
          for (int k = 0; k < names.length; k++) {
                        UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
                        if(variable==null){
                            /*
                             * //TODO Create a stict and relaxed behavior of the base driver which
                             * export as much it can or export only 100% complaint UPnPDevice service
                             */
                            Activator.logger.WARNING(
                                "UPnP Device that cotains serviceId="+id+" contains the action "
                                +actions[j].getName()+" with the Input argument "+names[k]
                                +" not related to any UPnPStateVariable. Thus this action won't be exported");
                            valid=false;
                            break;
                        }
                        Argument a = new Argument();
            a.setDirection(Argument.IN);
            a.setName(names[k]);
            a.setRelatedStateVariableName(variable.getName());           
            al.add(a);           
          }
        }
        names=actions[j].getOutputArgumentNames();
        if(names!=null && valid){
          for (int k = 0; k < names.length; k++) {
                        UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
                        if(variable==null){
                            /*
                             * //TODO Create a stict and relaxed behavior of the base driver which
                             * export as much it can or export only 100% complaint UPnPDevice service
                             */
                            Activator.logger.WARNING(
                                "UPnP Device that cotains serviceId="+id+" contains the action "
                                +actions[j].getName()+" with the Output argument "+names[k]
                                +" not related to any UPnPStateVariable. Thus this action won't be exported");                           
                        }
            Argument a = new Argument();
            a.setDirection(Argument.OUT);
            a.setName(names[k]);
            a.setRelatedStateVariableName(variable.getName());           
            al.add(a);           
          }
        }
                if(valid) {
            act.setArgumentList(al);
            ser.addAction(act);
View Full Code Here

  /* (non-Javadoc)
   * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
   */
  public String[] getInputArgumentNames() {
    // TODO to check
    ArgumentList argsList=act.getInputArgumentList();
    if(argsList.size()==0){
      return null;
    }
    String [] inputArgs=new String[argsList.size()];
    for(int i=0;i<argsList.size();i++){
      inputArgs[i]=argsList.getArgument(i).getName();
    }
    return inputArgs;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
   */
  public String[] getOutputArgumentNames() {
    // TODO to check
    ArgumentList argsList=act.getOutputArgumentList();
    if(argsList.size()==0){
      return null;
    }
    String [] outArgs=new String[argsList.size()];
    for(int i=0;i<argsList.size();i++){
      outArgs[i]=argsList.getArgument(i).getName();
    }
    return outArgs;
  }
View Full Code Here

    check if I have understood wath this method should do
    */
    /*
     * I look for argument and value and then I add them to ArgumentList
     */
    ArgumentList argsList=new ArgumentList();
    argsList= act.getInputArgumentList();
 
    for(int i=0;i<argsList.size();i++){
      /*     
       * I assert that .getArgument(i) will return to me an Argument with only the name of the
       * Argument and not it's value. I'll set the associated value by myself and
       * Also I assert that the Argument are ordered
       */
      Argument argument=argsList.getArgument(i);
      String argumentName=argument.getName();
      //String relateVar=argument.getRelatedStateVariableName();
      UPnPStateVariable stateVar=this.getStateVariable(argumentName);
      String upnpType=stateVar.getUPnPDataType();
      /*Class javaClass=stateVar.getJavaDataType();*/
      //setting the value related to the input argument
      argument.setValue(Converter.toString(args.get(argumentName),upnpType));
    }
    act.setInArgumentValues(argsList);
    if(act.postControlAction()==true){
      //TODO check what happen if I don't have any output argument
      Properties outDic=new Properties();
      ArgumentList outArgs=act.getOutputArgumentList();
      if(outArgs.size()==0){
        return null;
      }
      for(int i=0;i<outArgs.size();i++){
        Argument argument=outArgs.getArgument(i);
        String argumentName=outArgs.getArgument(i).getName();
        //String relateVar=argument.getRelatedStateVariableName();
        UPnPStateVariable stateVar=getStateVariable(argumentName);
        //String javaType=stateVar.getJavaDataType().getName();
        //TODO rember to catch number exception
        String upnpType=stateVar.getUPnPDataType();
View Full Code Here

TOP

Related Classes of org.cybergarage.upnp.ArgumentList

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.