Commit 1a658afa authored by Yann Mombrun's avatar Yann Mombrun

Merge branch 'develop'

* develop:
  Bump to stable version 2.3.5
  Remove commented code and unused imports
  Implement #5 by adding an offline flag
  Bump to develop version 2.3.5-SNAP
parents b325970b 811682db
Pipeline #4139 passed with stage
in 27 seconds
......@@ -11,7 +11,7 @@
</parent>
<artifactId>weblab-metaview</artifactId>
<version>2.3.4</version>
<version>2.3.5</version>
<packaging>war</packaging>
<name>WebLab Metaview</name>
......
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2017 Airbus Defence and Space
* Copyright (C) 2004 - 2019 AIRBUS Defence and Space SAS
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
......@@ -24,8 +24,6 @@ import java.util.Map;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletRequest;
import javax.portlet.PortletURL;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
......@@ -50,10 +48,6 @@ import org.springframework.web.portlet.bind.annotation.ActionMapping;
import org.springframework.web.portlet.bind.annotation.ResourceMapping;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portlet.PortletURLFactoryUtil;
/**
* The controller in charge of the edition.
......@@ -68,11 +62,11 @@ public class EditMetaController {
private static final String USE_GEOSERVER_EXPOSED_MAP = "useGeoserverExposedMap";
private static final String URL_REDIRECTION = "/web/guest/docview";
private static final String LAYERS_CONFIG = "layersConfig";
......@@ -120,6 +114,7 @@ public class EditMetaController {
public EditMetaController(final EditMetaConfBean editMetaData, final TimeConfig timeConfig, final DataTaglib dataTaglib, final ResourceSaverService resourceSaverService,
final PermissionService permissionService) {
super();
this.editMetaData = editMetaData;
this.timeConfig = timeConfig;
......@@ -127,15 +122,18 @@ public class EditMetaController {
this.resourceSaverService = resourceSaverService;
this.permissionService = permissionService;
}
@ModelAttribute("layersConfig")
public GroupLayerConfig getLayersConfig() {
return this.editMetaData.getLayersConfig();
}
@ResourceMapping("editmeta")
public ModelAndView displayEditMenu(final ResourceRequest request, final ResourceResponse response) {
response.setContentType(EditMetaController.TEXT_HTML);
response.setCharacterEncoding(EditMetaController.UTF_8);
this.logger.debug("ShowView EditMetaController called");
......@@ -168,25 +166,22 @@ public class EditMetaController {
@ResourceMapping("clearErrorAttribute")
public void clearModelAttribute(final ModelMap model) {
model.addAttribute(EditMetaController.EDIT_ERROR, Boolean.FALSE);
}
@ActionMapping(params = "action=cancel")
public void cancelEdit(final ActionRequest actionRequest, final ActionResponse response, final ModelMap model) throws IOException {
this.logger.debug("view redirect after cancel method called");
response.sendRedirect(EditMetaController.URL_REDIRECTION);
// build link to default portlet jsp
//final String portletName = (String) actionRequest.getAttribute(WebKeys.PORTLET_ID);
//final ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
//final PortletURL portletURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest), portletName, themeDisplay.getLayout().getPlid(), PortletRequest.RENDER_PHASE);
//response.sendRedirect(portletURL.toString());
}
@ActionMapping(params = "action=save")
public void saveEdit(final ActionRequest request, final ActionResponse response, final ModelMap model) throws SystemException, IOException {
this.logger.debug("saveEdit method called");
if (!this.permissionService.hasAdminRole(request)) {
......@@ -205,7 +200,7 @@ public class EditMetaController {
final EditMetaServices editMetaServices = new EditMetaServices(editMeta, this.timeConfig);
editMetaServices.writeContent(resource, parameterMap);
try {
boolean worked = this.resourceSaverService.saveResource(resource);
final boolean worked = this.resourceSaverService.saveResource(resource);
if (!worked) {
this.logger.warn("The resource " + resource.getUri() + " may not be saved.");
}
......
......@@ -68,10 +68,19 @@ import com.liferay.portal.kernel.exception.SystemException;
@Controller
@RequestMapping(value = "VIEW")
@SessionAttributes({ "resource", "isEmptyModel", "isLoadedResource", "rdfProperties", "translations", "metaDisplay", "editMetaData", "timeConfig", "dataTaglib", "dataLanguage",
"useGeoserverExposedMap", "layersConfig", "editError" })
"useGeoserverExposedMap", "layersConfig", "editError", "offline" })
public class MetaViewController {
private static final String RESOURCE_DESC = "resourceDesc";
private static final String VIEW = "view";
/**
* Key for the resource field.
*/
protected static final String RESOURCE = "resource";
......@@ -87,6 +96,9 @@ public class MetaViewController {
protected static final String ALLOW_SOURCE_EVENTING = "allowSourceEventing";
private static final String OFFLINE = "offline";
// attributes
protected final Log logger = LogFactory.getLog(this.getClass());
......@@ -109,8 +121,13 @@ public class MetaViewController {
protected final Boolean allowSourceEventing;
protected final Boolean offline;
public MetaViewController(final MetaViewBusinessServices metaviewBusinessService, final PermissionService permissionService, final DisplayMetaConfBean metaDisplayConf,
final RDFPropertiesConfBean rdfProperties, final String sourceTypeTab, final Boolean allowSourceEventing) {
final RDFPropertiesConfBean rdfProperties, final String sourceTypeTab, final Boolean allowSourceEventing, final Boolean offline) {
super();
this.metaviewBusinessService = metaviewBusinessService;
this.permissionService = permissionService;
......@@ -118,28 +135,34 @@ public class MetaViewController {
this.rdfProperties = rdfProperties;
this.sourceTypeTab = sourceTypeTab;
this.allowSourceEventing = allowSourceEventing;
this.offline = offline;
}
@ModelAttribute("metaDisplay")
public Map<String, Boolean> getDisplayMeta() {
return this.metaDisplayConf.getProperties();
}
@ModelAttribute("useGeoserverExposedMap")
public Boolean getUseGeoserverExposedMap() {
return Boolean.valueOf(this.metaDisplayConf.isUseGeoserverExposedMap());
}
@ModelAttribute("layersConfig")
public GroupLayerConfig getLayersConfig() {
return this.metaDisplayConf.getLayersConfig();
}
@ModelAttribute("rdfProperties")
public Map<String, String> getRDFProperties() {
return this.rdfProperties.getProperties();
}
......@@ -149,6 +172,7 @@ public class MetaViewController {
// #############################################################################
@ActionMapping(params = "action=goToEntity")
public void goToEntity(final ActionResponse response, final ModelMap model) {
this.logger.debug("receiving action goToEntity");
response.setEvent(QName.valueOf("{http://weblab.ow2.org/portlet/metaview/action}sendUnloadedDocument"), (PieceOfKnowledge) model.get(MetaViewController.RESOURCE));
}
......@@ -156,6 +180,7 @@ public class MetaViewController {
@ActionMapping(params = "action=selectTranslation")
public void selectTranslation(final ActionRequest request, final ActionResponse response, final ModelMap model) {
final String lang = request.getParameter("language");
final URI service = URI.create(request.getParameter("service"));
this.logger.debug("select translation for language :" + lang + " and service" + service);
......@@ -166,6 +191,7 @@ public class MetaViewController {
@ActionMapping(params = "action=selectOriginalVersion")
public void selectOriginal(final ActionRequest request, final ActionResponse response, final ModelMap model) {
this.logger.debug("select original version");
response.setEvent(QName.valueOf("{http://weblab.ow2.org/portlet/metaview/action}selectOriginalVersion"), ((Resource) model.get(MetaViewController.RESOURCE)).getUri());
}
......@@ -173,6 +199,7 @@ public class MetaViewController {
@ActionMapping(params = "action=useAsSource")
public void useAsSource(final ActionRequest request, final ActionResponse response, final ModelMap model) throws SystemException {
this.logger.info("send event useAsSource");
if (!this.permissionService.hasAdminRole(request)) {
......@@ -180,8 +207,8 @@ public class MetaViewController {
return;
}
if ((this.allowSourceEventing == null) || !this.allowSourceEventing) {
this.logger.warn("The user does not have the authorisation to send an event to the source!");
if ((this.allowSourceEventing == null) || !this.allowSourceEventing.booleanValue()) {
this.logger.warn("The source eventing is deactivated by configuration!");
return;
}
......@@ -189,8 +216,8 @@ public class MetaViewController {
final PieceOfKnowledge pok = this.metaviewBusinessService.getPoKToUseAsSource(doc, this.sourceTypeTab);
response.setEvent(QName.valueOf("{http://weblab.ow2.org/portlet/metaview/action}useAsSource"), pok);
}
/**
* The user add the current document to the basket. An event to share this action is sent to others Portlets.
*
......@@ -201,6 +228,7 @@ public class MetaViewController {
*/
@ActionMapping(params = "action=addToBasketMeta")
public void addToBasket(final ActionResponse response, final ModelMap model) {
response.setEvent(QName.valueOf("{http://weblab.ow2.org/portlet/metaview/action}addToBasket"), (Document) model.get(MetaViewController.RESOURCE));
}
......@@ -215,6 +243,7 @@ public class MetaViewController {
*/
@ActionMapping(params = "action=pinToBasketMeta")
public void pinToBasket(final ActionResponse response, final ModelMap model) {
response.setEvent(QName.valueOf("{http://weblab.ow2.org/portlet/metaview/action}pinToBasket"), (Document) model.get(MetaViewController.RESOURCE));
}
......@@ -224,11 +253,12 @@ public class MetaViewController {
// #############################################################################
@EventMapping(value = "{http://weblab.ow2.org/portlet/metaview/reaction}displayMeta")
public void processLoadedDocumentEvent(final EventRequest request, final EventResponse response, final ModelMap model) {
// receive a event containing a document
this.logger.debug("receiving the event: {http://weblab.ow2.org/portlet/metaview/reaction}displayMeta with value " + request.getEvent());
model.addAttribute(MetaViewController.RESOURCE, request.getEvent().getValue());
model.addAttribute("resourceDesc", new HashMap<String, List<String>>());
model.addAttribute(MetaViewController.RESOURCE_DESC, new HashMap<String, List<String>>());
model.addAttribute(MetaViewController.IS_LOADED_RESOURCE, Boolean.FALSE);
model.addAttribute(MetaViewController.IS_EMPTY_MODEL, Boolean.FALSE);
}
......@@ -236,11 +266,12 @@ public class MetaViewController {
@EventMapping(value = "{http://weblab.ow2.org/portlet/metaview/reaction}loadDocumentAndDisplayMeta")
public void processNotLoadedDocumentEvent(final EventRequest request, final EventResponse response, final ModelMap model) {
// receive a event containing an unloaded document
this.logger.debug("receiving the event : {http://weblab.ow2.org/portlet/metaview/reaction}loadDocumentAndDisplayMeta with value " + request.getEvent());
model.addAttribute(MetaViewController.RESOURCE, request.getEvent().getValue());
model.addAttribute("resourceDesc", new HashMap<String, List<String>>());
model.addAttribute(MetaViewController.RESOURCE_DESC, new HashMap<String, List<String>>());
model.addAttribute(MetaViewController.IS_LOADED_RESOURCE, Boolean.FALSE);
model.addAttribute(MetaViewController.IS_EMPTY_MODEL, Boolean.FALSE);
......@@ -254,6 +285,7 @@ public class MetaViewController {
@ResourceMapping("showMetadata")
public ModelAndView serveMetadata(final ResourceRequest request, final ResourceResponse response, final ModelMap model)
throws ContentNotAvailableException, InvalidParameterException, UnexpectedException, SystemException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
......@@ -273,7 +305,9 @@ public class MetaViewController {
mav.getModelMap().addAttribute(MetaViewController.ALLOW_SOURCE_EVENTING, this.allowSourceEventing);
// check admin permissions for user
mav.getModelMap().addAttribute(MetaViewController.HAS_ADMIN_ROLE, this.permissionService.hasAdminRole(request));
mav.getModelMap().addAttribute(MetaViewController.HAS_ADMIN_ROLE, Boolean.valueOf(this.permissionService.hasAdminRole(request)));
mav.getModelMap().addAttribute(MetaViewController.OFFLINE, this.offline);
// adding map to model
if (!isLoadedDocument) {
......@@ -292,7 +326,8 @@ public class MetaViewController {
// #############################################################################
@RenderMapping()
public ModelAndView showMetadata(final ModelMap model) {
final ModelAndView mav = new ModelAndView("view");
final ModelAndView mav = new ModelAndView(MetaViewController.VIEW);
mav.addAllObjects(model);
if (!model.containsAttribute(MetaViewController.IS_EMPTY_MODEL)) {
this.logger.debug("Is empty model.");
......@@ -307,8 +342,10 @@ public class MetaViewController {
// #############################################################################
@ExceptionHandler(Exception.class)
public ModelAndView getMetadataException(final Exception ex) {
final ModelAndView mav = new ModelAndView("error");
mav.addObject("message_error", ex.getMessage());
return mav;
}
}
......@@ -32,6 +32,7 @@
<constructor-arg name="rdfProperties" type="org.ow2.weblab.portlet.business.bean.RDFPropertiesConfBean" ref="rdfProperties" />
<constructor-arg name="sourceTypeTab" type="java.lang.String" value="website" />
<constructor-arg name="allowSourceEventing" type="java.lang.Boolean" value="false" />
<constructor-arg name="offline" type="java.lang.Boolean" value="false" />
</bean>
<bean id="restSaverService" class="org.ow2.weblab.portlet.business.service.impl.RestResourceSaverService">
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment