source: ether_statistics/service/implementation/com/medias/megapoli/struts/actions/LoadMetadataAction.java @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 2.4 KB
Line 
1package com.medias.megapoli.struts.actions;
2
3import com.ether.user.UserRole;
4import com.medias.annuaire.Personne;
5import com.medias.megapoli.struts.forms.MetadataForm;
6import com.medias.xml.metadata.Metadata;
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
14import javax.servlet.ServletException;
15import javax.servlet.http.HttpServletRequest;
16import javax.servlet.http.HttpServletResponse;
17
18/**
19 * @author combaz
20 *         Created on 15 févr. 2005
21 */
22public class LoadMetadataAction
23        extends Action
24{
25    public ActionForward execute( ActionMapping mapping, ActionForm form,
26                                  HttpServletRequest request,
27                                  HttpServletResponse response )
28            throws ServletException
29    {
30        String target = "failure";
31        String path = request.getParameter( "metadataUri" );
32        ActionErrors errors = new ActionErrors();
33
34        if( form != null )
35        {
36            MetadataForm mform = (MetadataForm) form;
37            if( ( path != null ) && ( path.length() != 0 ) )
38            {
39                try
40                {
41                    // On charge la métadonnée...
42                    Metadata meta = new Metadata( path );
43                    mform.setMetadata( meta );
44
45                    // On vérifie les droits de l'utilisateur sur la métadonnée
46                    Personne user = (Personne) request.getSession().getAttribute( "SES_USER" );
47                    String rights = "read";
48                    if( ( user.getRoles().equals( UserRole.COORDINATOR.name() ) ) || ( user.hasSet( meta.getPres().getNom() ) ) )
49                        rights = "write";
50                    request.getSession().setAttribute( "SES_RIGHTS", rights );
51
52                    target = "success";
53                }
54                catch( Exception e )
55                {
56                    System.out.println( "exception_LoadMetadataAction" );
57                    errors.add( ActionErrors.GLOBAL_MESSAGE, new ActionError( "errors.upload.metadata.notfound" ) );
58
59                    e.printStackTrace();
60                }
61            }
62        }
63
64        if( !errors.isEmpty() )
65        {
66            saveErrors( request, errors );
67        }
68
69        return mapping.findForward( target );
70    }
71}
Note: See TracBrowser for help on using the repository browser.