public static SoapActionType valueOf(String s) throws InvalidValueException { Matcher magicControlMatcher = SoapActionType.PATTERN_MAGIC_CONTROL.matcher(s); try { if (magicControlMatcher.matches()) { return new SoapActionType(MAGIC_CONTROL_NS, MAGIC_CONTROL_TYPE, null, magicControlMatcher.group(1)); // throws IllegalArgumentException } Matcher matcher = SoapActionType.PATTERN.matcher(s); if (matcher.matches()) return new SoapActionType(matcher.group(1), matcher.group(2), Integer.valueOf(matcher.group(3)), matcher.group(4)); } catch(RuntimeException e) { throw new InvalidValueException(String.format( "Can't parse action type string (namespace/type/version#actionName) '%s': %s", s, e.toString() )); } throw new InvalidValueException("Can't parse action type string (namespace/type/version#actionName): " + s); }
public IncomingActionRequestMessage(StreamRequestMessage source, LocalService service) throws ActionException { super(source); SoapActionHeader soapActionHeader = getHeaders().getFirstHeader(UpnpHeader.Type.SOAPACTION, SoapActionHeader.class); if (soapActionHeader == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Missing SOAP action header"); } SoapActionType actionType = soapActionHeader.getValue(); this.action = service.getAction(actionType.getActionName()); if (this.action == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't implement action: " + actionType.getActionName()); } if (!QueryStateVariableAction.ACTION_NAME.equals(actionType.getActionName())) { if (!service.getServiceType().implementsVersion(actionType.getServiceType())) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't support the requested service version"); } } this.actionNamespace = actionType.getTypeString(); }
public String getTypeString() { if (version == null) { return "urn:" + getNamespace() + ":" + getType(); } else { return "urn:" + getNamespace() + ":service:" + getType() + ":" + getVersion(); } }
@Override public String toString() { return getTypeString() + "#" + getActionName(); }
log.fine("Adding magic control SOAP action header for state variable query action"); soapActionHeader = new SoapActionHeader( new SoapActionType( SoapActionType.MAGIC_CONTROL_NS, SoapActionType.MAGIC_CONTROL_TYPE, null, action.getName() } else { soapActionHeader = new SoapActionHeader( new SoapActionType( action.getService().getServiceType(), action.getName() actionNamespace = soapActionHeader.getValue().getTypeString();
public SoapActionHeader(URI uri) { setValue(SoapActionType.valueOf(uri.toString())); }
public String getString() { return "\"" + getValue().toString() + "\""; } }
@Override public String toString() { return getTypeString() + "#" + getActionName(); }
log.fine("Adding magic control SOAP action header for state variable query action"); soapActionHeader = new SoapActionHeader( new SoapActionType( SoapActionType.MAGIC_CONTROL_NS, SoapActionType.MAGIC_CONTROL_TYPE, null, action.getName() } else { soapActionHeader = new SoapActionHeader( new SoapActionType( action.getService().getServiceType(), action.getName() actionNamespace = soapActionHeader.getValue().getTypeString();
public void setString(String s) throws InvalidHeaderException { try { if (!s.startsWith("\"") && s.endsWith("\"")) { throw new InvalidHeaderException("Invalid SOAP action header, must be enclosed in doublequotes:" + s); } SoapActionType t = SoapActionType.valueOf(s.substring(1, s.length()-1)); setValue(t); } catch (RuntimeException ex) { throw new InvalidHeaderException("Invalid SOAP action header value, " + ex.getMessage()); } }
public String getString() { return "\"" + getValue().toString() + "\""; } }
public String getTypeString() { if (version == null) { return "urn:" + getNamespace() + ":" + getType(); } else { return "urn:" + getNamespace() + ":service:" + getType() + ":" + getVersion(); } }
public IncomingActionRequestMessage(StreamRequestMessage source, LocalService service) throws ActionException { super(source); SoapActionHeader soapActionHeader = getHeaders().getFirstHeader(UpnpHeader.Type.SOAPACTION, SoapActionHeader.class); if (soapActionHeader == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Missing SOAP action header"); } SoapActionType actionType = soapActionHeader.getValue(); this.action = service.getAction(actionType.getActionName()); if (this.action == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't implement action: " + actionType.getActionName()); } if (!QueryStateVariableAction.ACTION_NAME.equals(actionType.getActionName())) { if (!service.getServiceType().implementsVersion(actionType.getServiceType())) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't support the requested service version"); } } this.actionNamespace = actionType.getTypeString(); }
@Override public String toString() { return getTypeString() + "#" + getActionName(); }
log.fine("Adding magic control SOAP action header for state variable query action"); soapActionHeader = new SoapActionHeader( new SoapActionType( SoapActionType.MAGIC_CONTROL_NS, SoapActionType.MAGIC_CONTROL_TYPE, null, action.getName() } else { soapActionHeader = new SoapActionHeader( new SoapActionType( action.getService().getServiceType(), action.getName() actionNamespace = soapActionHeader.getValue().getTypeString();
public SoapActionHeader(URI uri) { setValue(SoapActionType.valueOf(uri.toString())); }
public String getString() { return "\"" + getValue().toString() + "\""; } }
public static SoapActionType valueOf(String s) throws InvalidValueException { Matcher magicControlMatcher = SoapActionType.PATTERN_MAGIC_CONTROL.matcher(s); if (magicControlMatcher.matches()) { return new SoapActionType(MAGIC_CONTROL_NS, MAGIC_CONTROL_TYPE, null, magicControlMatcher.group(1)); } Matcher matcher = SoapActionType.PATTERN.matcher(s); if (matcher.matches()) { return new SoapActionType(matcher.group(1), matcher.group(2), Integer.valueOf(matcher.group(3)), matcher.group(4)); } else { throw new InvalidValueException("Can't parse action type string (namespace/type/version#actionName): " + s); } }
public String getTypeString() { if (version == null) { return "urn:" + getNamespace() + ":" + getType(); } else { return "urn:" + getNamespace() + ":service:" + getType() + ":" + getVersion(); } }
public IncomingActionRequestMessage(StreamRequestMessage source, LocalService service) throws ActionException { super(source); SoapActionHeader soapActionHeader = getHeaders().getFirstHeader(UpnpHeader.Type.SOAPACTION, SoapActionHeader.class); if (soapActionHeader == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Missing SOAP action header"); } SoapActionType actionType = soapActionHeader.getValue(); this.action = service.getAction(actionType.getActionName()); if (this.action == null) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't implement action: " + actionType.getActionName()); } if (!QueryStateVariableAction.ACTION_NAME.equals(actionType.getActionName())) { if (!service.getServiceType().implementsVersion(actionType.getServiceType())) { throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't support the requested service version"); } } this.actionNamespace = actionType.getTypeString(); }