1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.model.message.control;
17
18 import org.fourthline.cling.model.Constants;
19 import org.fourthline.cling.model.meta.Action;
20 import org.fourthline.cling.model.meta.QueryStateVariableAction;
21 import org.fourthline.cling.model.message.StreamResponseMessage;
22 import org.fourthline.cling.model.message.UpnpResponse;
23 import org.fourthline.cling.model.message.header.ContentTypeHeader;
24 import org.fourthline.cling.model.message.header.EXTHeader;
25 import org.fourthline.cling.model.message.header.ServerHeader;
26 import org.fourthline.cling.model.message.header.UpnpHeader;
27
28
29
30
31 public class OutgoingActionResponseMessage extends StreamResponseMessage implements ActionResponseMessage {
32
33 private String actionNamespace;
34
35 public OutgoingActionResponseMessage(Action action) {
36 this(UpnpResponse.Status.OK, action);
37 }
38
39 public OutgoingActionResponseMessage(UpnpResponse.Status status) {
40 this(status, null);
41 }
42
43 public OutgoingActionResponseMessage(UpnpResponse.Status status, Action action) {
44 super(new UpnpResponse(status));
45
46 if (action != null) {
47 if (action instanceof QueryStateVariableAction) {
48 this.actionNamespace = Constants.NS_UPNP_CONTROL_10;
49 } else {
50 this.actionNamespace = action.getService().getServiceType().toString();
51 }
52 }
53
54 addHeaders();
55 }
56
57 protected void addHeaders() {
58 getHeaders().add(
59 UpnpHeader.Type.CONTENT_TYPE,
60 new ContentTypeHeader(ContentTypeHeader.DEFAULT_CONTENT_TYPE_UTF8)
61 );
62 getHeaders().add(
63 UpnpHeader.Type.SERVER,
64 new ServerHeader()
65 );
66 getHeaders().add(
67 UpnpHeader.Type.EXT,
68 new EXTHeader()
69 );
70 }
71
72 public String getActionNamespace() {
73 return actionNamespace;
74 }
75
76
77 }