@@ -0,0 +1,2602 @@
+/*%0A * Copyright 2010-2011 Ning, Inc.%0A *%0A * Ning licenses this file to you under the Apache License, version 2.0%0A * (the %22License%22); you may not use this file except in compliance with the%0A * License.  You may obtain a copy of the License at:%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the%0A * License for the specific language governing permissions and limitations%0A * under the License.%0A */%0Apackage com.ning.billing.invoice;%0A%0Aimport java.util.UUID;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.google.common.eventbus.Subscribe;%0Aimport com.google.inject.Inject;%0Aimport com.ning.billing.invoice.api.InvoiceApiException;%0Aimport com.ning.billing.util.callcontext.CallContext;%0Aimport com.ning.billing.util.callcontext.CallOrigin;%0Aimport com.ning.billing.util.callcontext.DefaultCallContext;%0Aimport com.ning.billing.util.callcontext.UserType;%0Aimport com.ning.billing.util.clock.Clock;%0Aimport com.ning.billing.util.dao.ObjectType;%0Aimport com.ning.billing.util.tag.ControlTagType;%0Aimport com.ning.billing.util.tag.api.ControlTagDeletionEvent;%0A%0Apublic class TagHandler %7B%0A%0A    private static final Logger log = LoggerFactory.getLogger(TagHandler.class);%0A%0A    private final Clock clock;%0A    private final InvoiceDispatcher dispatcher;%0A%0A    @Inject%0A    public TagHandler(final Clock clock,%0A            final InvoiceDispatcher dispatcher) %7B%0A        this.clock = clock;%0A        this.dispatcher = dispatcher;%0A    %7D%0A%0A    @Subscribe%0A    public void process_AUTO_INVOICING_OFF_removal(final ControlTagDeletionEvent event) %7B%0A        if (event.getTagDefinition().getName().equals(ControlTagType.AUTO_INVOICING_OFF.toString()) && event.getObjectType() ==  ObjectType.ACCOUNT) %7B%0A            final UUID accountId = event.getObjectId();%0A            processUnpaid_AUTO_INVOICING_OFF_invoices(accountId, event.getUserToken());%0A        %7D%0A    %7D%0A%0A    private void processUnpaid_AUTO_INVOICING_OFF_invoices(final UUID accountId, final UUID userToken) %7B%0A        try %7B%0A            final CallContext context = new DefaultCallContext(%22InvoiceTagHandler%22, CallOrigin.INTERNAL, UserType.SYSTEM, userToken, clock);%0A            dispatcher.processAccount(accountId, clock.getUTCNow(), false, context);%0A        %7D catch (InvoiceApiException e) %7B%0A            log.warn(String.format(%22Failed to process process removal AUTO_INVOICING_OFF for account %25s%22, accountId), e);%0A        %7D%0A    %7D%0A%7D%0A

Implement AUTO_INVOICING_OFF removal