private ApsProperties extractParametersFromShowlet( ApiMethodRelatedShowlet relatedShowlet, Showlet masterShowlet) { ApsProperties showletProperties = (masterShowlet.getType().isLogic()) ? masterShowlet.getType().getConfig() : masterShowlet.getConfig(); return this.extractParametersFromShowletProperties(relatedShowlet, showletProperties); }
@Override public String copyFromShowlet() { try { String check = this.checkMasterMethod(this.getApiMethodName()); if (null != check) return check; ApiMethod masterMethod = this.getApiCatalogManager().getMethod(this.getApiMethodName()); IPage page = this.getPageManager().getPage(this.getPageCode()); if (null == page) { this.addFieldError( "pageCode", this.getText("error.service.paste.invalidPageCode", new String[] {this.getPageCode()})); return INPUT; } Showlet[] showlets = page.getShowlets(); if (null == this.getFramePos() || this.getFramePos() > showlets.length || null == showlets[this.getFramePos()]) { String framePosString = (null != this.getFramePos()) ? this.getFramePos().toString() : "null"; this.addFieldError( "framePos", this.getText( "error.service.paste.invalidFramePos", new String[] {this.getPageCode(), framePosString})); return INPUT; } Showlet masterShowlet = showlets[this.getFramePos()]; ShowletType type = (masterShowlet.getType().isLogic()) ? masterShowlet.getType().getParentType() : masterShowlet.getType(); if (null == masterMethod.getRelatedShowlet() || !masterMethod.getRelatedShowlet().getShowletCode().equals(type.getCode())) { this.addFieldError( "framePos", this.getText( "error.service.paste.invalidShowlet", new String[] {masterShowlet.getType().getCode(), masterMethod.getMethodName()})); return INPUT; } ApsProperties parameters = this.extractParametersFromShowlet(masterMethod.getRelatedShowlet(), masterShowlet); this.setApiParameterValues(parameters); this.setApiParameters(masterMethod.getParameters()); this.setStrutsAction(ApsAdminSystemConstants.PASTE); this.setServiceKey(this.buildTempKey(masterMethod.getMethodName())); } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "copyFromShowlet"); return FAILURE; } return SUCCESS; }
public void testPasteNewShowletType_2() throws Throwable { String showletTypeCode = "randomShowletCode_2"; String pageDest = "pagina_1"; int frameDest = 1; Showlet temp = this._pageManager.getPage("pagina_11").getShowlets()[2]; assertNotNull(temp); assertEquals("content_viewer", temp.getType().getCode()); IPage page = this._pageManager.getPage(pageDest); try { assertNull(page.getShowlets()[frameDest]); page.getShowlets()[frameDest] = temp; this._pageManager.updatePage(page); this.setUserOnSession("admin"); this.initAction("/do/Portal/ShowletType", "save"); this.addParameter("showletTypeCode", showletTypeCode); this.addParameter("englishTitle", "en"); this.addParameter("italianTitle", "it"); this.addParameter("pageCode", pageDest); this.addParameter("framePos", frameDest); this.addParameter("strutsAction", ApsAdminSystemConstants.PASTE); this.addParameter("replaceOnPage", "true"); String result = this.executeAction(); assertEquals("replaceOnPage", result); Showlet newShowlet = this._pageManager.getPage(pageDest).getShowlets()[frameDest]; assertNotNull(newShowlet); assertNotNull(newShowlet.getConfig()); ShowletType addedType = this._showletTypeManager.getShowletType(showletTypeCode); assertNotNull(addedType); assertEquals(newShowlet.getType().getCode(), addedType.getCode()); ApsProperties config = addedType.getConfig(); Iterator<Object> keysIter = config.keySet().iterator(); while (keysIter.hasNext()) { String key = (String) keysIter.next(); assertEquals(newShowlet.getConfig().getProperty(key), config.getProperty(key)); } } catch (Throwable t) { throw t; } finally { page.getShowlets()[frameDest] = null; this._pageManager.updatePage(page); this._showletTypeManager.deleteShowletType(showletTypeCode); } }