List of usage examples for com.liferay.portal.kernel.util StringPool COMMA_AND_SPACE
String COMMA_AND_SPACE
To view the source code for com.liferay.portal.kernel.util StringPool COMMA_AND_SPACE.
Click Source Link
From source file:com.liferay.faces.demos.bean.DocUploadBackingBean.java
License:Open Source License
public String uploadSingleAttachments(UploadedFileWrapper fileToUpload) { boolean success = true; FacesContext facesContext = FacesContext.getCurrentInstance(); Locale locale = facesContext.getViewRoot().getLocale(); if (locale == null) { locale = Locale.getDefault(); }/* w w w . j a v a 2s . c om*/ ArrayList<UploadedFileWrapper> uploadedFiles = new ArrayList<UploadedFileWrapper>(); uploadedFiles.add(fileToUpload); DLFolder dlFolder = docLibModelBean.getSelectedNodeDlFolder(); try { for (UploadedFileWrapper uploadedFile : uploadedFiles) { // DLFolder dlFolder = folderUserObject.getDlFolder(); String name = stripInvalidFileNameCharacters(uploadedFile.getName()); String title = name; String description = null; String changeLog = null; File file = new File(uploadedFile.getAbsolutePath()); ServiceContext serviceContext = new ServiceContext(); // Temporary: Make the default setting be that community members can view the file. Need to develop a // "Viewable By" permissions Facelet composite component UI similar to // portal-web/docroot/html/taglib/ui/input_permissions/page.jsp serviceContext.setAddGroupPermissions(true); try { long fileEntryTypeId = DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT; Map<String, Fields> fieldsMap = new HashMap<String, Fields>(); FileInputStream inputStream = new FileInputStream(file); DLFileEntryServiceUtil.addFileEntry(dlFolder.getGroupId(), dlFolder.getRepositoryId(), dlFolder.getFolderId(), name, uploadedFile.getContentType(), title, description, changeLog, fileEntryTypeId, fieldsMap, file, inputStream, file.length(), serviceContext); inputStream.close(); file.delete(); } catch (DuplicateFileException e) { success = false; liferayFacesContext.addGlobalErrorMessage("please-enter-a-unique-document-name"); } catch (FileNameException e) { success = false; String extensions = StringUtil.merge( PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA), StringPool.COMMA_AND_SPACE); String message = liferayFacesContext .getMessage("document-names-must-end-with-one-of-the-following-extensions"); message = message + extensions; liferayFacesContext.addGlobalErrorMessage(message); } catch (FileSizeException e) { success = false; String message = liferayFacesContext.getMessage("please-enter-a-file-with-a-valid-file-size"); message = message + " (" + getMaxFileSizeKB() + "k max)"; liferayFacesContext.addGlobalErrorMessage(message); } catch (SourceFileNameException e) { success = false; liferayFacesContext.addGlobalErrorMessage( "the-source-file-does-not-have-the-same-extension-as-the-original-file"); } } } catch (Exception e) { success = false; logger.error(e.getMessage(), e); liferayFacesContext.addGlobalUnexpectedErrorMessage(); } docLibModelBean.forceDocumentRequery(); String nextPage = success ? "/views/portletViewMode.xhtml" : "error.xhtml"; return nextPage; }
From source file:com.liferay.google.apps.connector.GHelperUtil.java
License:Open Source License
public static String getErrorMessage(Document document) { Element rootElement = document.getRootElement(); Element errorElement = rootElement.element("error"); List<Attribute> attributes = errorElement.attributes(); StringBundler sb = new StringBundler(attributes.size() * 4 + 1); sb.append(StringPool.OPEN_CURLY_BRACE); for (int i = 0; i < attributes.size(); i++) { Attribute attribute = attributes.get(i); sb.append(attribute.getName());/*from w w w . j a v a 2 s . c o m*/ sb.append(StringPool.EQUAL); sb.append(attribute.getValue()); if ((i + 1) <= attributes.size()) { sb.append(StringPool.COMMA_AND_SPACE); } } sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.liferay.privatemessaging.portlet.PrivateMessagingPortlet.java
License:Open Source License
protected String getMessage(PortletRequest portletRequest, Exception key) throws Exception { String message = null;/*w w w. j a va 2 s .c o m*/ if (key instanceof FileExtensionException) { message = translate(portletRequest, "document-names-must-end-with-one-of-the-following-extensions"); message += CharPool.SPACE + StringUtil.merge( PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA), StringPool.COMMA_AND_SPACE); } else if (key instanceof FileNameException) { message = translate(portletRequest, "please-enter-a-file-with-a-valid-file-name"); } else if (key instanceof FileSizeException) { long fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE); if (fileMaxSize == 0) { fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE); } fileMaxSize /= 1024; message = translate(portletRequest, "please-enter-a-file-with-a-valid-file-size-no-larger-than-x", fileMaxSize); } else if (key instanceof UserScreenNameException) { message = translate(portletRequest, "the-following-users-were-not-found"); message += CharPool.SPACE + key.getMessage(); } else { message = translate(portletRequest, "your-request-failed-to-complete"); } return message; }
From source file:com.liferay.sync.util.SyncUtil.java
License:Open Source License
public static String buildExceptionMessage(Throwable throwable) { // SYNC-1253// w w w. j a va 2s . co m StringBundler sb = new StringBundler(13); if (throwable instanceof InvocationTargetException) { throwable = throwable.getCause(); } String throwableMessage = throwable.getMessage(); if (Validator.isNull(throwableMessage)) { throwableMessage = throwable.toString(); } sb.append(StringPool.QUOTE); sb.append(throwableMessage); sb.append(StringPool.QUOTE); sb.append(StringPool.COMMA_AND_SPACE); sb.append("\"error\": "); JSONObject errorJSONObject = JSONFactoryUtil.createJSONObject(); errorJSONObject.put("message", throwableMessage); errorJSONObject.put("type", ClassUtil.getClassName(throwable)); sb.append(errorJSONObject.toString()); sb.append(StringPool.COMMA_AND_SPACE); sb.append("\"throwable\": \""); sb.append(throwable.toString()); sb.append(StringPool.QUOTE); if (throwable.getCause() == null) { return StringUtil.unquote(sb.toString()); } sb.append(StringPool.COMMA_AND_SPACE); sb.append("\"rootCause\": "); Throwable rootCauseThrowable = throwable; while (rootCauseThrowable.getCause() != null) { rootCauseThrowable = rootCauseThrowable.getCause(); } JSONObject rootCauseJSONObject = JSONFactoryUtil.createJSONObject(); throwableMessage = rootCauseThrowable.getMessage(); if (Validator.isNull(throwableMessage)) { throwableMessage = rootCauseThrowable.toString(); } rootCauseJSONObject.put("message", throwableMessage); rootCauseJSONObject.put("type", ClassUtil.getClassName(rootCauseThrowable)); sb.append(rootCauseJSONObject); return StringUtil.unquote(sb.toString()); }
From source file:com.liferay.taglib.aui.ScriptTag.java
License:Open Source License
protected void processEndTag(ScriptData scriptData) throws Exception { JspWriter jspWriter = pageContext.getOut(); jspWriter.write("<script type=\"text/javascript\">\n// <![CDATA[\n"); StringBundler rawSB = scriptData.getRawSB(); rawSB.writeTo(jspWriter);/*from w w w .ja va2 s . c o m*/ StringBundler callbackSB = scriptData.getCallbackSB(); if (callbackSB.index() > 0) { String loadMethod = "use"; HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); if (BrowserSnifferUtil.isIe(request) && (BrowserSnifferUtil.getMajorVersion(request) < 8)) { loadMethod = "ready"; } jspWriter.write("AUI()."); jspWriter.write(loadMethod); jspWriter.write("("); Set<String> useSet = scriptData.getUseSet(); for (String use : useSet) { jspWriter.write(StringPool.APOSTROPHE); jspWriter.write(use); jspWriter.write(StringPool.APOSTROPHE); jspWriter.write(StringPool.COMMA_AND_SPACE); } jspWriter.write("function(A) {"); callbackSB.writeTo(jspWriter); jspWriter.write("});"); } jspWriter.write("\n// ]]>\n</script>"); }
From source file:org.apache.jsp.html.taglib.aui.script.page_jsp.java
License:Open Source License
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null;//from ww w . j a v a2 s . co m HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * 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 version 2.1 of the License, or (at your option) * any later version. * * This library 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 Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * 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 version 2.1 of the License, or (at your option) * any later version. * * This library 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 Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * 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 version 2.1 of the License, or (at your option) * any later version. * * This library 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 Lesser General Public License for more * details. */ out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); // liferay-theme:defineObjects com.liferay.taglib.theme.DefineObjectsTag _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 = (com.liferay.taglib.theme.DefineObjectsTag) _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .get(com.liferay.taglib.theme.DefineObjectsTag.class); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setPageContext(_jspx_page_context); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setParent(null); int _jspx_eval_liferay_002dtheme_005fdefineObjects_005f0 = _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doStartTag(); if (_jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); return; } _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); com.liferay.portal.theme.ThemeDisplay themeDisplay = null; com.liferay.portal.model.Company company = null; com.liferay.portal.model.Account account = null; com.liferay.portal.model.User user = null; com.liferay.portal.model.User realUser = null; com.liferay.portal.model.Contact contact = null; com.liferay.portal.model.Layout layout = null; java.util.List layouts = null; java.lang.Long plid = null; com.liferay.portal.model.LayoutTypePortlet layoutTypePortlet = null; java.lang.Long scopeGroupId = null; com.liferay.portal.security.permission.PermissionChecker permissionChecker = null; java.util.Locale locale = null; java.util.TimeZone timeZone = null; com.liferay.portal.model.Theme theme = null; com.liferay.portal.model.ColorScheme colorScheme = null; com.liferay.portal.theme.PortletDisplay portletDisplay = null; java.lang.Long portletGroupId = null; themeDisplay = (com.liferay.portal.theme.ThemeDisplay) _jspx_page_context.findAttribute("themeDisplay"); company = (com.liferay.portal.model.Company) _jspx_page_context.findAttribute("company"); account = (com.liferay.portal.model.Account) _jspx_page_context.findAttribute("account"); user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user"); realUser = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("realUser"); contact = (com.liferay.portal.model.Contact) _jspx_page_context.findAttribute("contact"); layout = (com.liferay.portal.model.Layout) _jspx_page_context.findAttribute("layout"); layouts = (java.util.List) _jspx_page_context.findAttribute("layouts"); plid = (java.lang.Long) _jspx_page_context.findAttribute("plid"); layoutTypePortlet = (com.liferay.portal.model.LayoutTypePortlet) _jspx_page_context .findAttribute("layoutTypePortlet"); scopeGroupId = (java.lang.Long) _jspx_page_context.findAttribute("scopeGroupId"); permissionChecker = (com.liferay.portal.security.permission.PermissionChecker) _jspx_page_context .findAttribute("permissionChecker"); locale = (java.util.Locale) _jspx_page_context.findAttribute("locale"); timeZone = (java.util.TimeZone) _jspx_page_context.findAttribute("timeZone"); theme = (com.liferay.portal.model.Theme) _jspx_page_context.findAttribute("theme"); colorScheme = (com.liferay.portal.model.ColorScheme) _jspx_page_context.findAttribute("colorScheme"); portletDisplay = (com.liferay.portal.theme.PortletDisplay) _jspx_page_context .findAttribute("portletDisplay"); portletGroupId = (java.lang.Long) _jspx_page_context.findAttribute("portletGroupId"); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * 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 version 2.1 of the License, or (at your option) * any later version. * * This library 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 Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); PortletRequest portletRequest = (PortletRequest) request .getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); PortletResponse portletResponse = (PortletResponse) request .getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE); String namespace = StringPool.BLANK; boolean useNamespace = GetterUtil.getBoolean((String) request.getAttribute("aui:form:useNamespace"), true); if ((portletResponse != null) && useNamespace) { namespace = portletResponse.getNamespace(); } String currentURL = PortalUtil.getCurrentURL(request); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * 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 version 2.1 of the License, or (at your option) * any later version. * * This library 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 Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); ScriptData scriptData = (ScriptData) request.getAttribute(ScriptTag.class.getName()); if (scriptData == null) { scriptData = (ScriptData) request.getAttribute(WebKeys.AUI_SCRIPT_DATA); if (scriptData != null) { request.removeAttribute(WebKeys.AUI_SCRIPT_DATA); } } out.write('\n'); out.write('\n'); // c:if org.apache.taglibs.standard.tag.rt.core.IfTag _jspx_th_c_005fif_005f0 = (org.apache.taglibs.standard.tag.rt.core.IfTag) _005fjspx_005ftagPool_005fc_005fif_0026_005ftest .get(org.apache.taglibs.standard.tag.rt.core.IfTag.class); _jspx_th_c_005fif_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fif_005f0.setParent(null); // /html/taglib/aui/script/page.jsp(34,0) name = test type = boolean reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fif_005f0.setTest(scriptData != null); int _jspx_eval_c_005fif_005f0 = _jspx_th_c_005fif_005f0.doStartTag(); if (_jspx_eval_c_005fif_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\n"); out.write("\t<script type=\"text/javascript\">\n"); out.write("\t\t// <![CDATA[\n"); out.write("\n"); out.write("\t\t\t"); StringBundler rawSB = scriptData.getRawSB(); rawSB.writeTo(out); StringBundler callbackSB = scriptData.getCallbackSB(); out.write("\n"); out.write("\n"); out.write("\t\t\t"); // c:if org.apache.taglibs.standard.tag.rt.core.IfTag _jspx_th_c_005fif_005f1 = (org.apache.taglibs.standard.tag.rt.core.IfTag) _005fjspx_005ftagPool_005fc_005fif_0026_005ftest .get(org.apache.taglibs.standard.tag.rt.core.IfTag.class); _jspx_th_c_005fif_005f1.setPageContext(_jspx_page_context); _jspx_th_c_005fif_005f1.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_c_005fif_005f0); // /html/taglib/aui/script/page.jsp(46,3) name = test type = boolean reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fif_005f1.setTest(callbackSB.index() > 0); int _jspx_eval_c_005fif_005f1 = _jspx_th_c_005fif_005f1.doStartTag(); if (_jspx_eval_c_005fif_005f1 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\n"); out.write("\n"); out.write("\t\t\t\t"); Set<String> useSet = scriptData.getUseSet(); StringBundler useSB = new StringBundler(useSet.size() * 4); for (String use : useSet) { useSB.append(StringPool.APOSTROPHE); useSB.append(use); useSB.append(StringPool.APOSTROPHE); useSB.append(StringPool.COMMA_AND_SPACE); } out.write("\n"); out.write("\n"); out.write("\t\t\t\tAUI().use(\n"); out.write("\n"); out.write("\t\t\t\t\t"); useSB.writeTo(out); out.write("\n"); out.write("\n"); out.write("\t\t\t\t\tfunction(A) {\n"); out.write("\n"); out.write("\t\t\t\t\t\t"); callbackSB.writeTo(out); out.write("\n"); out.write("\n"); out.write("\t\t\t\t\t}\n"); out.write("\t\t\t\t);\n"); out.write("\t\t\t"); int evalDoAfterBody = _jspx_th_c_005fif_005f1.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_c_005fif_005f1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f1); return; } _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f1); out.write("\n"); out.write("\t\t// ]]>\n"); out.write("\t</script>\n"); int evalDoAfterBody = _jspx_th_c_005fif_005f0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_c_005fif_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0); return; } _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
From source file:org.gfbio.ContactFormToHelpdeskPortlet.java
License:Open Source License
protected boolean validateChallenge(HttpServletRequest request) throws CaptchaException { String reCaptchaResponse = ParamUtil.getString(request, "g-recaptcha-response"); //_log.info("validate Challenge response"+reCaptchaResponse); Http.Options options = new Http.Options(); try {/* www. ja va 2 s .co m*/ options.addPart("secret", PropsUtil.get("google.secretkey")); } catch (Exception se) { _log.error(se, se); } options.addPart("remoteip", request.getRemoteAddr()); options.addPart("response", reCaptchaResponse); options.setLocation(PropsUtil.get("google.urlverify")); options.setPost(true); String content = null; try { content = HttpUtil.URLtoString(options); //_log.info("Content :"+content); } catch (IOException ioe) { _log.error(ioe, ioe); throw new CaptchaTextException(); } if (content == null) { _log.error("reCAPTCHA did not return a result"); throw new CaptchaTextException(); } try { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(content); String success = jsonObject.getString("success"); if (StringUtil.equalsIgnoreCase(success, "true")) { return true; } JSONArray jsonArray = jsonObject.getJSONArray("error-codes"); if ((jsonArray == null) || (jsonArray.length() == 0)) { return false; } StringBundler sb = new StringBundler(jsonArray.length() * 2 - 1); for (int i = 0; i < jsonArray.length(); i++) { sb.append(jsonArray.getString(i)); if (i < (jsonArray.length() - 1)) { sb.append(StringPool.COMMA_AND_SPACE); } } _log.error("reCAPTCHA encountered an error: " + sb.toString()); return false; } catch (JSONException jsone) { _log.error("reCAPTCHA did not return a valid result: " + content); throw new CaptchaTextException(); } }