0 Replies Latest reply: Mar 15, 2013 2:54 AM by 995111 RSS

    i am getting following error in my application please find the sol...jax rs

    995111
      15 Mar, 2013 1:09:49 PM com.sun.jersey.spi.container.ContainerRequest getEntity
      SEVERE: A message body reader for Java class aero.omanair.flightStatus.vo.SearchCriteriaVO, and Java type class aero.omanair.flightStatus.vo.SearchCriteriaVO, and MIME media type application/octet-stream was not found.
      The registered message body readers compatible with the MIME media type are:
      application/octet-stream ->
      com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
      com.sun.jersey.core.impl.provider.entity.FileProvider
      com.sun.jersey.core.impl.provider.entity.InputStreamProvider
      com.sun.jersey.core.impl.provider.entity.DataSourceProvider
      com.sun.jersey.core.impl.provider.entity.RenderedImageProvider
      */* ->
      com.sun.jersey.core.impl.provider.entity.FormProvider
      com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider

      please solve the issue......
      my pojo class is

      package aero.omanair.flightStatus.vo;



      import aero.omanair.flightStatus.util.FlightStatusUtils;
      @Entity
      @XmlRootElement
      @Consumes({"MediaType.MULTIPART_FORM_DATA", "application/x-www-form-urlencoded"})
      @Produces({"MediaType.MULTIPART_FORM_DATA", "application/x-www-form-urlencoded"})
      @XStreamAlias("SearchCriteriaVO")
      public class SearchCriteriaVO implements MessageBodyReader<JSONObject>, Serializable {     
           private static final long serialVersionUID = 1L;
           static final Logger logger = Logger.getLogger(SearchCriteriaVO.class);     
           
           private static final DateFormat TIMESTAMP_FORMAT_DEFAULT = new SimpleDateFormat("yyyy-MM-dd");
           private static final DateFormat DATE_FORMAT_DISPLAY = new SimpleDateFormat("dd-MMM-yyyy");
           
           private String tripType;
           private String fromStation;
           private String toStation;
           private String beginStationCode;
           private String beginStationName;
           private String destinationStationCode;
           private String destinationStationName;
           private String flightNumber;
           private String flightDate;
           private String flightDateDisp;
           //private Date scheduledTimeDeparture;
           private Timestamp scheduledTimeDep;
           private int connectingTime;
           
           private String searchResult;     
           private String searchdetails;
           
           private String errorMessage;
           private String infoMessage;
           @XStreamImplicit
           private Map<String,String> depDateList;

           public SearchCriteriaVO(
                     String tripType,
                     String flightNumber,
                     String flightDate) {
                
                this.tripType = tripType;
                this.flightNumber = flightNumber;
                this.flightDate = flightDate;
                
                populateDateList();     
           }     
           
           public SearchCriteriaVO(
                     String tripType,
                     String beginStationCode,
                     String beginStationName,
                     String destinationStationCode,
                     String destinationStationName,
                     String flightDate) {
                
                this.tripType = tripType;
                this.beginStationCode = beginStationCode;
                this.beginStationName = beginStationName;
                this.destinationStationCode = destinationStationCode;
                this.destinationStationName = destinationStationName;
                this.flightDate = flightDate;
                
                populateDateList();          
           }     
           
           public SearchCriteriaVO(){          
                String today="";
                
                try {
                     Calendar cal = Calendar.getInstance();
                     today = TIMESTAMP_FORMAT_DEFAULT.format(cal.getTime());
                } catch (Exception e) {
                     logger.error("Exception in SearchCriteriaVO: ", e);
                }
                
                this.setTripType("BRO");
                this.setSearchResult("");
                this.setFlightDate(today);
                
                populateDateList();          
           }
           @GET
           private void populateDateList(){
           try {
                     Calendar cal = Calendar.getInstance();
                     
                     String today = TIMESTAMP_FORMAT_DEFAULT.format(cal.getTime());
                     String todayDisplay = DATE_FORMAT_DISPLAY.format(cal.getTime());
                     
                     cal.add(Calendar.DATE, -1);     
                     String yesterday = TIMESTAMP_FORMAT_DEFAULT.format(cal.getTime());
                     String yesterdayDisp = DATE_FORMAT_DISPLAY.format(cal.getTime());
                     
                     cal.add(Calendar.DATE, +2);
                     String tomorrow = TIMESTAMP_FORMAT_DEFAULT.format(cal.getTime());
                     String tomorrowDisplay = DATE_FORMAT_DISPLAY.format(cal.getTime());
                          
                     
                     depDateList = new LinkedHashMap<String,String>();
                     depDateList.put(yesterday, yesterdayDisp);
                     depDateList.put(today, todayDisplay);          
                     depDateList.put(tomorrow, tomorrowDisplay);
                } catch (Exception e) {
                     logger.error("Exception in init: ", e);
                }
           }
           
           /**
           *
           */
           @GET
           public String toString() {
                StringBuffer sb = new StringBuffer("SearchCriteria{");
                
                sb.append("tripType :" + tripType);          
                sb.append(", beginStationCode :" + beginStationCode);
                sb.append(", beginStationName :" + beginStationName);
                sb.append(", destinationStationCode :" + destinationStationCode);
                sb.append(", destinationStationName :" + destinationStationName);               
                sb.append("}");
                
                return sb.toString();
           }
           @GET
           public void setSearchInfoMsg(){
                if(getTripType().equals("BRO")){               
                     if(StringUtils.isNotBlank(getBeginStationName()) && StringUtils.isNotBlank(getDestinationStationName()) && StringUtils.isNotBlank(getFlightDateDisp())){                                        
                          StringBuffer msg = new StringBuffer("Flight details for ");
                          msg.append(getBeginStationName());
                          msg.append(" - ");
                          msg.append(getDestinationStationName());                              
                          msg.append(" on : ");
                          msg.append(getFlightDateDisp());     
                          
                          setInfoMessage(msg.toString());
                     }
                }else if(getTripType().equals("BFL")){
                     if(StringUtils.isNotBlank(getFlightNumber()) && StringUtils.isNotBlank(getFlightDateDisp())){                                        
                          StringBuffer msg = new StringBuffer("Flight details for ");
                          msg.append("WY ");
                          msg.append(getFlightNumber());                         
                          msg.append(" on : ");
                          msg.append(getFlightDateDisp());     
                          
                          setInfoMessage(msg.toString());
                     }
                }
           }
           @GET
           public String getTripType() {
                return tripType;
           }
           @GET
           public void setTripType(String tripType) {
                this.tripType = tripType;
           }
           @GET
           public String getFromStation() {
                return fromStation;
           }
           @GET
           public void setFromStation(String fromStation) {
                this.fromStation = fromStation;
           }
           @GET
           public String getToStation() {
                return toStation;
           }
           @GET
           public void setToStation(String toStation) {
                this.toStation = toStation;
           }
           @GET
           public String getBeginStationCode() {
                return beginStationCode;
           }
           @GET
           public void setBeginStationCode(String beginStationCode) {
                this.beginStationCode = beginStationCode;
           }
           @GET
           public String getBeginStationName() {
                return beginStationName;
           }
           @GET
           public void setBeginStationName(String beginStationName) {
                this.beginStationName = beginStationName;
           }
           @GET
           public String getDestinationStationCode() {
                return destinationStationCode;
           }
           @GET
           public void setDestinationStationCode(String destinationStationCode) {
                this.destinationStationCode = destinationStationCode;
           }
           @GET
           public String getDestinationStationName() {
                return destinationStationName;
           }
           @GET
           public void setDestinationStationName(String destinationStationName) {
                this.destinationStationName = destinationStationName;
           }
           @GET
           public String getFlightNumber() {
                return flightNumber;
           }

           public void setFlightNumber(String flightNumber) {
                this.flightNumber = flightNumber;
           }
           @GET
           public String getFlightDate() {
                return flightDate;
           }
           @GET
           public void setFlightDate(String flightDate) {
                this.flightDate = flightDate;
           }

           /**
           * @return the depDateList
           */
           @GET
           public Map<String, String> getDepDateList() {
                return depDateList;
           }

           /**
           * @param depDateList the depDateList to set
           */
           @GET
           public void setDepDateList(Map<String, String> depDateList) {
                this.depDateList = depDateList;
           }
           @GET
           public String getSearchResult() {
                return searchResult;
           }
           @GET
           public void setSearchResult(String searchResult) {
                this.searchResult = searchResult;
           }
           @GET
           public String getSearchdetails() {
                return searchdetails;
           }
           @GET
           public void setSearchdetails(String searchdetails) {
                this.searchdetails = searchdetails;
           }

           /*public Date getScheduledTimeDeparture() {
                return scheduledTimeDeparture;
           }

           public void setScheduledTimeDeparture(Date scheduledTimeDeparture) {
                this.scheduledTimeDeparture = scheduledTimeDeparture;
           }*/
                
           /**
           * @return the scheduledTimeDep
           */
           @GET
           public Timestamp getScheduledTimeDep() {
                return scheduledTimeDep;
           }

           /**
           * @param scheduledTimeDep the scheduledTimeDep to set
           */
           @GET
           public void setScheduledTimeDep(Timestamp scheduledTimeDep) {
                this.scheduledTimeDep = scheduledTimeDep;
           }
           @GET
           public int getConnectingTime() {
                return connectingTime;
           }
           @GET
           public void setConnectingTime(int connectingTime) {
                this.connectingTime = connectingTime;
           }
           @GET
           public String getErrorMessage() {
                return errorMessage;
           }
           @GET
           public void setErrorMessage(String errorMessage) {
                this.errorMessage = errorMessage;
           }
           @GET
           public String getInfoMessage() {
                return infoMessage;
           }
           @GET
           public void setInfoMessage(String infoMessage) {
                this.infoMessage = infoMessage;
           }
           @GET
           public String getFlightDateDisp() {
                flightDateDisp = getFlightDate();
                
                if(StringUtils.isNotBlank(flightDateDisp)){
                     flightDateDisp = FlightStatusUtils.getDisplayDate(flightDateDisp);               
                }
                return flightDateDisp;
           }
           @GET
           public void setFlightDateDisp(String flightDateDisp) {
                this.flightDateDisp = flightDateDisp;
           }
           @GET
           public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2,
                     MediaType arg3) {
                // TODO Auto-generated method stub
                return false;
           }
           //public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2,
                //     MediaType arg3, MultivaluedMap<String, String> arg4,
                //     InputStream arg5) throws IOException, WebApplicationException {
                // TODO Auto-generated method stub
                //return null;
           //}
           @GET
           public JSONObject readFrom(Class<JSONObject> arg0, Type arg1,
                     Annotation[] arg2, MediaType arg3,
                     MultivaluedMap<String, String> arg4, InputStream arg5)
                     throws IOException, WebApplicationException {
                // TODO Auto-generated method stub
                return null;
           }          
                
      }
      and my service class is


      package aero.omanair.flightStatus.service.impl;

      import java.sql.Timestamp;
      import java.util.ArrayList;
      import java.util.Iterator;
      import java.util.List;

      import javax.ws.rs.FormParam;
      import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      import javax.ws.rs.WebApplicationException;
      import javax.ws.rs.core.MediaType;
      import javax.ws.rs.core.MultivaluedMap;
      import javax.ws.rs.ext.MessageBodyReader;
      import javax.ws.rs.ext.MessageBodyWriter;
      import javax.ws.rs.ext.Provider;
      import javax.ws.rs.Produces;
      import javax.ws.rs.Consumes;
      import javax.xml.bind.annotation.XmlElement;
      import javax.xml.bind.annotation.XmlRootElement;
      import java.io.File;
      import java.io.IOException;
      import java.io.InputStream;
      import java.io.OutputStream;
      import java.lang.annotation.Annotation;
      import java.lang.reflect.Type;


      @Path("hello")
      @Singleton
      @Provider public class FlightStatusManagerImpl implements FlightStatusManager,Constants,MessageBodyReader<SearchCriteriaVO> {
           private static final Object FlightStatusVO = null;
           private FlightStatusDAO flightStatusDAO;
           private SectorDAO sectorDAO;
           private Object FloghtStatusVO;
           private FlightStatusVO FlightStatus;
           public FlightStatusManagerImpl()
           {
                SearchCriteriaVO cv=new SearchCriteriaVO();
                cv.setFromStation("HYD");
                cv.setToStation("BGL");
           }
           
           /*Method that returns the list of FlightStatusVO based on the searchCriteria*/
           @GET
           @Produces({"application/xml", "application/octet-stream"})
                     @Consumes({"application/xml", "application/octet-stream"})
           public List<FlightStatusVO> searchAndExport(SearchCriteriaVO searchCriteria)throws OperationFailedException{
                try{     
                     
                     
                     
                //     SearchCriteriaVO searchCriteria = buildSearchCriteriaObj(searchParametersVO);
                     List<FlightStatusVO> flightStatusVO = new ArrayList<FlightStatusVO>();
                     List<FlightStatusVO> flightStatusListVO = new ArrayList<FlightStatusVO>();
                
                                                   
                     boolean connectionFlightChk= true;               
                     
                     //obCriteria = buildSearchCriteriaObj(request);
                     
                     String tripType = searchCriteria.getTripType();
                     String fromStationCode = searchCriteria.getBeginStationCode();
                     String fromStationDesc = searchCriteria.getBeginStationName();
                                                   
                     String toStationCode = searchCriteria.getDestinationStationCode();
                     String toStationDesc = searchCriteria.getDestinationStationName();
                     
                     String fromStation = StringUtils.isNotBlank(fromStationCode) ? fromStationCode : "";
                     fromStation = fromStation + (StringUtils.isNotBlank(fromStationDesc) ? "("+fromStationDesc+")" : "");
                                    
                     String toStation = StringUtils.isNotBlank(toStationCode) ? toStationCode : "";
                     toStation = toStation + (StringUtils.isNotBlank(toStationDesc) ? "("+toStationDesc+")" : "");
                     
                     searchCriteria.setFromStation(fromStation);
                     searchCriteria.setToStation(toStation);
                     
                     flightStatusVO = flightStatusDAO.getDirectFlights(searchCriteria);
                     flightStatusDAO.setReplacementFlight(flightStatusVO, toStationCode, toStationDesc, false);
                     
                     if(StringUtils.isNotBlank(tripType) && tripType.equals("BRO")){
                          if((StringUtils.isNotBlank(toStationCode) && toStationCode.contains(BASE_STATION_NAME))
                                    || (StringUtils.isNotBlank(toStationDesc) && toStationDesc.contains(BASE_STATION_NAME))
                                    || (StringUtils.isNotBlank(fromStationCode) && fromStationCode.contains(BASE_STATION_CODE))
                                    || (StringUtils.isNotBlank(fromStationDesc) && fromStationDesc.contains(BASE_STATION_NAME))){
                               
                               connectionFlightChk = false;
                          }
                          
                          if(connectionFlightChk){
                               searchCriteria.setConnectingTime(11);
                               List<FlightStatusVO> connectionFlights = flightStatusDAO.getCircularFlights(searchCriteria, BASE_STATION_CODE);
                               
                               if(!connectionFlights.isEmpty()){
                                    flightStatusVO.addAll(connectionFlights);
                               }                                        
                          }
                          
                          if((StringUtils.isNotBlank(fromStationCode) && fromStationCode.contains(BASE_STATION_CODE)) || (StringUtils.isNotBlank(fromStationDesc) && fromStationDesc.contains(BASE_STATION_NAME))) {
                               String sectorPattern = StringUtils.isNotBlank(toStationCode) ? "-"+toStationCode : "";
                                         
                               List<String> toSectors = null;
                               
                               if(StringUtils.isNotBlank(sectorPattern)){
                                    toSectors = sectorDAO.searchSectors(sectorPattern);
                                    
                                    List<String> connectingSectors = new ArrayList<String>();
                                                                  
                                    Iterator<String> it = toSectors.iterator();
                                    while (it.hasNext()) {
                                         String toSector = (String) it.next();
                                         String connectingStation = toSector.split("-")[0];
                                         connectingSectors.add(BASE_STATION_CODE+"-"+connectingStation);
                                    }
                                    
                                    if(connectingSectors.size() > 0){
                                         List<String> validSectors = new ArrayList<String>();
                                         validSectors = sectorDAO.checkSectorExist(connectingSectors);
                                         
                                         Iterator<String> itr = validSectors.iterator();
                                         while (itr.hasNext()) {
                                              String sector = itr.next();
                                              String stopOver = StringUtils.isNotBlank(sector) ? sector.split("-")[1] : null;
                                                                                 
                                              searchCriteria.setConnectingTime(9);                                   
                                              List<FlightStatusVO> circularFlights = flightStatusDAO.getCircularFlights(searchCriteria, stopOver);
                                              
                                              if(!circularFlights.isEmpty()){
                                                   flightStatusVO.addAll(circularFlights);
                                              }
                                         }
                                    }
                          }                                                  
                                                        
                          } else if((StringUtils.isNotBlank(toStationCode) && toStationCode.contains(BASE_STATION_CODE)) || (StringUtils.isNotBlank(toStationDesc) && toStationDesc.contains(BASE_STATION_NAME))){
                               String sectorPattern = StringUtils.isNotBlank(fromStationCode) ? fromStationCode+"-" : "";
                                                        
                               List<String> fromSectors = null;
                               
                               if(StringUtils.isNotBlank(sectorPattern)){
                                    fromSectors = sectorDAO.searchSectors(sectorPattern);
                                    
                                    List<String> connectingFSectors = new ArrayList<String>();
                                                                  
                                    Iterator<String> it = fromSectors.iterator();
                                    while (it.hasNext()) {
                                         String toSector = (String) it.next();
                                         String connectingFStation = toSector.split("-")[1];
                                         connectingFSectors.add(connectingFStation+"-"+BASE_STATION_CODE);
                                    }
                                    
                                    if(connectingFSectors.size()!=0){
                                         List<String> validFSectors = new ArrayList<String>();
                                         validFSectors = sectorDAO.checkSectorExist(connectingFSectors);
                                         Iterator<String> itr= validFSectors.iterator();
                                         
                                         while (itr.hasNext()) {
                                              String sector = itr.next();
                                              String stopOver = StringUtils.isNotBlank(sector) ? sector.split("-")[0] : null;
                                              
                                              searchCriteria.setConnectingTime(9);
                                              List<FlightStatusVO> circularFlights = flightStatusDAO.getCircularFlights(searchCriteria, stopOver);
                                              
                                              if(!circularFlights.isEmpty()){
                                                   flightStatusVO.addAll(circularFlights);
                                              }                                   
                                         }
                                    }
                               }
                          }                    
                     }
                     
                     flightStatusDAO.setReplacementFlight(flightStatusVO, toStationCode, toStationDesc, true);
                     
                     searchCriteria.setBeginStationName(searchCriteria.getFromStation());
                     searchCriteria.setDestinationStationName(searchCriteria.getToStation());
                     //searchCriteria.setSearchResult("Flight Not Available");
                     //searchCriteria.setSearchdetails("Flight details for ");
                     
                     //request.setAttribute("flightStatusList", flightStatusVO);
                     //request.setAttribute("searchCriteriaVO", obCriteria);
                     flightStatusVO = statusCalculation(flightStatusVO);
                     return flightStatusVO;          
                } catch (Exception e) {               
                     /*SearchCriteriaVO searchCriteriaVO = new SearchCriteriaVO();
                     searchCriteriaVO.setErrorMessage(e.getMessage());
                     
                     String tripType = StringUtils.isNotBlank(request.getParameter("tripType")) ? request.getParameter("tripType").trim() : null;
                     flightDate = request.getParameter("flightDate");     
                     
                     if(StringUtils.isNotBlank(tripType) && tripType.equals("BRO")){
                          fromStationName = StringUtils.isNotBlank(request.getParameter("fmCode_visible")) ? request.getParameter("fmCode_visible").trim() : null;                              
                          toStationName = StringUtils.isNotBlank(request.getParameter("toCode_visible")) ? request.getParameter("toCode_visible").trim() : null;
                          
                          searchCriteriaVO.setTripType(tripType);
                          searchCriteriaVO.setFlightDate(flightDate);
                          searchCriteriaVO.setBeginStationName(fromStationName);
                          searchCriteriaVO.setDestinationStationName(toStationName);
                          
                     } else if(StringUtils.isNotBlank(tripType) && tripType.equals("BFL")){
                          flightNumber = StringUtils.isNotBlank(request.getParameter("flightNumber")) ? request.getParameter("flightNumber").trim() : null;
                          
                          searchCriteriaVO.setTripType(tripType);
                          searchCriteriaVO.setFlightDate(flightDate);
                          searchCriteriaVO.setFlightNumber(flightNumber);               
                     }               
                     
                     request.setAttribute("searchCriteriaVO", searchCriteriaVO);*/
                     throw new OperationFailedException(e.getMessage());               
                }     
                
      }
           
           
           public SearchCriteriaVO buildSearchCriteriaObj(SearchParametersVO searchParamenterVO) throws OperationFailedException{
                
                String fromStationCode = null;
                String fromStationDesc = null;
                String toStationCode = null;
                String toStationDesc = null;
                String fromStation = searchParamenterVO.getFromStationName();
                String toStation = searchParamenterVO.getToStationName();
                
                if(StringUtils.isNotBlank(searchParamenterVO.getTripType()) && searchParamenterVO.getTripType().equals("BRO")) {
                if(StringUtils.isNotBlank(fromStation)){                                        
                     int length = (fromStation).length();               
                     if(length > 3){
                          if(fromStation.contains("(") && fromStation.contains(")")){
                               int beginIndex = fromStation.indexOf("(");
                               int endIndex = fromStation.indexOf(")");
                               
                               fromStationCode = fromStation.substring(0, beginIndex);
                               fromStationDesc = fromStation.substring(beginIndex+1, endIndex);
                               
                          } else if(fromStation.contains("(")){
                               int beginIndex = fromStation.indexOf("(");
                               int endIndex = length;
                                         
                               fromStationCode = fromStation.substring(0, beginIndex);
                               fromStationDesc = fromStation.substring(beginIndex+1, endIndex);
                               
                          } else if(fromStation.contains(")")){
                               int beginIndex = 0;
                               int endIndex = fromStation.indexOf(")");
                               
                               fromStationCode = null;
                               fromStationDesc = fromStation.substring(beginIndex, endIndex);
                               
                          } else{
                               fromStationCode = null;
                               fromStationDesc = fromStation;
                          }                         
                     } else if(length == 3 && !fromStation.contains("(") && !fromStation.contains(")")) {
                          fromStationCode = fromStation;
                          fromStationDesc = null;
                          
                     } else{
                          //request.setAttribute("message", "Please enter a valid From Station");
                          throw new OperationFailedException("Please enter a valid From Station");
                     }
                     
                     fromStationCode = flightStatusDAO.isValidFromStationCode(fromStationCode) ? fromStationCode : null;
                     fromStationDesc = flightStatusDAO.isValidFromStationDesc(fromStationDesc) ? fromStationDesc : null;
                     
                     if(StringUtils.isBlank(fromStationCode) && StringUtils.isBlank(fromStationDesc)){
                          //request.setAttribute("message", "Please enter a valid From Station");
                          throw new OperationFailedException("Please enter a valid From Station");                         
                     }
                }          
                if(StringUtils.isNotBlank(toStation)){                                        
                     int length = toStation.length();               
                     if(length > 3){
                          if(toStation.contains("(") && toStation.contains(")")){
                               int beginIndex = toStation.indexOf("(");
                               int endIndex = toStation.indexOf(")");
                               
                               toStationCode = toStation.substring(0, beginIndex);
                               toStationDesc = toStation.substring(beginIndex+1, endIndex);
                               
                          } else if(toStation.contains("(")){
                               int beginIndex = toStation.indexOf("(");
                               int endIndex = length;
                                         
                               toStationCode = toStation.substring(0, beginIndex);
                               toStationDesc = toStation.substring(beginIndex+1, endIndex);
                               
                          } else if(toStation.contains(")")){
                               int beginIndex = 0;
                               int endIndex = toStation.indexOf(")");
                               
                               toStationCode = null;
                               toStationDesc = toStation.substring(beginIndex, endIndex);
                               
                          } else{
                               toStationCode = null;
                               toStationDesc = toStation;
                          }                         
                     } else if(length == 3 && !toStation.contains("(") && !toStation.contains(")")) {
                          toStationCode = toStation;
                          toStationDesc = null;
                          
                     } else{
                          //request.setAttribute("message", "Please enter a valid To Station");
                          throw new OperationFailedException("Please enter a valid To Station");
                     }
                     
                     toStationCode = flightStatusDAO.isValidToStationCode(toStationCode) ? toStationCode : null;
                     toStationDesc = flightStatusDAO.isValidToStationDesc(toStationDesc) ? toStationDesc : null;
                     
                     if(StringUtils.isBlank(toStationCode) && StringUtils.isBlank(toStationDesc)){
                          //request.setAttribute("message", "Please enter a valid To Station");
                          throw new OperationFailedException("Please enter a valid To Station");                         
                     }
                }
                
                if(StringUtils.isNotBlank(fromStationCode) && StringUtils.isNotBlank(toStationCode) && fromStationCode.equalsIgnoreCase(toStationCode)){
                     //request.setAttribute("message", "From and To Stations cannot be the same");
                     throw new OperationFailedException("From and To Stations cannot be the same");
                }
                
                if(StringUtils.isNotBlank(fromStationDesc) && StringUtils.isNotBlank(toStationDesc) && fromStationDesc.equalsIgnoreCase(toStationDesc)){
                     //request.setAttribute("message", "From and To Stations cannot be the same");
                     throw new OperationFailedException("From and To Stations cannot be the same");
                }          
                SearchCriteriaVO searchCriteriaVO = new SearchCriteriaVO(searchParamenterVO.getTripType(), fromStationCode, fromStationDesc, toStationCode, toStationDesc, searchParamenterVO.getFlightDate());               
                //session.putValue("searchCriteriaVO", searchCriteriaVO);
                
                return searchCriteriaVO;     
                
           } else if(StringUtils.isNotBlank(searchParamenterVO.getTripType()) && searchParamenterVO.getTripType().equals("BFL")){               
                
                String flightNumber=StringUtils.isNotBlank(searchParamenterVO.getFlightNumber()) ? searchParamenterVO.getFlightNumber().trim() : null;
                searchParamenterVO.setFlightNumber(flightNumber) ;
                
                if(StringUtils.isBlank(searchParamenterVO.getFlightNumber())){
                     //request.setAttribute("message", "Please enter valid Flight Number");
                     throw new OperationFailedException("Please enter valid Flight Number");
                }
                               
                SearchCriteriaVO searchCriteriaVO = new SearchCriteriaVO(searchParamenterVO.getTripType(), flightNumber, searchParamenterVO.getFlightDate());                         
                //session.putValue("searchCriteriaVO", searchCriteriaVO);               
                
                return searchCriteriaVO;     
                
           } else{
                //request.setAttribute("message", "Please select a valid Trip Type");
                throw new OperationFailedException("Please select a valid Trip Type");
           }
           }

           
           /*This method is written for displaying Flight Status: written on 28/1/2013*/
           public List<FlightStatusVO> statusCalculation(List<FlightStatusVO> flightStatusListVO)
           {
                List<FlightStatusVO> flightStatus = new ArrayList<FlightStatusVO>();
                //String flightStatusDescription;
                //String statusDisplay;
                if(flightStatusListVO.size()>0){
                     for(int i=0;i<flightStatusListVO.size();i++){               
                          FlightStatusVO flightStatusVO =new FlightStatusVO();
                          flightStatusVO=flightStatusListVO.get(i);
                          if(flightStatusVO.getFlightStatus() =="CNLD" || flightStatusVO.getFlightStatus() =="RTND")
                          {
                               flightStatusVO.setStatusDisplay(flightStatusVO.getFlightStatusDesc());
                          }
                          else if(flightStatusVO.getActualTimeArv() != null)
                          {
                               flightStatusVO.setStatusDisplay("ARRIVED");
                          }else if(flightStatusVO.getActualTimeDep() != null)
                          {     
                               flightStatusVO.setStatusDisplay("IN FLIGHT");
                               
                          }else
                          {
                               flightStatusVO.setStatusDisplay("NOT YET DEPARTED");               
                          }
                          flightStatus.add(flightStatusVO);
                     }
                }
                
                return flightStatus;
           }
           /*Method for displaying flight status ends here*/
           
           

           public FlightStatusDAO getFlightStatusDAO() {
                return flightStatusDAO;
           }

           public void setFlightStatusDAO(FlightStatusDAO flightStatusDAO) {
                this.flightStatusDAO = flightStatusDAO;
           }

           public SectorDAO getSectorDAO() {
                return sectorDAO;
           }

           public void setSectorDAO(SectorDAO sectorDAO) {
                this.sectorDAO = sectorDAO;
           }


           public long getSize(Object arg0, Class arg1, Type arg2, Annotation[] arg3,
                     MediaType arg4) {
                // TODO Auto-generated method stub
                return 0;
           }


           public boolean isWriteable(Class arg0, Type arg1, Annotation[] arg2,
                     MediaType arg3) {
                // TODO Auto-generated method stub
                return false;
           }


           public void writeTo(Object arg0, Class arg1, Type arg2, Annotation[] arg3,
                     MediaType arg4, MultivaluedMap arg5, OutputStream arg6)
                     throws IOException, WebApplicationException {
                // TODO Auto-generated method stub
                
           }

           public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2,
                     MediaType arg3) {
                // TODO Auto-generated method stub
                return false;
           }

           public SearchCriteriaVO readFrom(Class<SearchCriteriaVO> arg0, Type arg1,
                     Annotation[] arg2, MediaType arg3,
                     MultivaluedMap<String, String> arg4, InputStream arg5)
                     throws IOException, WebApplicationException {
                // TODO Auto-generated method stub
                return null;
           }
      }


      plz find the solution...


      thanks in advance

      Edited by: 992108 on Mar 15, 2013 12:54 AM