Search in sources :

Example 1 with DeleteCampaign

use of com.xrtb.commands.DeleteCampaign in project XRTB by benmfaul.

the class WebCampaign method stopCampaign.

/**
	 * Delete a campaign
	 * 
	 * @param cmd
	 *            Map. The delete command map from the web user.
	 * @return String. The list of campaigns running.
	 */
public String stopCampaign(Map cmd) throws Exception {
    String name = (String) cmd.get("username");
    String adId = (String) cmd.get("id");
    Map response = new HashMap();
    try {
        Controller.getInstance().deleteCampaign(name, adId);
        response.put("error", false);
        DeleteCampaign command = new DeleteCampaign("", name, adId);
        command.to = "*";
        command.from = Configuration.getInstance().instanceName;
        Controller.getInstance().sendLog(3, "WebAccess-New-Campaign", "Campaign stopped:  " + adId);
    } catch (Exception error) {
        error.printStackTrace();
        response.put("message", "failed: " + error.toString());
        response.put("error", true);
    }
    response.put("running", Configuration.getInstance().getLoadedCampaignNames());
    return getString(response);
}
Also used : HashMap(java.util.HashMap) DeleteCampaign(com.xrtb.commands.DeleteCampaign) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with DeleteCampaign

use of com.xrtb.commands.DeleteCampaign in project XRTB by benmfaul.

the class Commands method stopCampaign.

/**
  * Stop a campaign by removing from bidders memory
  */
public void stopCampaign() {
    System.out.print("Which bidder to stop campaign:");
    String to = scan.nextLine();
    System.out.print("Which campaign owner: ");
    String owner = scan.nextLine();
    System.out.print("Which campaign: ");
    String cname = scan.nextLine();
    DeleteCampaign cmd = new DeleteCampaign(to, owner, cname);
    cmd.from = uuid;
    commands.add(cmd);
}
Also used : DeleteCampaign(com.xrtb.commands.DeleteCampaign)

Example 3 with DeleteCampaign

use of com.xrtb.commands.DeleteCampaign in project XRTB by benmfaul.

the class TestZZZRedis method deleteUnknownCampaign.

/**
	 * Test deleting a campaign
	 */
@Test
public void deleteUnknownCampaign() throws Exception {
    DeleteCampaign e = new DeleteCampaign("", "ben", "id123");
    e.id = "DELETECAMP-ID";
    rcv = null;
    latch = new CountDownLatch(1);
    commands.add(e);
    latch.await(5, TimeUnit.SECONDS);
}
Also used : DeleteCampaign(com.xrtb.commands.DeleteCampaign) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

DeleteCampaign (com.xrtb.commands.DeleteCampaign)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1