1 package org.nextime.ion.backoffice.action.content; 2 3 4 import java.io.IOException ; 5 import java.util.Vector ; 6 7 import javax.servlet.ServletException ; 8 import javax.servlet.http.HttpServletRequest ; 9 import javax.servlet.http.HttpServletResponse ; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionForward; 12 import org.apache.struts.action.ActionMapping; 13 import org.nextime.ion.backoffice.action.BaseAction; 14 15 import org.nextime.ion.framework.business.Publication; 16 import org.nextime.ion.framework.business.TypePublication; 17 import org.nextime.ion.framework.business.impl.Style; 18 import org.nextime.ion.framework.business.impl.TypePublicationImpl; 19 import org.nextime.ion.framework.helper.Viewer; 20 import org.nextime.ion.framework.locale.Locale; 21 import org.nextime.ion.framework.locale.LocaleList; 22 import org.nextime.ion.framework.mapping.Mapping; 23 24 25 26 public class PreviewPublicationAction extends BaseAction { 27 28 public ActionForward perform(ActionMapping mapping, 29 ActionForm form, 30 HttpServletRequest request, 31 HttpServletResponse response) 32 throws IOException , ServletException { 33 34 checkUser(request); 36 37 request.setAttribute("locales", LocaleList.getInstance().getLocales() ); 39 40 String id = request.getParameter("id"); 41 int version = Integer.parseInt(request.getParameter("version")); 42 String style = request.getParameter("style"); 43 String locale = request.getParameter("locale"); 44 45 try { 46 Mapping.begin(); 47 48 Publication publication = Publication.getInstance(id); 49 TypePublication type = publication.getType(); 50 Vector styleNames = type.listStyles(); 52 Vector styles = new Vector (); 53 for( int i=0; i<styleNames.size(); i++ ) { 54 String n = styleNames.get(i).toString(); 55 if(((TypePublicationImpl)type).getStyleSheet(n).getType() == Style.XSL && !n.startsWith("indexation") && !n.startsWith("special")) { 56 styles.add(n); 57 } 58 } 59 request.setAttribute("styles",styles); 60 61 if( style == null ) style=styles.get(0)+""; 62 if( locale == null ) locale=((Locale)LocaleList.getInstance().getLocales().iterator().next()).getLocale(); 63 64 String view = new String (Viewer.getView(publication, version, style, locale)); 65 request.setAttribute("view",view); 66 67 Mapping.rollback(); 68 } catch( Exception e ) { 69 Mapping.rollback(); 70 throw new ServletException (e); 71 } 72 73 return (mapping.findForward("view")); 75 76 } 77 78 } 79 | Popular Tags |