Author: chatellier Date: 2011-01-12 15:11:27 +0000 (Wed, 12 Jan 2011) New Revision: 503 Log: Download sources action Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java trunk/coser-web/src/main/webapp/WEB-INF/content/source/ trunk/coser-web/src/main/webapp/WEB-INF/content/source/facade.jsp trunk/coser-web/src/main/webapp/WEB-INF/content/source/source.jsp trunk/coser-web/src/main/webapp/WEB-INF/content/source/zone.jsp Modified: trunk/coser-web/src/main/webapp/WEB-INF/content/index.jsp Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java (rev 0) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java 2011-01-12 15:11:27 UTC (rev 503) @@ -0,0 +1,68 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +package fr.ifremer.coser.web.actions.source; + +import java.util.Map; + +import com.opensymphony.xwork2.ActionSupport; + +import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.services.WebService; +import fr.ifremer.coser.web.CoserWebException; +import fr.ifremer.coser.web.ServiceFactory; + +/** + * Action index, affiche la liste des facades majeures. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FacadeAction extends ActionSupport { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3385467755357775199L; + + protected Map<String, String> facades; + + public Map<String, String> getFacades() { + return facades; + } + + @Override + public String execute() { + + WebService webService = ServiceFactory.getWebService(); + try { + // renvoi la liste des facadeid et leur label associé + facades = webService.getFacades(); + + } catch (CoserBusinessException ex) { + throw new CoserWebException("Can't get zone map", ex); + } + + return SUCCESS; + } +} Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java (rev 0) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java 2011-01-12 15:11:27 UTC (rev 503) @@ -0,0 +1,56 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +package fr.ifremer.coser.web.actions.source; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * Affiche les liens de téléchargement du zip pour le projet choisit. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SourceAction extends ActionSupport { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3385467755357775199L; + + protected String zone; + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + @Override + public String execute() { + + return SUCCESS; + } +} Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java (rev 0) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java 2011-01-12 15:11:27 UTC (rev 503) @@ -0,0 +1,93 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +package fr.ifremer.coser.web.actions.source; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Locale; + +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Result; + +import com.opensymphony.xwork2.ActionSupport; + +import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.services.WebService; +import fr.ifremer.coser.web.CoserWebException; +import fr.ifremer.coser.web.ServiceFactory; + +/** + * Force le téléchargement du zip. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SourceDataAction extends ActionSupport { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3385467755357775199L; + + protected String zone; + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + @Action(results= {@Result(type="stream", params={"contentType", "application/zip", "inputName", "inputStream", "contentDisposition", "attachment; filename=\"${filename}\""})}) + public String execute() { + return SUCCESS; + } + + public String getFilename() { + return "source.zip"; + } + + public InputStream getInputStream() { + WebService webService = ServiceFactory.getWebService(); + + Locale locale = getLocale(); + String localeCode = locale.getLanguage(); + + InputStream input = null; + try { + + File sourceZip = webService.getSourceZip(zone, localeCode); + input = new FileInputStream(sourceZip); + } catch (CoserBusinessException ex) { + throw new CoserWebException("Can't get source zip file", ex); + } catch (FileNotFoundException ex) { + throw new CoserWebException("Can't get source zip file", ex); + } + + return input; + } +} Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java (rev 0) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java 2011-01-12 15:11:27 UTC (rev 503) @@ -0,0 +1,76 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +package fr.ifremer.coser.web.actions.source; + +import java.util.Map; + +import com.opensymphony.xwork2.ActionSupport; + +import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.services.WebService; +import fr.ifremer.coser.web.CoserWebException; +import fr.ifremer.coser.web.ServiceFactory; + +/** + * Affiche la liste des sous zones (zone). + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class ZoneAction extends ActionSupport { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3385467755357775199L; + + protected String facade; + + public void setFacade(String facade) { + this.facade = facade; + } + + protected Map<String, String> zones; + + public Map<String, String> getZones() { + return zones; + } + + @Override + public String execute() { + + WebService webService = ServiceFactory.getWebService(); + try { + + // renvoi la liste des id subzone-survey et leurs label + // associé + zones = webService.getZoneForFacade(facade); + + } catch (CoserBusinessException ex) { + throw new CoserWebException("Can't get zone map", ex); + } + + return SUCCESS; + } +} Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/coser-web/src/main/webapp/WEB-INF/content/index.jsp =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/content/index.jsp 2011-01-12 14:58:42 UTC (rev 502) +++ trunk/coser-web/src/main/webapp/WEB-INF/content/index.jsp 2011-01-12 15:11:27 UTC (rev 503) @@ -41,7 +41,7 @@ <p> <span style="font-weight:bold"><s:text name="message.index.datatypetitle" /> :</span><br /> <ul> - <li><s:a action="zone"><s:text name="message.index.datatype1" /></s:a></li> + <li><s:a action="source/facade"><s:text name="message.index.datatype1" /></s:a></li> <li><s:a action="map/facade"><s:text name="message.index.datatype2" /></s:a></li> <li><s:a action="pop/facade"><s:text name="message.index.datatype3" /></s:a></li> <li><s:a action="com/facade"><s:text name="message.index.datatype4" /></s:a></li> Added: trunk/coser-web/src/main/webapp/WEB-INF/content/source/facade.jsp =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/content/source/facade.jsp (rev 0) +++ trunk/coser-web/src/main/webapp/WEB-INF/content/source/facade.jsp 2011-01-12 15:11:27 UTC (rev 503) @@ -0,0 +1,42 @@ +<!-- + #%L + Coser :: Web + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<%@taglib uri="/struts-tags" prefix="s" %> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>Coser</title> + </head> + <body> + + <img src="<s:url value='/images/zonesmap.jpg' />" /> + + <br /> + + <s:form action="zone" method="get"> + <s:select name="facade" list="facades" label="Select a facade" /> + <s:submit label="Suite"/> + </s:form> + </body> +</html> \ No newline at end of file Added: trunk/coser-web/src/main/webapp/WEB-INF/content/source/source.jsp =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/content/source/source.jsp (rev 0) +++ trunk/coser-web/src/main/webapp/WEB-INF/content/source/source.jsp 2011-01-12 15:11:27 UTC (rev 503) @@ -0,0 +1,38 @@ +<!-- + #%L + Coser :: Web + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<%@taglib uri="/struts-tags" prefix="s" %> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>Coser</title> + </head> + <body> + + <s:a action="source-data"> + <s:param name="zone" value="%{zone}" /> + Download + </s:a>. + </body> +</html> \ No newline at end of file Added: trunk/coser-web/src/main/webapp/WEB-INF/content/source/zone.jsp =================================================================== --- trunk/coser-web/src/main/webapp/WEB-INF/content/source/zone.jsp (rev 0) +++ trunk/coser-web/src/main/webapp/WEB-INF/content/source/zone.jsp 2011-01-12 15:11:27 UTC (rev 503) @@ -0,0 +1,47 @@ +<!-- + #%L + Coser :: Web + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<%@taglib uri="/struts-tags" prefix="s" %> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>Coser</title> + </head> + <body> + + <img src="<s:url value='/images/zonesmap.jpg' />" /> + + <br /> + + <s:if test="%{zones.isEmpty()}"> + No result founds + </s:if> + <s:else> + <s:form action="source" method="get"> + <s:select name="zone" list="zones" label="Select a sub zone" /> + <s:submit label="Suite"/> + </s:form> + </s:else> + </body> +</html> \ No newline at end of file