private ArrayList<StudentPersonalType> fetchStudents(
      HashMap<String, StudentPersonalType> studentMap, PagingInfo pagingInfo) {
    ArrayList<StudentPersonalType> studentList = new ArrayList<StudentPersonalType>();
    if (pagingInfo == null) // return all
    {
      studentList.addAll(studentMap.values());
    } else {
      pagingInfo.setTotalObjects(studentMap.size());
      if ((pagingInfo.getPageSize() * (pagingInfo.getCurrentPageNo())) > studentMap.size()) {
        return null; // Requested page outside of limits.
      }

      // retrieve applicable students
      Collection<StudentPersonalType> allStudent = studentMap.values();
      int i = 0;
      int startPos = pagingInfo.getPageSize() * pagingInfo.getCurrentPageNo();
      int endPos = startPos + pagingInfo.getPageSize();
      for (Iterator<StudentPersonalType> iter = allStudent.iterator(); iter.hasNext(); ) {
        StudentPersonalType student = iter.next();
        if ((i >= startPos) && (i < endPos)) {
          studentList.add(student);
        }
        i++;
      }
      // Set the number of object that are returned in the paging info. Will ensure HTTP headers are
      // set correctly.
      pagingInfo.setPageSize(studentList.size());
    }

    return studentList;
  }
  /* (non-Javadoc)
   * @see sif3.common.interfaces.Provider#retrive(sif3.common.model.SIFZone, sif3.common.model.SIFContext, sif3.common.model.PagingInfo)
   */
  @Override
  public Object retrieve(
      SIFZone zone,
      SIFContext context,
      PagingInfo pagingInfo,
      RequestMetadata metadata,
      ResponseParameters customResponseParams)
      throws PersistenceException, UnsupportedQueryException, DataTooLargeException {
    logger.debug(
        "Retrieve Students for "
            + getZoneAndContext(zone, context)
            + " and RequestMetadata = "
            + metadata);
    logger.debug("ChangedSince Date: " + metadata.getRequestParameter("ChangedSince"));
    logger.debug("Custom HTTP Header (customHdr): " + metadata.getHTTPParameter("customHdr"));

    // Should go all the way to consumer
    customResponseParams.addHTTPHeaderParameter("testHTTPResponseParam", "testValue");

    // Should override a default from the provider properties file.
    customResponseParams.addHTTPHeaderParameter("test", "providerPropertyFileOverride");

    // Should be overridden by framework
    customResponseParams.addHTTPHeaderParameter(
        ResponseHeaderConstants.HDR_DATE_TIME, "ignore this date/time");

    if (pagingInfo == null) {
      throw new DataTooLargeException(
          "No paging info is provided. Please provide navigationPage and navigationPageSize.");
    } else {
      // We may want to set the navigationID! Here we set it as a GUID but only if we are on the
      // first page because it is expected that in subsequent
      // paged calls that the consumer would provide that id.
      if (pagingInfo.getCurrentPageNo() == CommonConstants.FIRST_PAGE) {
        //    	        pagingInfo.setNavigationId(UUIDGenerator.getUUID());
      }
    }

    ArrayList<StudentPersonalType> studentList = fetchStudents(students, pagingInfo);

    StudentPersonalCollectionType studentCollection =
        dmObjectFactory.createStudentPersonalCollectionType();

    if (studentList != null) {
      studentCollection.getStudentPersonal().addAll(studentList);
      return studentCollection;
    } else {
      return null;
    }
  }