001: /*
002: * Created on 3 mai 2004
003: *
004: * To change the template for this generated file go to
005: * Window>Preferences>Java>Code Generation>Code and Comments
006: */
007: package mc.formgenerator.servlets.bonita;
008:
009: import hero.client.importLdap.SimpleCallbackHandler;
010: import hero.interfaces.UserSessionHome;
011: import hero.interfaces.UserSessionUtil;
012: import hero.util.HeroException;
013: import hero.util.StrutsProjectValue;
014:
015: import java.rmi.RemoteException;
016: import java.util.Collection;
017: import java.util.Iterator;
018: import java.util.Vector;
019:
020: import javax.ejb.CreateException;
021: import javax.naming.NamingException;
022: import javax.security.auth.login.LoginContext;
023: import javax.security.auth.login.LoginException;
024:
025: import hero.interfaces.*;
026:
027: /**
028: * Model for servlet ServletAccueil to give project list to display.
029: *
030: */
031: public class ModeleAccueil {
032:
033: /**
034: * Attribute which stocks the project names
035: */
036: private Collection modelProjectList;
037:
038: /**
039: * Default class constructor
040: */
041: public ModeleAccueil() {
042: }
043:
044: /**
045: * Returns the list of all the projects but without the instances.
046: * @return Colection model projects -> they aren't instances.
047: * @throws LoginException
048: * @throws NamingException
049: * @throws CreateException
050: * @throws RemoteException
051: * @throws HeroException
052: */
053: public Collection getAllModelProjects() throws LoginException,
054: NamingException, CreateException, RemoteException,
055: HeroException {
056:
057: boolean isAnInstance;
058:
059: Vector listeResultat = new Vector();
060: hero.interfaces.AllProjectsSessionLocalHome projecth = (AllProjectsSessionLocalHome) hero.interfaces.AllProjectsSessionUtil
061: .getLocalHome();
062: hero.interfaces.AllProjectsSessionLocal allProject = projecth
063: .create();
064:
065: //Get all the projects : models & instances
066: Collection listeProjets = allProject.getProjects();
067:
068: //listeResultat only owns the model projects
069: Iterator it = listeProjets.iterator();
070: while (it.hasNext()) {
071: //Getting the name of the current project
072: StrutsProjectValue struts = (StrutsProjectValue) it.next();
073: String name = struts.getName();
074:
075: //is this project an instance
076: isAnInstance = name.matches(".*_instance.*");
077: if (!isAnInstance) {
078: listeResultat.addElement(name);
079: }
080: }
081:
082: return listeResultat;
083: }
084:
085: /**
086: * The main method which asks and returns the model projects list.
087: * @throws LoginException
088: * @throws RemoteException
089: * @throws NamingException
090: * @throws CreateException
091: * @throws HeroException
092: */
093: public void process() throws LoginException, RemoteException,
094: NamingException, CreateException, HeroException {
095:
096: Collection list = this .getAllModelProjects();
097:
098: this .setModelProjectList(list);
099: }
100:
101: /**
102: * Set the value of the attribute modelProjectList with the value 'col'.
103: * @param col Collection
104: */
105: public void setModelProjectList(Collection col) {
106:
107: this .modelProjectList = col;
108: }
109:
110: /**
111: * Get the value of the attribute modelProjectList.
112: * @return Collection List of all model projects.
113: */
114: public Collection getModelProjectList() {
115:
116: return this.modelProjectList;
117: }
118:
119: }
|