/**
 * Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U <br>
 * This file is part of FI-WARE project.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License.
 * </p>
 * <p>
 * You may obtain a copy of the License at:<br>
 * <br>
 * http://www.apache.org/licenses/LICENSE-2.0
 * </p>
 * <p>
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * </p>
 * <p>
 * See the License for the specific language governing permissions and limitations under the License.
 * </p>
 * <p>
 * For those usages not covered by the Apache version 2.0 License please contact with opensource@tid.es
 * </p>
 */

package com.telefonica.euro_iaas.paasmanager.model;

import javax.persistence.Column;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Defines a message in a task.
 * 
 * @author Sergio Arroyo
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class TaskError {

    @XmlAttribute(required = true)
    @Column(length = 1024)
    private String message;
    @XmlAttribute(required = false)
    @Column(length = 1024)
    private String majorErrorCode;
    @XmlAttribute(required = false)
    private String minorErrorCode;
    @XmlAttribute(required = false)
    private String venodrSpecificErrorCode;

    /**
     */
    public TaskError() {
    }

    /**
     * @param message
     */
    public TaskError(String message) {
        setMessage(message);
    }

    /**
     * @return the majorErrorCode
     */
    public String getMajorErrorCode() {
        return majorErrorCode;
    }

    /**
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * @return the minorErrorCode
     */
    public String getMinorErrorCode() {
        return minorErrorCode;
    }

    /**
     * @return the venodrSpecificErrorCode
     */
    public String getVenodrSpecificErrorCode() {
        return venodrSpecificErrorCode;
    }

    /**
     * @param majorErrorCode
     *            the majorErrorCode to set
     */
    public void setMajorErrorCode(String majorErrorCode) {
        if (majorErrorCode.length() >= 1024) {
            this.majorErrorCode = majorErrorCode.substring(0, 1023);
        } else {
            this.majorErrorCode = majorErrorCode;
        }
    }

    /**
     * @param message
     *            the message to set
     */
    public void setMessage(String message) {

        if (message.length() >= 1024) {
            this.message = message.substring(0, 1023);
        } else {

            this.message = message;
        }
    }

    /**
     * @param minorErrorCode
     *            the minorErrorCode to set
     */
    public void setMinorErrorCode(String minorErrorCode) {
        this.minorErrorCode = minorErrorCode;
    }

    /**
     * @param venodrSpecificErrorCode
     *            the venodrSpecificErrorCode to set
     */
    public void setVenodrSpecificErrorCode(String venodrSpecificErrorCode) {
        this.venodrSpecificErrorCode = venodrSpecificErrorCode;
    }

    /**
     * Constructs a <code>String</code> with all attributes in name = value format.
     * 
     * @return a <code>String</code> representation of this object.
     */
    public String toString() {
        StringBuilder sb = new StringBuilder("[[TaskError]");
        sb.append("[message = ").append(this.message).append("]");
        sb.append("[majorErrorCode = ").append(this.majorErrorCode).append("]");
        sb.append("[minorErrorCode = ").append(this.minorErrorCode).append("]");
        sb.append("[venodrSpecificErrorCode = ").append(this.venodrSpecificErrorCode).append("]");
        sb.append("]");
        return sb.toString();
    }

}

@@ -2528,32 +2528,75 @@
 orErrorCode) %7B%0D%0A
+        if (majorErrorCode != null) %7B%0D%0A    
         if (majo
@@ -2619,32 +2619,36 @@
 h() %3E= 1024) %7B%0D%0A
+    
             this
@@ -2701,32 +2701,36 @@
 1023);%0D%0A        
+   
+ 
 %7D else %7B%0D%0A      
@@ -2719,24 +2719,28 @@
   %7D else %7B%0D%0A
+    
             
@@ -2774,24 +2774,39 @@
 ErrorCode;%0D%0A
+            %7D%0D%0A
         %7D%0D%0A 
@@ -2934,26 +2934,60 @@
 message) %7B%0D%0A
-%0D%0A
+        if (message != null) %7B%0D%0A    
         if (
@@ -3019,32 +3019,36 @@
  %7B%0D%0A            
+   
+ 
 this.message = m
@@ -3075,32 +3075,36 @@
 1023);%0D%0A        
+    
 %7D else %7B%0D%0A%0D%0A    
@@ -3103,32 +3103,36 @@
 %0D%0A%0D%0A            
+   
+ 
 this.message = m
@@ -3136,24 +3136,39 @@
 = message;%0D%0A
+            %7D%0D%0A
         %7D%0D%0A 

check null