Package org.nextime.ion.frontoffice.objectSelector

Source Code of org.nextime.ion.frontoffice.objectSelector.ListOnlinePublications

/*
* �ON content management system.
* Copyright (C) 2002  Guillaume Bort(gbort@msn.com). All rights reserved.
*
* Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
* Copyright 2000-2002 (C) Intalio Inc. All Rights Reserved.
*
* �ON is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* �ON core framework, �ON content server, �ON backoffice, �ON frontoffice
* and �ON admin application are parts of �ON and are distributed under
* same terms of licence.
*
*
* �ON includes software developed by the Apache Software Foundation (http://www.apache.org/)
* and software developed by the Exolab Project (http://www.exolab.org).
*
* �ON is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*/

package org.nextime.ion.frontoffice.objectSelector;

import java.util.Collection;
import java.util.Hashtable;
import java.util.Vector;

import org.nextime.ion.common.IsOnline;

import org.nextime.ion.framework.business.Publication;
import org.nextime.ion.framework.business.Section;
import org.nextime.ion.framework.helper.Viewer;
import org.nextime.ion.framework.logger.Logger;

/**
*/
public class ListOnlinePublications implements ObjectSelector {

  public Collection selectObjects(Hashtable params) throws SelectException {
    try {
      String section = (String) params.get("section");
      String view = (String) params.get("view");
      int max = Integer.parseInt((String) params.get("max"));
      //Mapping.begin();
      Vector v = Section.getInstance(section).listPublications();
      Vector v2 = new Vector();
      int nb = 0;
      for (int i = 0;(i < v.size() && nb < max); i++) {
        Publication p = (Publication) v.get(i);
        if (IsOnline.getStatus(p)) {
          nb++;
          PublicationResult r = new PublicationResult();
          r._publi = p;
          if( view != null ) {
            r._view = new String(Viewer.getView(p, view));
          }
          v2.add(r);
        }
      }
      //Mapping.rollback();
      return v2;
    } catch (Exception e) {
      Logger.getInstance().error("Erreur du SelectObject", this, e);
      throw new SelectException(e.getMessage());
    }
  }

}
TOP

Related Classes of org.nextime.ion.frontoffice.objectSelector.ListOnlinePublications

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.