Changeset 281 for ether_megapoli/trunk/service/implementation/com/medias/megapoli/struts/actions/PrepareTreeAction.java
- Timestamp:
- 12/02/11 17:03:30 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_megapoli/trunk/service/implementation/com/medias/megapoli/struts/actions/PrepareTreeAction.java
r151 r281 1 1 package com.medias.megapoli.struts.actions; 2 2 3 import javax.servlet.ServletException;4 import javax.servlet.http.HttpServletRequest;5 import javax.servlet.http.HttpServletResponse;6 3 import com.ether.user.UserRole; 4 import com.medias.annuaire.Personne; 5 import com.medias.megapoli.struts.forms.PrepareTreeForm; 6 import com.medias.xml.hierarchie.Hierarchie; 7 7 import org.apache.struts.action.Action; 8 8 import org.apache.struts.action.ActionError; … … 11 11 import org.apache.struts.action.ActionForward; 12 12 import org.apache.struts.action.ActionMapping; 13 import com.medias.annuaire.Personne; 14 import com.medias.xml.hierarchie.Hierarchie; 15 import com.medias.megapoli.struts.forms.PrepareTreeForm; 13 14 import javax.servlet.ServletException; 15 import javax.servlet.http.HttpServletRequest; 16 import javax.servlet.http.HttpServletResponse; 16 17 17 18 18 19 /** 19 20 * @author combaz 20 * 21 * Created on 24 févr. 200521 * <p/> 22 * Created on 24 févr. 2005 22 23 */ 23 public class PrepareTreeAction extends Action { 24 public ActionForward execute (ActionMapping mapping, 25 ActionForm form, 26 HttpServletRequest request, 27 HttpServletResponse response) 28 throws ServletException { 29 30 String target = "failure"; 31 ActionErrors errors = new ActionErrors (); 32 String path = (String)request.getSession ().getServletContext ().getAttribute ("DataDescPathName"); 33 Hierarchie arborescence; 24 public class PrepareTreeAction 25 extends Action 26 { 27 public ActionForward execute( ActionMapping mapping, 28 ActionForm form, 29 HttpServletRequest request, 30 HttpServletResponse response ) 31 throws ServletException 32 { 33 34 String target = "failure"; 35 ActionErrors errors = new ActionErrors(); 36 String path = (String) request.getSession().getServletContext().getAttribute( "DataDescPathName" ); 37 Hierarchie arborescence; 34 38 // Hierarchie tree = (Hierarchie)request.getSession ().getServletContext ().getAttribute ("APP_UPLOADTREE"); 35 36 if (form != null) { 37 PrepareTreeForm pTreeForm = (PrepareTreeForm)form; 38 try { 39 // On charge la métadonnée... 40 if (path != null) { 41 arborescence = new Hierarchie(path); 42 pTreeForm.setHierarchie (arborescence); 43 // On vérifie les droits de l'utilisateur sur la métadonnée 44 Personne user = (Personne) request.getSession ().getAttribute ("SES_USER"); 45 if (user == null) { 46 target = "login"; 47 } else { 48 String rights = "read"; 49 if ((user.getRoles ().equals ("coordinateur"))) 50 rights = "write"; 51 request.getSession ().setAttribute ("SES_RIGHTS", rights); 52 // tree.createTreeView (); 53 target = "success"; 54 } 55 } else { 56 throw new Exception ("Chemin vers le fichier de description de hierarchie xml introuvable"); 57 } 58 } 59 catch (Exception e) { 60 System.out.println ("exception_PrepareTreeAction"); 61 errors.add (ActionErrors.GLOBAL_MESSAGE, new ActionError ("errors.upload.prepareTree.failed")); 62 e.printStackTrace (); 63 } 64 } 65 66 if (!errors.isEmpty ()){ 67 saveErrors (request, errors); 68 } 69 70 return mapping.findForward (target); 71 } 72 39 40 if( form != null ) 41 { 42 PrepareTreeForm pTreeForm = (PrepareTreeForm) form; 43 try 44 { 45 // On charge la métadonnée... 46 if( path != null ) 47 { 48 arborescence = new Hierarchie( path ); 49 pTreeForm.setHierarchie( arborescence ); 50 // On vérifie les droits de l'utilisateur sur la métadonnée 51 Personne user = (Personne) request.getSession().getAttribute( "SES_USER" ); 52 if( user == null ) 53 { 54 target = "login"; 55 } 56 else 57 { 58 String rights = "read"; 59 if( ( user.getRoles().equals( UserRole.COORDINATOR.name() ) ) ) 60 rights = "write"; 61 request.getSession().setAttribute( "SES_RIGHTS", rights ); 62 // tree.createTreeView (); 63 target = "success"; 64 } 65 } 66 else 67 { 68 throw new Exception( "Chemin vers le fichier de description de hierarchie xml introuvable" ); 69 } 70 } 71 catch( Exception e ) 72 { 73 System.out.println( "exception_PrepareTreeAction" ); 74 errors.add( ActionErrors.GLOBAL_MESSAGE, new ActionError( "errors.upload.prepareTree.failed" ) ); 75 e.printStackTrace(); 76 } 77 } 78 79 if( !errors.isEmpty() ) 80 { 81 saveErrors( request, errors ); 82 } 83 84 return mapping.findForward( target ); 85 } 86 73 87 }
Note: See TracChangeset
for help on using the changeset viewer.