/*
 * =============================================================================
 * Copyright 1998-2012, IAESTE Internet Development Team. All rights reserved.
 * -----------------------------------------------------------------------------
 * Project: IntraWeb Services (iws-api) - net.iaeste.iws.api.requests.ProcessOfferRequest
 * -----------------------------------------------------------------------------
 * This software is provided by the members of the IAESTE Internet Development
 * Team (IDT) to IAESTE A.s.b.l. It is for internal use only and may not be
 * redistributed. IAESTE A.s.b.l. is not permitted to sell this software.
 *
 * This software is provided "as is"; the IDT or individuals within the IDT
 * cannot be held legally responsible for any problems the software may cause.
 * =============================================================================
 */
package net.iaeste.iws.api.requests;

import net.iaeste.iws.api.constants.IWSConstants;
import net.iaeste.iws.api.dtos.Offer;
import net.iaeste.iws.api.exceptions.VerificationException;

import java.util.HashMap;
import java.util.Map;

/**
 * @author  Kim Jensen / last $Author:$
 * @version $Revision:$ / $Date:$
 * @noinspection CastToConcreteClass
 * @since   1.7
 */
public final class ProcessOfferRequest implements Verifiable {

    /** {@link IWSConstants#SERIAL_VERSION_UID}. */
    private static final long serialVersionUID = IWSConstants.SERIAL_VERSION_UID;

    /** The Offer Object to process. */
    private Offer offer;

    /**
     * Empty Constructor, to use if the setters are invoked. This is required
     * for WebServices to work properly.
     */
    public ProcessOfferRequest() {
        offer = null;
    }

    /**
     * Default Constructor, sets the Offer to be processed. If the Offer exists,
     * it will be updated otherwise a new Offer will be created.
     *
     * @param offer object to create or update
     */
    public ProcessOfferRequest(final Offer offer) {
        this.offer = new Offer(offer);
    }

    // =========================================================================
    // Standard Setters & Getters
    // =========================================================================

    public void setOffer(final Offer offer) {
        this.offer = new Offer(offer);
    }

    public Offer getOffer() {
        return new Offer(offer);
    }

    // =========================================================================
    // Standard Request Methods
    // =========================================================================

    /**
     * {@inheritDoc}
     */
    @Override
    public void verify() throws VerificationException {
        if(offer == null) {
            throw new VerificationException("The Offer may not be null.");
        }
        offer.verify();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Map<String, String> validate() {
        return new HashMap<String, String>(0);
    }
}

@@ -1009,68 +1009,8 @@
 fer;
-%0Aimport net.iaeste.iws.api.exceptions.VerificationException;
 %0A%0Aim
@@ -1230,16 +1230,45 @@
 Request 
+extends AbstractVerification 
 implemen
@@ -2618,164 +2618,119 @@
 lic 
-void verify() throws VerificationException %7B%0A        if(offer == null) %7B%0A            throw new VerificationException(%22The Offer may not be null.%22
+Map%3CString, String%3E validate() %7B%0A        final HashMap%3CString, String%3E validation = new HashMap%3C%3E(0
 );%0A
+%0A
         
 %7D%0A  
@@ -2729,181 +2729,167 @@
     
-%7D%0A        offer.verify(
+isNotNull(validation, %22offer%22, offer
 );%0A    
-%7D%0A%0A
     
-/**%0A     * %7B@inheritDoc%7D%0A
+if(offer != null) %7B%0A   
      
-*/%0A
     
-@Override%0A    public Map%3CString, String%3E validate() %7B%0A        return new HashMap%3CString, String%3E(0)
+addAllErrors(validation, offer.validate());%0A        %7D%0A%0A        return validation
 ;%0A  

add AbstractVerification to ProcessOfferRequest, refs #106