View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.model.message.control;
17  
18  import org.fourthline.cling.model.message.StreamResponseMessage;
19  import org.fourthline.cling.model.message.UpnpResponse;
20  
21  /**
22   * @author Christian Bauer
23   */
24  public class IncomingActionResponseMessage extends StreamResponseMessage implements ActionResponseMessage {
25  
26  
27      public IncomingActionResponseMessage(StreamResponseMessage source) {
28          super(source);
29      }
30  
31      public IncomingActionResponseMessage(UpnpResponse operation) {
32          super(operation);
33      }
34  
35      public String getActionNamespace() {
36          return null; // TODO: We _could_ read this in SOAPActionProcessor and set it when we receive a response but why?
37      }
38  
39      public boolean isFailedNonRecoverable() {
40          int statusCode = getOperation().getStatusCode();
41          return getOperation().isFailed()
42                  && !(statusCode == UpnpResponse.Status.METHOD_NOT_SUPPORTED.getStatusCode() ||
43                  (statusCode == UpnpResponse.Status.INTERNAL_SERVER_ERROR.getStatusCode()) && hasBody());
44      }
45  
46      public boolean isFailedRecoverable() {
47          return hasBody() && getOperation().getStatusCode() == UpnpResponse.Status.INTERNAL_SERVER_ERROR.getStatusCode();
48      }
49  
50  }