Example usage for org.apache.http.auth InvalidCredentialsException InvalidCredentialsException

List of usage examples for org.apache.http.auth InvalidCredentialsException InvalidCredentialsException

Introduction

In this page you can find the example usage for org.apache.http.auth InvalidCredentialsException InvalidCredentialsException.

Prototype

public InvalidCredentialsException() 

Source Link

Document

Creates a new InvalidCredentialsException with a null detail message.

Usage

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Gets a ContactListIterator to retrieve all contact lists associated with the authenticated user
 *//*from   www . j a v a2  s.  co  m*/
public ContactListIterator getContactLists()
        throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    String link = API_BASE + "/ws/customers/" + username + "/lists";
    ContactListIterator iterator = new ContactListIterator(this, link);
    iterator.loadNextPage();

    return iterator;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Gets a single ContactList based on its "link" attribute
 *//*from   w w  w  . ja  va 2  s.  co m*/
public ContactList getContactList(String link)
        throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    HashMap<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("Link", link);
    ContactList contactList = new ContactList(attributes, this, false);

    // Get an attribute, this should force the ModelObject to automatically populate
    if (contactList.getAttribute("ContactListId") == null
            || contactList.getAttribute("ContactListId").equals("")) {
        return null;
    }

    return contactList;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Gets a ContactListIterator to retrieve all contact lists associated with the contact list
 * @param link Link attribute of the contact list
 *//*from   ww w.j av  a2 s  . c  o  m*/
public ContactIterator getContactListMembers(String link)
        throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    ContactIterator iterator = new ContactIterator(this, API_BASE + link + "/members");
    iterator.loadNextPage();

    return iterator;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Gets a ContactIterator to retrieve all contacts associated with the authenticated user
 * Stored in reverse chronological order
 *///from ww w. j a v a2  s .co  m
public ContactIterator getContacts() throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    String link = API_BASE + "/ws/customers/" + username + "/contacts";
    ContactIterator iterator = new ContactIterator(this, link);
    iterator.loadNextPage();

    return iterator;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Gets a single Contact based on its EmailAddress attribute
 * Does not populate as much information as getContactById
 *//*from w w w.j  a v  a 2 s  .c o m*/
public Contact getContactByEmail(String email)
        throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    HashMap<String, Object> attributes = new HashMap<String, Object>();
    String link = "/ws/customers/" + username + "/contacts?email=" + email;
    attributes.put("Link", link);
    Contact contact = new Contact(attributes, this, false);

    // Get an attribute, this should force the ModelObject to automatically populate
    if (contact.getAttribute("ContactId") == null || contact.getAttribute("ContactId")
            .equals("http://api.constantcontact.com/ws/customers/" + username + "/contacts")) {
        return null;
    }

    return contact;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Gets a single Contact based on its Link attribute
 *///from  w w w  .ja  v a2s  .c  o m
public Contact getContactByLink(String link)
        throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    HashMap<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("Link", link);
    Contact contact = new Contact(attributes, this, false);

    // Get an attribute, this should force the ModelObject to automatically populate
    if (contact.getAttribute("ContactId") == null || contact.getAttribute("ContactId").equals("")) {
        return null;
    }

    return contact;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Gets a CampaignIterator to retrieve all campaigns associated with the authenticated user
 * Stored in reverse chronological order
 */// w  w  w . j av  a 2  s  .  c o  m
public CampaignIterator getCampaigns(CampaignType type)
        throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    String link = API_BASE + "/ws/customers/" + username + "/campaigns";

    if (type != CampaignType.ALL) {
        link += "?status=" + type.getName();
    }

    CampaignIterator iterator = new CampaignIterator(this, link);
    iterator.loadNextPage();

    return iterator;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Gets a single Campaign based on its Link attribute
 * @throws IOException /*from w ww.ja  v  a2s .  c  o m*/
 * @throws ClientProtocolException 
 * @throws InvalidCredentialsException 
 */
public Campaign getCampaign(String link)
        throws ClientProtocolException, IOException, InvalidCredentialsException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    HashMap<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("Link", link);
    Campaign campaign = new Campaign(attributes, this);

    // Get an attribute, this should force the ModelObject to automatically populate
    if (campaign.getAttribute("CampaignId") == null || campaign.getAttribute("CampaignId").equals("")) {
        return null;
    }

    return campaign;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Returns a ContactEventIterator to retrieve all ContactEvents associated with a Contact
 * @param contactLink Link attribute of contact
 * @param type The type of event to retrieve
 *///from   w  w  w .  j  a  v a  2s.  c  om
public ContactEventIterator getContactEvents(String contactLink, EventType type)
        throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    ContactEventIterator iterator = new ContactEventIterator(this,
            API_BASE + contactLink + "/events/" + type.getName());
    iterator.loadNextPage();

    return iterator;
}

From source file:com.ctctlabs.ctctwsjavalib.CTCTConnection.java

/**
 * Returns a ContactEventIterator to retrieve all ContactEvents associated with a Campaign
 * @param campaignLink Link attribute of campaign
 * @param type The type of event to retrieve
 * @return A list of CampaignEventIterators. Only one for all event types except clicks
 *//*from www . j  a  va2 s.  c  o m*/
@SuppressWarnings("unchecked")
public ArrayList<CampaignEventIterator> getCampaignEvents(String campaignLink, EventType type)
        throws InvalidCredentialsException, ClientProtocolException, IOException {
    if (username == null) {
        throw new InvalidCredentialsException();
    }

    ArrayList<CampaignEventIterator> iterators = new ArrayList<CampaignEventIterator>();
    if (type == EventType.CLICKS) {
        Campaign campaign = getCampaign(campaignLink);
        if (campaign.hasAttribute("Urls")) {
            for (String eventUrl : (ArrayList<String>) campaign.getAttribute("Urls")) {
                CampaignEventIterator iterator = new CampaignEventIterator(this,
                        eventUrl.replace("http://api.constantcontact.com", "https://api.constantcontact.com"));
                iterator.loadNextPage();
                iterators.add(iterator);
            }
        }

        return iterators;
    } else {
        CampaignEventIterator iterator = new CampaignEventIterator(this,
                API_BASE + campaignLink + "/events/" + type.getName());
        iterator.loadNextPage();

        iterators.add(iterator);
        return iterators;
    }
}