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

com.threatconnect.sdk.client.writer.associate.AbstractAttributeAssociateWriterAdapter 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.writer.associate;

import com.threatconnect.sdk.client.UrlTypeable;
import com.threatconnect.sdk.client.response.WriteListResponse;
import com.threatconnect.sdk.client.writer.AbstractBaseWriterAdapter;
import com.threatconnect.sdk.conn.Connection;
import com.threatconnect.sdk.exception.FailedResponseException;
import com.threatconnect.sdk.server.entity.Attribute;
import com.threatconnect.sdk.server.response.entity.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *
 * @author dtineo
 */
public abstract class AbstractAttributeAssociateWriterAdapter extends AbstractBaseWriterAdapter 
    implements AttributeAssociateWritable

, UrlTypeable { public AbstractAttributeAssociateWriterAdapter(Connection conn, Class singleType) { super(conn, singleType ); } @Override public WriteListResponse addAttributes(P uniqueId, List attributes) throws IOException { return addAttributes(uniqueId, attributes, null); } @Override public WriteListResponse addAttributes(P uniqueId, List attributes, String ownerName) throws IOException { Map map = createParamMap("id", uniqueId); WriteListResponse data = createList(getUrlBasePrefix() + ".byId.attributes", AttributeListResponse.class, ownerName, map, attributes); return data; } @Override public ApiEntitySingleResponse addAttribute(P uniqueId, Attribute attribute) throws IOException, FailedResponseException { return addAttribute(uniqueId, attribute, null); } @Override public ApiEntitySingleResponse addAttribute(P uniqueId, Attribute attribute, String ownerName) throws IOException, FailedResponseException { Map map = createParamMap("id", uniqueId); AttributeResponse item = createItem(getUrlBasePrefix() + ".byId.attributes", AttributeResponse.class, ownerName, map, attribute); return item; } @Override public WriteListResponse addAttributeSecurityLabels(P uniqueId, Integer attributeId, List securityLabels ) throws IOException { return addAttributeSecurityLabels(uniqueId, attributeId, securityLabels, null); } @Override public WriteListResponse addAttributeSecurityLabels(P uniqueId, Integer attributeId, List securityLabels, String ownerName) throws IOException { Map map = createParamMap("id", uniqueId, "attributeId", attributeId); WriteListResponse data = createListWithParam(getUrlBasePrefix() + ".byId.attributes.byId.securityLabels.byName", SecurityLabelListResponse.class, ownerName, map, "securityLabel", securityLabels ); return data; } @Override public ApiEntitySingleResponse addAttributeSecurityLabel(P uniqueId, Integer attributeId, String securityLabel) throws IOException, FailedResponseException { return addAttributeSecurityLabel(uniqueId, attributeId, securityLabel, null); } @Override public ApiEntitySingleResponse addAttributeSecurityLabel(P uniqueId, Integer attributeId, String securityLabel, String ownerName) throws IOException, FailedResponseException { Map map = createParamMap("id", uniqueId, "attributeId", attributeId, "securityLabel", securityLabel); SecurityLabelResponse data = createItem(getUrlBasePrefix() + ".byId.attributes.byId.securityLabels.byName", SecurityLabelResponse.class, ownerName, map, null); return data; } @Override public WriteListResponse updateAttributes(P uniqueId, List attributes) throws IOException { return updateAttributes(uniqueId, attributes, null); } @Override public WriteListResponse updateAttributes(P uniqueId, List attributes, String ownerName) throws IOException { Map map = createParamMap("id", uniqueId); List idList = new ArrayList<>(); for( Attribute a : attributes ) idList.add( a.getId() ); WriteListResponse data = updateListWithParam(getUrlBasePrefix() + ".byId.attributes.byId", AttributeListResponse.class, ownerName, map, "attributeId", idList, attributes); return data; } @Override public ApiEntitySingleResponse updateAttribute(P uniqueId, Attribute attribute) throws IOException, FailedResponseException { return updateAttribute(uniqueId, attribute, null); } @Override public ApiEntitySingleResponse updateAttribute(P uniqueId, Attribute attribute, String ownerName) throws IOException, FailedResponseException { Map map = createParamMap("id", uniqueId, "attributeId", attribute.getId() ); AttributeResponse item = updateItem(getUrlBasePrefix() + ".byId.attributes.byId", AttributeResponse.class, ownerName, map, attribute); return item; } @Override public WriteListResponse deleteAttributes(P uniqueId, List attributes) throws IOException { return deleteAttributes(uniqueId, attributes, null); } @Override public WriteListResponse deleteAttributes(P uniqueId, List attribute, String ownerName) throws IOException { Map map = createParamMap("id", uniqueId); List idList = new ArrayList<>(); for(Integer it : attribute) idList.add( it ); WriteListResponse data = deleteList(getUrlBasePrefix() + ".byId.attributes.byId" , AttributeResponse.class, ownerName, map, "attributeId", idList); return data; } @Override public ApiEntitySingleResponse deleteAttribute(P uniqueId, Integer attribute) throws IOException, FailedResponseException { return deleteAttribute(uniqueId, attribute, null); } @Override public ApiEntitySingleResponse deleteAttribute(P uniqueId, Integer attribute, String ownerName) throws IOException, FailedResponseException { Map map = createParamMap("id", uniqueId, "attributeId", attribute); ApiEntitySingleResponse item = deleteItem(getUrlBasePrefix() + ".byId.attributes.byId", AttributeResponse.class, ownerName, map); return item; } @Override public WriteListResponse deleteAttributeSecurityLabels(P uniqueId, Integer attributeId, List securityLabels) throws IOException { return deleteAttributeSecurityLabels(uniqueId, attributeId, securityLabels, null); } @Override public WriteListResponse deleteAttributeSecurityLabels(P uniqueId, Integer attributeId, List securityLabels, String ownerName) throws IOException { Map map = createParamMap("id", uniqueId); WriteListResponse data = deleteList(getUrlBasePrefix() + ".byId.attributes.byId.securityLabels.byName" , SecurityLabelResponse.class, ownerName, map, "securityLabel", securityLabels); return data; } @Override public ApiEntitySingleResponse deleteAttributeSecurityLabel(P uniqueId, Integer attributeId, String securityLabel) throws IOException, FailedResponseException { return deleteAttributeSecurityLabel(uniqueId, attributeId, securityLabel, null); } @Override public ApiEntitySingleResponse deleteAttributeSecurityLabel(P uniqueId, Integer attributeId, String securityLabel, String ownerName) throws IOException, FailedResponseException { Map map = createParamMap("id", uniqueId, "securityLabel", securityLabel); ApiEntitySingleResponse item = deleteItem(getUrlBasePrefix() + ".byId.attributes.byId.securityLabels.byName", SecurityLabelResponse.class, ownerName, map); return item; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy