/** * Performs the exit editor action.<p> * * @see org.opencms.workplace.editors.CmsEditor#actionExit() */ @Override public void actionExit() throws IOException, JspException, ServletException { if (getAction() == ACTION_CANCEL) { // save and exit was canceled return; } // unlock resource, if no modified actionClear(false); // close the editor actionClose(); }
/** * Decodes the content from the content request parameter.<p> * * @param encodedContent the encoded content * @param encoding the encoding to use * @param originalFile the current file state * * @return the decoded content */ protected String decodeContentParameter(String encodedContent, String encoding, CmsFile originalFile) { return decodeContent(encodedContent); }
fillParamValues(request); setParamDialogtype(EDITOR_TYPE); if (EDITOR_SAVE.equals(getParamAction())) { setAction(ACTION_SAVE); } else if (EDITOR_SAVEEXIT.equals(getParamAction())) { setAction(ACTION_SAVEEXIT); } else if (EDITOR_EXIT.equals(getParamAction())) { setAction(ACTION_EXIT); } else if (EDITOR_SHOW.equals(getParamAction())) { setAction(ACTION_SHOW); } else if (EDITOR_SHOW_ERRORMESSAGE.equals(getParamAction())) { setAction(ACTION_SHOW_ERRORMESSAGE); } else { setAction(ACTION_DEFAULT); initContent(); setParamContent(encodeContent(getParamContent()));
editFile = getCms().readFile(getParamResource(), CmsResourceFilter.ALL); String decodedContent = decodeContentParameter(getParamContent(), getFileEncoding(), editFile); try { editFile.setContents(decodedContent.getBytes(getFileEncoding())); } catch (UnsupportedEncodingException e) { throw new CmsException( Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()), e); && (CmsResourceTypeXmlContent.isXmlContent(editFile))) { getCms().getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE); CmsFile writtenFile = getCms().writeFile(editFile); decodedContent = CmsEncoder.createString(writtenFile.getContents(), getFileEncoding()); setParamContent(encodeContent(decodedContent)); setParamModified(Boolean.TRUE.toString()); } catch (CmsException e) { showErrorPage(e); if (getAction() != ACTION_CANCEL) { setAction(ACTION_SAVE);
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); String content = getParamContent(); if (CmsStringUtil.isNotEmpty(content)) { setParamContent(decodeContent(content)); return; } else { checkLock(getParamResource()); CmsFile editFile = getCms().readFile(getParamResource(), CmsResourceFilter.ALL); content = CmsEncoder.createString(editFile.getContents(), getFileEncoding()); } catch (CmsException e) { showErrorPage(this, e); } catch (JspException exc) { setParamContent(content);
/** * @see org.opencms.workplace.editors.CmsEditor#actionClear(boolean) */ @Override public void actionClear(boolean forceUnlock) { boolean modified = Boolean.valueOf(getParamModified()).booleanValue(); if (forceUnlock || !modified) { // unlock the resource when force unlock is true or resource was not modified try { getCms().unlockResource(getParamResource()); } catch (CmsException e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e); } } } }
editFile = getCms().readFile(getParamResource(), CmsResourceFilter.ALL); String decodedContent = CmsEncoder.adjustHtmlEncoding(decodeContent(getParamContent()), getFileEncoding()); editFile.setContents(decodedContent.getBytes(getFileEncoding())); } catch (UnsupportedEncodingException e) { throw new CmsException( Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()), e); && CmsResourceTypeXmlContent.isXmlContent(editFile)) { getCms().getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE); CmsFile writtenFile = getCms().writeFile(editFile); decodedContent = CmsEncoder.createString(writtenFile.getContents(), getFileEncoding()); setParamContent(encodeContent(decodedContent)); setParamModified(Boolean.TRUE.toString()); } catch (CmsException e) { showErrorPage(e); if (getAction() != ACTION_CANCEL) { setAction(ACTION_SAVE);
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); String content = getParamContent(); if (CmsStringUtil.isNotEmpty(content)) { setParamContent(decodeContent(content)); return; } else { checkLock(getParamResource()); CmsFile editFile = getCms().readFile(getParamResource(), CmsResourceFilter.ALL); content = CmsEncoder.createString(editFile.getContents(), getFileEncoding()); } catch (CmsException e) { showErrorPage(this, e); } catch (JspException exc) { setParamContent(content);
/** * @see org.opencms.workplace.editors.CmsEditor#actionClear(boolean) */ @Override public void actionClear(boolean forceUnlock) { boolean modified = Boolean.valueOf(getParamModified()).booleanValue(); if (forceUnlock || !modified) { // unlock the resource when force unlock is true or resource was not modified try { getCms().unlockResource(getParamResource()); } catch (CmsException e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e); } } } }
fillParamValues(request); setParamDialogtype(EDITOR_TYPE); if (EDITOR_SAVE.equals(getParamAction())) { setAction(ACTION_SAVE); } else if (EDITOR_SAVEEXIT.equals(getParamAction())) { setAction(ACTION_SAVEEXIT); } else if (EDITOR_EXIT.equals(getParamAction())) { setAction(ACTION_EXIT); } else if (EDITOR_SHOW.equals(getParamAction())) { setAction(ACTION_SHOW); } else if (EDITOR_SHOW_ERRORMESSAGE.equals(getParamAction())) { setAction(ACTION_SHOW_ERRORMESSAGE); } else { setAction(ACTION_DEFAULT); initContent(); setParamContent(encodeContent(getParamContent()));
/** * Performs the exit editor action.<p> * * @see org.opencms.workplace.editors.CmsEditor#actionExit() */ @Override public void actionExit() throws IOException, JspException, ServletException { if (getAction() == ACTION_CANCEL) { // save and exit was canceled return; } // unlock resource, if no modified actionClear(false); // close the editor actionClose(); }