
org.springframework.social.vkontakte.api.impl.AbstractVKontakteOperations Maven / Gradle / Ivy
/*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.vkontakte.api.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import org.springframework.social.MissingAuthorizationException;
import org.springframework.social.UncategorizedApiException;
import org.springframework.social.support.URIBuilder;
import org.springframework.social.vkontakte.api.VKGenericResponse;
import org.springframework.social.vkontakte.api.VKResponse;
import org.springframework.social.vkontakte.api.VKontakteErrorException;
import org.springframework.social.vkontakte.api.impl.json.VKArray;
import org.springframework.util.Assert;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
* Generic class for operation templates.
* @author vkolodrevskiy
*/
class AbstractVKontakteOperations {
private final static String VK_REST_URL = "https://api.vk.com/method/";
private final boolean isAuthorized;
private final String accessToken;
protected final ObjectMapper objectMapper;
public AbstractVKontakteOperations(boolean isAuthorized, String accessToken, ObjectMapper objectMapper) {
this.isAuthorized = isAuthorized;
this.accessToken = accessToken;
this.objectMapper = objectMapper;
}
protected void requireAuthorization() {
if (!isAuthorized) {
throw new MissingAuthorizationException("vkontakte");
}
}
protected URI makeOperationURL(String method, Properties params) {
URIBuilder uri = URIBuilder.fromUri(VK_REST_URL + method);
uri.queryParam("access_token", accessToken);
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy