Changeset 281 for ether_megapoli/trunk/service/implementation/com/medias/megapoli/struts/actions/LoadMetadataAction.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/LoadMetadataAction.java
r151 r281 1 1 package com.medias.megapoli.struts.actions; 2 2 3 import com.ether.user.UserRole; 3 4 import com.medias.annuaire.Personne; 5 import com.medias.megapoli.struts.forms.MetadataForm; 4 6 import 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 11 7 import org.apache.struts.action.Action; 12 8 import org.apache.struts.action.ActionError; … … 16 12 import org.apache.struts.action.ActionMapping; 17 13 14 import javax.servlet.ServletException; 15 import javax.servlet.http.HttpServletRequest; 16 import javax.servlet.http.HttpServletResponse; 17 18 18 /** 19 19 * @author combaz 20 * Created on 15 févr. 200520 * Created on 15 févr. 2005 21 21 */ 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); 22 public 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(); 38 33 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 } 63 71 }
Note: See TracChangeset
for help on using the changeset viewer.