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

io.github.fallwizard.rabbitmq.mgmt.BaseFluent Maven / Gradle / Ivy

The newest version!
package io.github.fallwizard.rabbitmq.mgmt;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.github.fallwizard.rabbitmq.mgmt.model.*;


import com.sun.jersey.api.client.GenericType;
import io.github.fallwizard.rabbitmq.mgmt.model.federation.FederationLink;

public class BaseFluent {

    private static final Logger logger = LoggerFactory.getLogger(BaseFluent.class);

	/**
	 * Helps deserialization with Gson.
	 */
	static final GenericType EXCHANGE = new GenericType(){};
	static final GenericType> EXCHANGE_COLLECTION = new GenericType>(){};
	
	static final GenericType BINDING = new GenericType(){};
	static final GenericType> BINDING_COLLECTION = new GenericType>(){};
	
	static final GenericType QUEUE = new GenericType(){};
	static final GenericType> QUEUE_COLLECTION = new GenericType>(){};

    static final GenericType PUBLISH_RESPONSE = new GenericType(){};

    static final GenericType MESSAGE = new GenericType(){};
    static final GenericType> MESSAGE_COLLECTION = new GenericType>(){};

	static final GenericType VHOST = new GenericType(){};
	static final GenericType> VHOST_COLLECTION = new GenericType>(){};
	
	static final GenericType PERMISSION = new GenericType(){};
	static final GenericType> PERMISSION_COLLECTION = new GenericType>(){};
	
	static final GenericType USER = new GenericType(){};
	static final GenericType> USER_COLLECTION = new GenericType>(){};
	
	static final GenericType NODE = new GenericType(){};
	static final GenericType> NODE_COLLECTION = new GenericType>(){};

    static final GenericType PARAMETER = new GenericType(){};
    static final GenericType> PARAMETER_COLLECTION = new GenericType>(){};

    static final GenericType POLICY = new GenericType(){};
    static final GenericType> POLICY_COLLECTION = new GenericType>(){};

    static final GenericType CONNECTION = new GenericType(){};
    static final GenericType> CONNECTION_COLLECTION = new GenericType>(){};

    static final GenericType FEDERATION_LINK = new GenericType(){};
    static final GenericType> FEDERATION_LINK_COLLECTION = new GenericType>(){};
	
	HttpContext HTTP;
	RabbitMgmtService mgmtService;

	public BaseFluent(HttpContext httpContext, RabbitMgmtService mgmtService){
		
		this.HTTP = httpContext;
		this.mgmtService = mgmtService;
	}
	
	public RabbitMgmtService and(){
		
		return this.mgmtService;
	}

    /**
     * Virtual Hosts use "/" in their names.  So we need to
     * encode the "/" to it's URL encoded representation "%2F".
     * @param vhost Virtual Host
     * @return Encoded String
     */
    public static String encodeSlashes(String vhost){

        String encodedValue = vhost;

        try {

            encodedValue = URLEncoder.encode(vhost, "UTF-8");

        } catch (UnsupportedEncodingException e) {

            logger.error("Failed to encode value: {}", vhost);
        }

        return encodedValue;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy