/** * loads a context defined by its absolut path passed in URL encoded parameter 'FILENAME' * * @throws PortalException */ void doLoadwmc(User user) throws PortalException { String filename = null; try { filename = URLDecoder.decode(parameter.get("FILENAME"), CharsetUtils.getSystemCharset()); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } File file = new File(filename); String cntxid = file.getName(); PortletSet ps = portlet.getPortletConfig().getPortletSet(); String mapid = ps.getPortletByName("iGeoPortal:MapActionPortlet").getID(); Portlet port = ps.getPortletByID(mapid); port.getPortletConfig().setInitParameter(INIT_WMC, cntxid); String mwinid = getInitParam(INIT_MAPPORTLETID); port = ps.getPortletByID(mwinid); port.getPortletConfig().setInitParameter(INIT_WMC, cntxid); request.setAttribute(PARAM_MAPPORTLET, mwinid); ViewContext vc = null; try { vc = WebMapContextFactory.createViewContext(file.toURI().toURL(), user, null); } catch (Exception e) { LOG.logError(e.getMessage(), e); return; } setCurrentMapContext(vc, getInitParam(INIT_MAPPORTLETID)); setCurrentMapContextName(getInitParam(INIT_MAPPORTLETID), cntxid); }
/** * selects the current context of a MapWindowPortlet * * @throws PortalException */ void doSelectwmc() throws PortalException { String cntxid = parameter.get("WMCID"); PortletSet ps = portlet.getPortletConfig().getPortletSet(); String mapid = ps.getPortletByName("iGeoPortal:MapActionPortlet").getID(); Portlet port = ps.getPortletByID(mapid); port.getPortletConfig().setInitParameter(INIT_WMC, cntxid); String mwinid = getInitParam(INIT_MAPPORTLETID); port = ps.getPortletByID(mwinid); port.getPortletConfig().setInitParameter(INIT_WMC, cntxid); request.setAttribute(PARAM_MAPPORTLET, mwinid); ViewContext vc = null; if ("true".equals(getInitParam(INIT_KEEP_BBOX))) { // get old current context to read its bounding box vc = getCurrentViewContext(parameter.get("MAPPORTLET")); Point[] currentEnv = vc.getGeneral().getBoundingBox(); // get new current context to set its bounding box with value of the // old current context bounding box to keep viewing area vc = getNamedViewContext(cntxid); try { vc.getGeneral().setBoundingBox(currentEnv); } catch (ContextException e) { LOG.logError(e.getMessage(), e); throw new PortalException(e.getMessage(), e); } } else { vc = getNamedViewContext(cntxid); } setCurrentMapContext(vc, getInitParam(INIT_MAPPORTLETID)); setCurrentMapContextName(getInitParam(INIT_MAPPORTLETID), cntxid); }