All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.threatconnect.sdk.client.AbstractClientAdapter Maven / Gradle / Ivy

Go to download

The ThreatConnect Java SDK. Used to communicate with teh ThreatConnect Threat Intelligence Platform

The newest version!
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.threatconnect.sdk.client;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.threatconnect.sdk.conn.AbstractRequestExecutor;
import com.threatconnect.sdk.conn.Connection;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * 

* Base client class used by {@link com.threatconnect.sdk.client.reader} and * {@link com.threatconnect.sdk.client.writer}. Conceptually works as an adapter * with a {@link com.threatconnect.sdk.conn.Connection} and a * {@link com.threatconnect.sdk.conn.AbstractRequestExecutor}. *

* *

* Implementing classes should abstract away low level API calls to the * {@link com.threatconnect.sdk.conn.AbstractRequestExecutor} and return high-level * {@link com.threatconnect.sdk.server.entity} style classes. *

* * */ public abstract class AbstractClientAdapter { /** * Base {@link com.threatconnect.sdk.conn.Connection} to REST API interface */ private Connection conn; /** * {@link com.threatconnect.sdk.conn.AbstractRequestExecutor} used to interact with * REST API */ protected AbstractRequestExecutor executor; /** * ObjectMapper used to marshall and unmarshall data with the REST API */ protected final ObjectMapper mapper = new ObjectMapper(); /** * Base constructor with required fields to create a basic client adapter * * @param conn Main object managing API connection */ public AbstractClientAdapter(Connection conn) { if ( conn == null ) { throw new IllegalStateException("Client doesn't have valid connection."); } this.conn = conn; this.executor = conn.getExecutor(); } /** * @return the conn */ public Connection getConn() { return conn; } /** * @param conn the conn to set */ public void setConn(Connection conn) { this.conn = conn; } protected static Map createParamMap( Object... keyOrValue ) { Map map = new HashMap<>(); for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy