1 |
779bac69
|
Marc NICOLAS
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
package fr.ias.sitools.resources.vo;
|
20 |
|
|
|
21 |
|
|
import fr.ias.sitools.vo.ssa.SimpleSpectralAccessProtocolLibrary;
|
22 |
|
|
import fr.cnes.sitools.common.resource.SitoolsParameterizedResource;
|
23 |
|
|
import fr.cnes.sitools.dataset.DataSetApplication;
|
24 |
|
|
import java.util.ArrayList;
|
25 |
|
|
import java.util.List;
|
26 |
|
|
import java.util.logging.Logger;
|
27 |
|
|
import org.restlet.data.Disposition;
|
28 |
|
|
import org.restlet.data.MediaType;
|
29 |
|
|
import org.restlet.data.Status;
|
30 |
|
|
import org.restlet.ext.wadl.DocumentationInfo;
|
31 |
|
|
import org.restlet.ext.wadl.MethodInfo;
|
32 |
|
|
import org.restlet.ext.wadl.ParameterInfo;
|
33 |
|
|
import org.restlet.ext.wadl.ParameterStyle;
|
34 |
|
|
import org.restlet.ext.wadl.RepresentationInfo;
|
35 |
|
|
import org.restlet.representation.Representation;
|
36 |
|
|
import org.restlet.representation.Variant;
|
37 |
|
|
import org.restlet.resource.Get;
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
public class SimpleSpectralAccessResource extends SitoolsParameterizedResource {
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
private static final Logger LOG = Logger.getLogger(SimpleSpectralAccessResource.class.getName());
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
@Override
|
56 |
|
|
public final void doInit() {
|
57 |
|
|
super.doInit();
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
@Override
|
67 |
|
|
protected final Representation head(final Variant variant) {
|
68 |
|
|
final Representation repr = super.head();
|
69 |
|
|
repr.setMediaType(MediaType.TEXT_XML);
|
70 |
|
|
return repr;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
@Get
|
79 |
|
|
public final Representation getVOResponse() {
|
80 |
|
|
LOG.finest(String.format("SSA : %s", getRequest()));
|
81 |
|
|
final SimpleSpectralAccessProtocolLibrary sia = new SimpleSpectralAccessProtocolLibrary((DataSetApplication) this.getApplication(),
|
82 |
|
|
this.getModel(), this.getRequest(), this.getContext());
|
83 |
|
|
final Representation rep = sia.getResponse();
|
84 |
|
|
if (fileName != null && !"".equals(fileName)) {
|
85 |
|
|
final Disposition disp = new Disposition(Disposition.TYPE_ATTACHMENT);
|
86 |
|
|
disp.setFilename(fileName);
|
87 |
|
|
rep.setDisposition(disp);
|
88 |
|
|
}
|
89 |
|
|
return rep;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
@Override
|
96 |
|
|
public final void sitoolsDescribe() {
|
97 |
|
|
setName("Simple Spectral Access Protocol");
|
98 |
|
|
setDescription("This class implements the Simple Spectral Access Protocol for Virtual Observatory. "
|
99 |
|
|
+ "See http://ivoa.net web site for information about this protocol.");
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
@Override
|
108 |
|
|
protected final void describeGet(final MethodInfo info) {
|
109 |
|
|
this.addInfo(info);
|
110 |
|
|
info.setIdentifier("SimpleSpectralAccessProtocol");
|
111 |
|
|
info.setDocumentation("Interoperability service to distribute spectrum through the Simple Spectral Access Protocol");
|
112 |
|
|
|
113 |
|
|
final List<ParameterInfo> parametersInfo = new ArrayList<ParameterInfo>();
|
114 |
|
|
parametersInfo.add(new ParameterInfo("POS", true, "string", ParameterStyle.QUERY,
|
115 |
|
|
"Box Central position (decimal degree) in ICRS such as RA,DEC."));
|
116 |
|
|
parametersInfo.add(new ParameterInfo("SIZE", true, "string", ParameterStyle.QUERY,
|
117 |
|
|
"Size of the box in decimal degree such as width,height or width."));
|
118 |
|
|
info.getRequest().setParameters(parametersInfo);
|
119 |
|
|
|
120 |
|
|
info.getResponse().getStatuses().add(Status.SUCCESS_OK);
|
121 |
|
|
|
122 |
|
|
final DocumentationInfo documentation = new DocumentationInfo();
|
123 |
|
|
documentation.setTitle("SIAP");
|
124 |
|
|
documentation.setTextContent("Simple Spectral Access Protocol");
|
125 |
|
|
|
126 |
|
|
final List<RepresentationInfo> representationsInfo = new ArrayList<RepresentationInfo>();
|
127 |
|
|
final RepresentationInfo representationInfo = new RepresentationInfo(MediaType.TEXT_XML);
|
128 |
|
|
representationInfo.setDocumentation(documentation);
|
129 |
|
|
representationsInfo.add(representationInfo);
|
130 |
|
|
info.getResponse().setRepresentations(representationsInfo);
|
131 |
|
|
}
|
132 |
|
|
} |