Search in sources :

Example 6 with GET

use of io.vertigo.vega.webservice.stereotype.GET in project vertigo by KleeGroup.

the class SwaggerWebServices method getSwapperUi.

/**
 * Return a swagger static resources.
 * @param resourceUrl Resource name
 * @param response HttpResponse
 * @throws IOException Exception
 */
@SessionLess
@AnonymousAccessAllowed
@GET("/swaggerUi/{resourceUrl}")
public void getSwapperUi(@PathParam("resourceUrl") final String resourceUrl, final HttpServletResponse response) throws IOException {
    FileUtil.checkUserFileName(resourceUrl);
    // ----
    if (resourceUrl.isEmpty()) {
        response.sendRedirect("./index.html");
    }
    final URL url = SwaggerWebServices.class.getResource("/swagger-site/" + resourceUrl);
    sendFile(url, resolveContentType(resourceUrl), response, resourceUrl);
}
Also used : URL(java.net.URL) SessionLess(io.vertigo.vega.webservice.stereotype.SessionLess) GET(io.vertigo.vega.webservice.stereotype.GET) AnonymousAccessAllowed(io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed)

Example 7 with GET

use of io.vertigo.vega.webservice.stereotype.GET in project vertigo by KleeGroup.

the class ComponentCmdWebServices method getModuleConfig.

@AnonymousAccessAllowed
@GET("/vertigo/components/modules/{moduleName}")
public String getModuleConfig(@PathParam("moduleName") final String moduleName) {
    Assertion.checkArgNotEmpty(moduleName);
    // -----
    final JsonArray jsonModuleConfigs = doGetModuleConfigs();
    for (int i = 0; i < jsonModuleConfigs.size(); i++) {
        final JsonObject jsonModuleConfig = (JsonObject) jsonModuleConfigs.get(i);
        if (moduleName.equalsIgnoreCase(jsonModuleConfig.get("name").getAsString())) {
            return jsonEngine.toJson(jsonModuleConfig);
        }
    }
    throw new VSystemException("NotFoundException");
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) VSystemException(io.vertigo.lang.VSystemException) GET(io.vertigo.vega.webservice.stereotype.GET) AnonymousAccessAllowed(io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed)

Example 8 with GET

use of io.vertigo.vega.webservice.stereotype.GET in project vertigo by KleeGroup.

the class AdvancedTestWebServices method testExportContacts.

@GET("/export/pdf/")
public VFile testExportContacts() throws URISyntaxException {
    final URL tempFile = resourcetManager.resolve("io/vertigo/vega/webservice/data/ws/contacts.pdf");
    final VFile result = fileManager.createFile(new File(tempFile.toURI()));
    // 200
    return result;
}
Also used : VFile(io.vertigo.dynamo.file.model.VFile) File(java.io.File) URL(java.net.URL) VFile(io.vertigo.dynamo.file.model.VFile) GET(io.vertigo.vega.webservice.stereotype.GET)

Example 9 with GET

use of io.vertigo.vega.webservice.stereotype.GET in project vertigo by KleeGroup.

the class ContactsWebServices method readContactView.

@GET("/contactView/{conId}")
public ContactView readContactView(@PathParam("conId") final long conId) {
    final Contact contact = contactDao.get(conId);
    if (contact == null) {
        // 404 ?
        throw new VUserException("Contact #" + conId + " unknown");
    }
    // we sheet and use 3 times the same address.
    final DtList<Address> addresses = DtList.of(contact.getAddressAccessor().get(), contact.getAddressAccessor().get(), contact.getAddressAccessor().get());
    final ContactView contactView = new ContactView();
    contactView.setName(contact.getName());
    contactView.setFirstName(contact.getFirstName());
    contactView.setHonorificCode(contact.getHonorificCode());
    contactView.setEmail(contact.getEmail());
    contactView.setBirthday(contact.getBirthday());
    contactView.setAddresses(addresses);
    // 200
    return contactView;
}
Also used : Address(io.vertigo.vega.webservice.data.domain.Address) Contact(io.vertigo.vega.webservice.data.domain.Contact) VUserException(io.vertigo.lang.VUserException) ContactView(io.vertigo.vega.webservice.data.domain.ContactView) GET(io.vertigo.vega.webservice.stereotype.GET)

Example 10 with GET

use of io.vertigo.vega.webservice.stereotype.GET in project vertigo by KleeGroup.

the class SimplerTestWebServices method loadListMeta.

@GET("/dtListMeta")
public DtList<Contact> loadListMeta() {
    final DtList<Contact> result = new DtList<>(Contact.class);
    for (final Contact contact : contactDao.getList()) {
        result.add(contact);
    }
    result.setMetaData("testLong", 12);
    result.setMetaData("testString", "the String test");
    result.setMetaData("testDate", DateUtil.newDate());
    result.setMetaData("testEscapedString", "the EscapedString \",} test");
    return result;
}
Also used : DtList(io.vertigo.dynamo.domain.model.DtList) Contact(io.vertigo.vega.webservice.data.domain.Contact) GET(io.vertigo.vega.webservice.stereotype.GET)

Aggregations

GET (io.vertigo.vega.webservice.stereotype.GET)12 AnonymousAccessAllowed (io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed)5 URL (java.net.URL)5 VFile (io.vertigo.dynamo.file.model.VFile)4 File (java.io.File)4 Contact (io.vertigo.vega.webservice.data.domain.Contact)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 VSystemException (io.vertigo.lang.VSystemException)2 SessionLess (io.vertigo.vega.webservice.stereotype.SessionLess)2 DtList (io.vertigo.dynamo.domain.model.DtList)1 VUserException (io.vertigo.lang.VUserException)1 UiContext (io.vertigo.vega.engines.webservice.json.UiContext)1 Address (io.vertigo.vega.webservice.data.domain.Address)1 ContactView (io.vertigo.vega.webservice.data.domain.ContactView)1 WebServiceDefinitionBuilder (io.vertigo.vega.webservice.metamodel.WebServiceDefinitionBuilder)1 WebServiceParam (io.vertigo.vega.webservice.metamodel.WebServiceParam)1 WebServiceParamType (io.vertigo.vega.webservice.metamodel.WebServiceParam.WebServiceParamType)1 ExtendedObject (io.vertigo.vega.webservice.model.ExtendedObject)1 AccessTokenConsume (io.vertigo.vega.webservice.stereotype.AccessTokenConsume)1