1 // ANNA - Anna is Not Nothingness Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // https://bitbucket.org/testillano/anna
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #include <anna/core/tracing/Logger.hpp>
39 #include <anna/http/wims20/ClientSide.hpp>
41 #include <anna/http/Request.hpp>
47 * Los niveles parece que serán bastante estables, así que nos ahorramos calcular toda su ruta
48 * cada vez que tengamos que calcular la URI.
50 void http::wims20::ClientSide::addOtherLevel(const std::string& otherLevel)
51 throw(RuntimeException) {
52 if(a_strOtherLevels == NULL)
53 a_strOtherLevels = Abstract::createString(otherLevel);
55 *a_strOtherLevels += '/';
56 *a_strOtherLevels += otherLevel;
59 Abstract::other_level_add(otherLevel);
63 http://domain-openapis/path-openapis/serviceID/guid/other_possible_levels?query_parameters
65 Dónde los campos tienen siguen la siguiente especificación:
66 \li http://domain-openapis: Identifica el recurso del Open API.
67 \li path-openapis: Recurso opcional que ajusta la ruta hacia los recursos de éste API.
68 \li serviceID: Identificador de recurso.
69 \li guid: Identificador del usuario que solicita la petición.
70 \li other_possible_level: Opcionalmente se pueden indicar tantos niveles jerárquicos como fuera
71 necesario para el servicio.
72 \li query_parameters: Lista de parámetros. Si hay más de un parámetro se separará con '&'.
74 void http::wims20::ClientSide::codeOn(http::Request& request)
75 throw(RuntimeException) {
76 a_uri = Abstract::calculeFixedPart();
78 if(Abstract::hasOtherLevels())
79 Abstract::appendWithSlash(a_uri, *a_strOtherLevels);
81 if(Abstract::hasParameters()) {
85 for(parameter_iterator ii = parameter_begin(), maxii = parameter_end(); ii != maxii; ii ++) {
89 a_uri += *Abstract::parameter_name(ii);
91 a_uri += *Abstract::parameter_value(ii);
97 string msg("http::wims20::ServerSide::codeOn | ");
99 msg += " | Result (URI): ";
101 Logger::debug(msg, ANNA_FILE_LOCATION);
103 request.setURI(a_uri);