Ignore:
Timestamp:
12/02/11 17:03:30 (13 years ago)
Author:
vmipsl
Message:

Login

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/service/implementation/com/medias/megapoli/struts/actions/LoadMetadataAction.java

    r151 r281  
    11package com.medias.megapoli.struts.actions; 
    22 
     3import com.ether.user.UserRole; 
    34import com.medias.annuaire.Personne; 
     5import com.medias.megapoli.struts.forms.MetadataForm; 
    46import com.medias.xml.metadata.Metadata; 
    5 import com.medias.megapoli.struts.forms.MetadataForm; 
    6  
    7 import javax.servlet.ServletException; 
    8 import javax.servlet.http.HttpServletRequest; 
    9 import javax.servlet.http.HttpServletResponse; 
    10  
    117import org.apache.struts.action.Action; 
    128import org.apache.struts.action.ActionError; 
     
    1612import org.apache.struts.action.ActionMapping; 
    1713 
     14import javax.servlet.ServletException; 
     15import javax.servlet.http.HttpServletRequest; 
     16import javax.servlet.http.HttpServletResponse; 
     17 
    1818/** 
    1919 * @author combaz 
    20  * Created on 15 févr. 2005 
     20 *         Created on 15 févr. 2005 
    2121 */ 
    22 public class LoadMetadataAction extends Action { 
    23         public ActionForward execute (ActionMapping mapping,ActionForm form, 
    24                                       HttpServletRequest request,  
    25                                       HttpServletResponse response) 
    26                 throws ServletException { 
    27                 String target = "failure"; 
    28                 String path = request.getParameter ("metadataUri"); 
    29                 ActionErrors errors = new ActionErrors (); 
    30          
    31                 if (form != null) { 
    32                         MetadataForm mform = (MetadataForm)form;                 
    33                         if ((path != null) && (path.length () != 0)) { 
    34                                 try { 
    35                                         // On charge la métadonnée... 
    36                                         Metadata meta = new Metadata (path); 
    37                                         mform.setMetadata (meta); 
     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(); 
    3833 
    39                                         // On vérifie les droits de l'utilisateur sur la métadonnée 
    40                                         Personne user = (Personne) request.getSession ().getAttribute ("SES_USER"); 
    41                                         String rights = "read"; 
    42                                         if((user.getRoles ().equals ("coordinateur")) || (user.hasSet (meta.getPres ().getNom ()))) 
    43                                                 rights = "write"; 
    44                                         request.getSession ().setAttribute ("SES_RIGHTS", rights); 
    45                                          
    46                                         target = "success"; 
    47                                 } 
    48                                 catch (Exception e) { 
    49                                         System.out.println ("exception_LoadMetadataAction"); 
    50                                         errors.add (ActionErrors.GLOBAL_MESSAGE, new ActionError ("errors.upload.metadata.notfound")); 
    51                                          
    52                                         e.printStackTrace (); 
    53                                 } 
    54                         } 
    55                 } 
    56                  
    57                 if(!errors.isEmpty ()){ 
    58                         saveErrors (request, errors); 
    59                 } 
    60                  
    61                 return mapping.findForward (target); 
    62         } 
     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    } 
    6371} 
Note: See TracChangeset for help on using the changeset viewer.