Buscar datos del almacenamiento de Azure

Este artículo muestra cómo rellenar un formulario adaptable con los datos almacenados en Azure Storage.
Se da por hecho que ha almacenado los datos del formulario adaptable en Azure Storage y ahora desea rellenar previamente el formulario adaptable con esos datos.

NOTE
El código de este artículo no funciona con los componentes principales basados en el formulario adaptable.El artículo equivalente para el formulario adaptable basado en componentes principales está disponible aquí

Crear solicitud de GET

El siguiente paso es escribir el código para recuperar los datos del almacenamiento de Azure con el blobID. El siguiente código se escribió para recuperar los datos. La URL se construyó utilizando los valores sasToken y storageURI de la configuración OSGi y el blobID pasado a la función getBlobData

 @Override
public String getBlobData(String blobID) {
    String sasToken = azurePortalConfigurationService.getSASToken();
    String storageURI = azurePortalConfigurationService.getStorageURI();
    log.debug("The SAS Token is " + sasToken);
    log.debug("The Storage URL is " + storageURI);
    String httpGetURL = storageURI + blobID;
    httpGetURL = httpGetURL + sasToken;
    HttpGet httpGet = new HttpGet(httpGetURL);

    org.apache.http.impl.client.CloseableHttpClient httpClient = HttpClientBuilder.create().build();
    CloseableHttpResponse httpResponse = null;
    try {
        httpResponse = httpClient.execute(httpGet);
        HttpEntity httpEntity = httpResponse.getEntity();
        String blobData = EntityUtils.toString(httpEntity);
        log.debug("The blob data I got was " + blobData);
        return blobData;

    } catch (ClientProtocolException e) {

        log.debug("Got Client Protocol Exception " + e.getMessage());
    } catch (IOException e) {

        log.debug("Got IOEXception " + e.getMessage());
    }

    return null;
}

Cuando se procesa un formulario adaptable con un parámetro guid en la dirección URL, el componente de página personalizada asociado a la plantilla recupera y rellena el formulario adaptable con los datos del almacenamiento de Azure.
El siguiente es el código en el jsp del componente de página asociado a la plantilla

com.aemforms.saveandfetchfromazure.StoreAndFetchDataFromAzureStorage azureStorage = sling.getService(com.aemforms.saveandfetchfromazure.StoreAndFetchDataFromAzureStorage.class);


String guid = request.getParameter("guid");

if(guid!=null&&!guid.isEmpty())
{
    String dataXml = azureStorage.getBlobData(guid);
    slingRequest.setAttribute("data",dataXml);

}

Prueba de la solución

recommendation-more-help
8de24117-1378-413c-a581-01e660b7163e