# com.bea.campaign.servlets
CampaignCleanupServlet Class

public class CampaignCleanupServlet
extends `HttpServlet`

A servlet which can handle cleaning up campaigns.

This supports the following servlet parameters:

- `campaignId`: the id/uri of the campaign.
- `cleanup`: this multi-valued parameter can one or more of the following values:
  - all - do all cleanup
  - endStates - cleanup end states
  - adBuckets - cleanup ad buckets
  - adCounts - cleanup ad counts
  - mailBatches - cleanup mail batches

It alse expects the following ejb-refs:

- java:comp/env/ejb/CampaignService
- java:comp/env/ejb/AdBucketService (optional)
- java:comp/env/ejb/AdService (optional)
- java:comp/env/ejb/MailService (optional)

If all the request cleanups succeed, a OK (200) status code will be returned. If one or more failed, a INTERNAL_ERROR (500) status code will be returned, plus the header 'BEA-CAMPAIGN-Cleanup-Failures' will be set to the comma-separate list of cleanUp values that failed.

Hierarchy
  `Object`
  `GenericServlet`
  `HttpServlet`
  `CampaignCleanupServlet`

All Implemented Interfaces
  `Serializable`, `Servlet`, `ServletConfig`

## Field Summary

`protected static final int` | `CLEANUP_AD_BUCKETS` Mask signifying ad bucket cleanup.
`protected static final int` | `CLEANUP_AD_COUNTS` Mask signifying ad count cleanup.
`protected static final int` | `CLEANUP_ALL` Mask signifying all cleanup.
`protected static final int` | `CLEANUP_END_STATES` Mask signifying end state cleanup.
`protected static final int` | `CLEANUP_MAIL_BATCHES` Mask signifying mail batches cleanup.
`public static final `String`` | `FAILED_REFRESH` String
`public static final `String`` | `REFRESH_STATUS` String
`public static final `String`` | `SUCCESSFUL_REFRESH` String

## Constructor Summary

CampaignCleanupServlet()

## Method Summary

`protected void` | `cleanupAdBuckets`(`String` campaignId) Cleanup a campaign's ad buckets.
`protected void` | `cleanupAdCounts`(`String` campaignId) Cleanup a campaign's ad count.
`protected void` | `cleanupEndStates`(`String` campaignId) Cleanup a campaign's end states.
`protected void` | `cleanupMailBatches`(`String` campaignId) Cleanup a campaign's mail batches.
`public void` | `doGet`(`HttpServletRequest` req, `HttpServletResponse` resp) Service a request.
`public void` | `doPost`(`HttpServletRequest` req, `HttpServletResponse` resp) Service a request.
`protected `AdBucketService`` | `getAdBucketService`() Get our java:comp/env/ejb/AdBucketService.
`protected `AdService`` | `getAdService`() Get our java:comp/env/ejb/AdService.
`protected `CampaignService`` | `getCampaignService`() Get our java:comp/env/ejb/CampaignService.
`protected `MailService`` | `getMailService`() Get our java:comp/env/ejb/MailService.
`protected int` | `handleCleanup`(`String` campaignId, int options) Handle the request cleanup options.
`public void` | `init`() Initialize this servlet.
`protected void` | `resetCampaign`(`String` campaignId) Reset a campaign's internal state.
`protected void` | `sendError`(`HttpServletResponse` resp, int status, `String` mesg) Send an error message.
`protected static `String`` | `toHTML`(`String` in) Convert a string to html.

Methods from `javax.servlet.http.`HttpServlet``
`doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service`

Methods from `javax.servlet.`GenericServlet``
`destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log, service`

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods from interface `javax.servlet.`Servlet``
`destroy, getServletConfig, getServletInfo, init, service`

Methods from interface `javax.servlet.`ServletConfig``
`getInitParameter, getInitParameterNames, getServletContext, getServletName`

## Field Detail

### CLEANUP_AD_BUCKETS

    protected static final int CLEANUP_AD_BUCKETS

  Mask signifying ad bucket cleanup.

### CLEANUP_AD_COUNTS

    protected static final int CLEANUP_AD_COUNTS

  Mask signifying ad count cleanup.

### CLEANUP_ALL

    protected static final int CLEANUP_ALL

  Mask signifying all cleanup.

### CLEANUP_END_STATES

    protected static final int CLEANUP_END_STATES

  Mask signifying end state cleanup.

### CLEANUP_MAIL_BATCHES

    protected static final int CLEANUP_MAIL_BATCHES

  Mask signifying mail batches cleanup.

### FAILED_REFRESH

    public static final String FAILED_REFRESH

### REFRESH_STATUS

    public static final String REFRESH_STATUS

