source: ether_megapoli/trunk/service/implementation/com/medias/megapoli/struts/actions/PrepareTreeAction.java @ 281

Last change on this file since 281 was 281, checked in by vmipsl, 13 years ago

Login

File size: 3.0 KB
RevLine 
[151]1package com.medias.megapoli.struts.actions;
2
[281]3import com.ether.user.UserRole;
4import com.medias.annuaire.Personne;
5import com.medias.megapoli.struts.forms.PrepareTreeForm;
6import com.medias.xml.hierarchie.Hierarchie;
[151]7import org.apache.struts.action.Action;
8import org.apache.struts.action.ActionError;
9import org.apache.struts.action.ActionErrors;
10import org.apache.struts.action.ActionForm;
11import org.apache.struts.action.ActionForward;
12import org.apache.struts.action.ActionMapping;
13
[281]14import javax.servlet.ServletException;
15import javax.servlet.http.HttpServletRequest;
16import javax.servlet.http.HttpServletResponse;
[151]17
[281]18
[151]19/**
20 * @author combaz
[281]21 *         <p/>
22 *         Created on 24 févr. 2005
[151]23 */
[281]24public 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;
[151]38//              Hierarchie tree = (Hierarchie)request.getSession ().getServletContext ().getAttribute ("APP_UPLOADTREE");
[281]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
[151]87}
Note: See TracBrowser for help on using the repository browser.