Example usage for org.springframework.util MultiValueMap add

List of usage examples for org.springframework.util MultiValueMap add

Introduction

In this page you can find the example usage for org.springframework.util MultiValueMap add.

Prototype

void add(K key, @Nullable V value);

Source Link

Document

Add the given single value to the current list of values for the given key.

Usage

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Exports a CTL schema and all of its dependencies depending on the export method specified.
 *//*from w  w  w .  j  a v a 2  s  . c  om*/
public FileData downloadCtlSchemaByAppToken(CTLSchemaDto ctlSchemaDto, CTLSchemaExportMethod method,
        String appToken) {
    final FileDataResponseExtractor extractor = new FileDataResponseExtractor();
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.add("fqn", ctlSchemaDto.getMetaInfo().getFqn());
    parameters.add("version", Integer.toString(ctlSchemaDto.getVersion()));
    if (ctlSchemaDto.getMetaInfo().getApplicationId() != null) {
        parameters.add("applicationToken", appToken);
    }
    parameters.add("method", method.name());
    RequestCallback request = new DataRequestCallback<>(parameters);
    return restTemplate.execute(restTemplate.getUrl() + "CTL/exportSchema", HttpMethod.POST, request,
            extractor);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

public CTLSchemaDto saveCTLSchemaWithAppToken(String body, String tenantId, String applicationToken) {
    //CHECKSTYLE:ON
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add("body", body);
    if (tenantId != null) {
        params.add("tenantId", tenantId);
    }/*from  w  w w .j a va 2  s. com*/
    if (applicationToken != null) {
        params.add("applicationToken", applicationToken);
    }
    return restTemplate.postForObject(restTemplate.getUrl() + "CTL/saveSchema", params, CTLSchemaDto.class);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

public void deleteCTLSchemaByFqnVersionTenantIdAndApplicationToken(String fqn, Integer version, String tenantId,
        String applicationToken) {
    //CHECKSTYLE:ON
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add("fqn", fqn);
    params.add("version", version);
    if (tenantId != null) {
        params.add("tenantId", tenantId);
    }// w  w w .  j a  v a 2s  .  c o  m
    if (applicationToken != null) {
        params.add("applicationToken", applicationToken);
    }
    restTemplate.postForLocation(restTemplate.getUrl() + "CTL/deleteSchema", params);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Promote existing CTL schema meta info from application to tenant scope
 *
 * @param applicationId the id of application where schema was created
 * @param fqn           the fqn of promoting CTL schema
 * @return CtlSchemaMetaInfoDto the promoted CTL schema meta info object.
 *//*from   w  w w  .  j av  a2 s .c  om*/
public CtlSchemaMetaInfoDto promoteScopeToTenant(String applicationId, String fqn) {
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add("applicationId", applicationId);
    params.add("fqn", fqn);
    return restTemplate.postForObject(restTemplate.getUrl() + "CTL/promoteScopeToTenant", params,
            CtlSchemaMetaInfoDto.class);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Provides security credentials, allowing an endpoint that uses them to
 * interact with the specified application.
 *
 * @param applicationToken the application token to allow interaction with
 * @param credentialsBody  the security credentials to save
 */// w  ww. j a v a  2  s. c  o m
public CredentialsDto provisionCredentials(String applicationToken, byte[] credentialsBody) {
    MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
    parameters.add("applicationToken", applicationToken);
    parameters.add("credentialsBody", Base64Utils.encodeToString(credentialsBody));
    return this.restTemplate.postForObject(restTemplate.getUrl() + "provisionCredentials", parameters,
            CredentialsDto.class);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Binds credentials to the specified server-side endpoint profile.
 *
 * @param applicationToken     the application token
 * @param credentialsId        the id of the credentials to bind
 * @param serverProfileVersion the server-side endpoint profile version
 * @param serverProfileBody    the server-side endpoint profile body
 *//*from  ww w . j  a  v  a2  s .c o  m*/
public void provisionRegistration(String applicationToken, String credentialsId, Integer serverProfileVersion,
        String serverProfileBody) {
    MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
    parameters.add("applicationToken", applicationToken);
    parameters.add("credentialsId", credentialsId);
    parameters.add("serverProfileVersion", serverProfileVersion);
    parameters.add("serverProfileBody", serverProfileBody);
    this.restTemplate.postForLocation(restTemplate.getUrl() + "provisionRegistration", parameters);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Revokes security credentials from the corresponding credentials storage.
 * Also launches an asynchronous process to terminate all active sessions of
 * the endpoint that uses these credentials.
 *
 * @param applicationToken the application token
 * @param credentialsId     the id of the credentials
 *///from w  w w.j av  a  2s . c  om
public void revokeCredentials(String applicationToken, String credentialsId) {
    MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
    parameters.add("applicationToken", applicationToken);
    parameters.add("credentialsId", credentialsId);
    this.restTemplate.postForLocation(restTemplate.getUrl() + "revokeCredentials", parameters);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Used if credentials stored in external storage and Kaa server can't directly revoke them but
 * can be notified about security credentials revocation by external system.
 *
 * <p>If an endpoint is already registered with the specified credentials, this API
 * call launches an asynchronous process to terminate all active sessions of
 * the corresponding endpoint.</p>
 *
 * @param applicationToken the application token
 * @param credentialsId     the id of the credentials
 *///from   w  w w  .ja v a2s  . c  om
public void onCredentialsRevoked(String applicationToken, String credentialsId) {
    MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
    parameters.add("applicationToken", applicationToken);
    parameters.add("credentialsId", credentialsId);
    this.restTemplate.postForLocation(restTemplate.getUrl() + "notifyRevoked", parameters);
}

From source file:org.kuali.rice.kew.doctype.service.impl.DocumentSecurityServiceImpl.java

protected void processDocumentRequiringExtensionProcessing(List<Document> documentsRequiringExtensionProcessing,
        SecuritySession securitySession, Set<String> authorizations) {
    if (CollectionUtils.isNotEmpty(documentsRequiringExtensionProcessing)) {
        LOG.info("Beginning processing of documents requiring extension processing (total: "
                + documentsRequiringExtensionProcessing.size() + " documents)");
        long start = System.currentTimeMillis();
        MultiValueMap<PartitionKey, Document> partitions = partitionDocumentsForSecurity(
                documentsRequiringExtensionProcessing, securitySession);
        MultiValueMap<String, DocumentSecurityDirective> applicationSecurityDirectives = new LinkedMultiValueMap<String, DocumentSecurityDirective>();
        for (PartitionKey partitionKey : partitions.keySet()) {
            DocumentSecurityDirective directive = DocumentSecurityDirective
                    .create(partitionKey.getDocumentSecurityAttributeNameList(), partitions.get(partitionKey));
            applicationSecurityDirectives.add(partitionKey.applicationId, directive);
        }//from   w  ww. ja v a2s.  c  om
        for (String applicationId : applicationSecurityDirectives.keySet()) {
            List<DocumentSecurityDirective> documentSecurityDirectives = applicationSecurityDirectives
                    .get(applicationId);
            DocumentSecurityHandlerService securityHandler = loadSecurityHandler(applicationId);
            List<String> authorizedDocumentIds = securityHandler
                    .getAuthorizedDocumentIds(securitySession.getPrincipalId(), documentSecurityDirectives);
            if (CollectionUtils.isNotEmpty(authorizedDocumentIds)) {
                authorizations.addAll(authorizedDocumentIds);
            }
        }
        long end = System.currentTimeMillis();
        LOG.info("Finished processing of documents requiring extension processing (total time: " + (start - end)
                + ")");
    }
}

From source file:org.kuali.rice.kew.doctype.service.impl.DocumentSecurityServiceImpl.java

protected MultiValueMap<PartitionKey, Document> partitionDocumentsForSecurity(List<Document> documents,
        SecuritySession securitySession) {
    MultiValueMap<PartitionKey, Document> partitions = new LinkedMultiValueMap<PartitionKey, Document>();
    for (Document document : documents) {
        DocumentTypeSecurity security = getDocumentTypeSecurity(document.getDocumentTypeName(),
                securitySession);//from   w w w. j ava 2s. c o m
        MultiValueMap<String, ExtensionDefinition> securityAttributeExtensionDefinitions = loadExtensionDefinitions(
                security, securitySession);
        for (String applicationId : securityAttributeExtensionDefinitions.keySet()) {
            List<ExtensionDefinition> extensionDefinitions = securityAttributeExtensionDefinitions
                    .get(applicationId);
            PartitionKey key = new PartitionKey(applicationId, extensionDefinitions);
            partitions.add(key, document);
        }
    }
    return partitions;
}