### SUCCESSFUL_REFRESH

    public static final String SUCCESSFUL_REFRESH

## Constructor Detail

### CampaignCleanupServlet

    public CampaignCleanupServlet()

## Method Detail

### cleanupAdBuckets(String) Method

    protected void cleanupAdBuckets(String campaignId)
         throws CreateException, EJBException, RemoteException, ContentException

Cleanup a campaign's ad buckets.

#### Exceptions

``CreateException``
``EJBException``
``RemoteException``
``ContentException``

Related Topics

``AdBucketService.cleanupAdBucket(String)``

### cleanupAdCounts(String) Method

    protected void cleanupAdCounts(String campaignId)
         throws CreateException, EJBException, RemoteException, ContentException

Cleanup a campaign's ad count.

#### Exceptions

``CreateException``
``EJBException``
``RemoteException``
``ContentException``

Related Topics

``AdService.cleanupAdService(String)``

### cleanupEndStates(String) Method

    protected void cleanupEndStates(String campaignId)
         throws CreateException, EJBException, RemoteException

Cleanup a campaign's end states.

#### Exceptions

``CreateException``
``EJBException``
``RemoteException``

Related Topics

``CampaignService.clearEndStates(String)``

### cleanupMailBatches(String) Method

    protected void cleanupMailBatches(String campaignId)
         throws CreateException, EJBException, RemoteException, MailServiceException

Cleanup a campaign's mail batches.

#### Exceptions

``CreateException``
``EJBException``
``RemoteException``
``MailServiceException``

Related Topics

``MailService.deleteBatch(String)``

### doGet(HttpServletRequest, HttpServletResponse) Method

    public void doGet(HttpServletRequest req,
                      HttpServletResponse resp)
         throws ServletException, IOException

Service a request.

Overrides
  `HttpServlet.doGet(HttpServletRequest, HttpServletResponse)`

#### Exceptions

``ServletException``
``IOException``

### doPost(HttpServletRequest, HttpServletResponse) Method

    public void doPost(HttpServletRequest req,
                       HttpServletResponse resp)
         throws ServletException, IOException

Service a request.

Overrides
  `HttpServlet.doPost(HttpServletRequest, HttpServletResponse)`

#### Exceptions

``ServletException``
``IOException``

Related Topics

``CampaignCleanupServlet.doGet(HttpServletRequest, HttpServletResponse)``

### getAdBucketService() Method

    protected AdBucketService getAdBucketService()
         throws CreateException, RemoteException

Get our java:comp/env/ejb/AdBucketService.

This will use the ejb-ref if getCampaignService().getAdBucketService() fails.

#### Exceptions

``CreateException``
``RemoteException``

### getAdService() Method

    protected AdService getAdService()
         throws CreateException, RemoteException

Get our java:comp/env/ejb/AdService.

This will use the ejb-ref if getCampaignService().getAdService() fails.

#### Exceptions

``CreateException``
``RemoteException``

### getCampaignService() Method

    protected CampaignService getCampaignService()
         throws CreateException, RemoteException

Get our java:comp/env/ejb/CampaignService.

#### Exceptions

``CreateException``
``RemoteException``

### getMailService() Method

    protected MailService getMailService()
         throws CreateException, RemoteException

Get our java:comp/env/ejb/MailService.

This will use the ejb-ref if getCampaignService().getMailService() fails.

#### Exceptions

``CreateException``
``RemoteException``

### handleCleanup(String, int) Method

    protected int handleCleanup(String campaignId,
                                int options)

Handle the request cleanup options.

#### Returns

the bit-ORed list of options that failed.

### init() Method

    public void init()
         throws ServletException

Initialize this servlet.

This will initialize the various services.

Overrides
  `GenericServlet.init()`

#### Exceptions

``ServletException``

Related Topics

``CampaignCleanupServlet.getCampaignService()``
``CampaignCleanupServlet.getAdBucketService()``
``CampaignCleanupServlet.getAdService()``
``CampaignCleanupServlet.getMailService()``

### resetCampaign(String) Method

    protected void resetCampaign(String campaignId)
         throws CreateException, EJBException, RemoteException

Reset a campaign's internal state.

#### Exceptions

``CreateException``
``EJBException``
``RemoteException``

Related Topics

``CampaignService.resetCampaign(String)``

### sendError(HttpServletResponse, int, String) Method

    protected void sendError(HttpServletResponse resp,
                             int status,
                             String mesg)
         throws ServletException, IOException

Send an error message.

#### Exceptions

``ServletException``
``IOException``

### toHTML(String) Method

    protected static String toHTML(String in)

Convert a string to html.

Related Topics

``AdHelper.toHTML(String)``