List of usage examples for com.liferay.portal.kernel.util Tuple getObject
public Object getObject(int i)
From source file:com.liferay.blogs.linkback.LinkbackConsumer.java
License:Open Source License
public void verifyNewTrackbacks() { Tuple tuple = null; while (!_trackbacks.isEmpty()) { synchronized (_trackbacks) { tuple = _trackbacks.remove(0); }//from w w w . jav a2 s .com long commentId = (Long) tuple.getObject(0); String url = (String) tuple.getObject(1); String entryUrl = (String) tuple.getObject(2); verifyTrackback(commentId, url, entryUrl); } }
From source file:com.liferay.document.library.webdav.test.BaseWebDAVTestCase.java
License:Open Source License
public static int getStatusCode(Tuple tuple) { return (Integer) tuple.getObject(0); }
From source file:com.liferay.document.library.webdav.test.BaseWebDAVTestCase.java
License:Open Source License
protected static Map<String, String> getHeaders(Tuple tuple) { return (Map<String, String>) tuple.getObject(2); }
From source file:com.liferay.document.library.webdav.test.BaseWebDAVTestCase.java
License:Open Source License
protected static byte[] getResponseBody(Tuple tuple) { return (byte[]) tuple.getObject(1); }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public JSONObject getExceptionMessagesJSONObject(Locale locale, Exception e, ExportImportConfiguration exportImportConfiguration) { JSONObject exceptionMessagesJSONObject = JSONFactoryUtil.createJSONObject(); String errorMessage = StringPool.BLANK; JSONArray errorMessagesJSONArray = null; int errorType = 0; JSONArray warningMessagesJSONArray = null; ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", locale, getClass()); Throwable cause = e.getCause(); if (e instanceof DuplicateFileEntryException) { errorMessage = LanguageUtil.get(locale, "please-enter-a-unique-document-name"); errorType = ServletResponseConstants.SC_DUPLICATE_FILE_EXCEPTION; } else if (e instanceof FileExtensionException) { errorMessage = LanguageUtil.format(locale, "document-names-must-end-with-one-of-the-following-extensions", ".lar", false); errorType = ServletResponseConstants.SC_FILE_EXTENSION_EXCEPTION; } else if (e instanceof FileNameException) { errorMessage = LanguageUtil.get(locale, "please-enter-a-file-with-a-valid-file-name"); errorType = ServletResponseConstants.SC_FILE_NAME_EXCEPTION; } else if (e instanceof FileSizeException || e instanceof LARFileSizeException) { if ((exportImportConfiguration != null) && ((exportImportConfiguration .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_LOCAL) || (exportImportConfiguration .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_REMOTE) || (exportImportConfiguration .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_PORTLET))) { errorMessage = LanguageUtil.get(locale, "file-size-limit-exceeded.-please-ensure-that-the-file-" + "does-not-exceed-the-file-size-limit-in-both-the-" + "live-environment-and-the-staging-environment"); } else {/*from w ww .j ava 2 s. com*/ errorMessage = LanguageUtil.format(locale, "please-enter-a-file-with-a-valid-file-size-no-larger-" + "than-x", TextFormatter.formatStorageSize(_dlValidator.getMaxAllowableSize(), locale), false); } errorType = ServletResponseConstants.SC_FILE_SIZE_EXCEPTION; } else if (e instanceof LARTypeException) { LARTypeException lte = (LARTypeException) e; if (lte.getType() == LARTypeException.TYPE_COMPANY_GROUP) { errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x", "global-site"); } else if (lte.getType() == LARTypeException.TYPE_LAYOUT_PROTOTYPE) { errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x", LanguageUtil.get(locale, "page-template")); } else if (lte.getType() == LARTypeException.TYPE_LAYOUT_SET) { errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x", "site"); } else if (lte.getType() == LARTypeException.TYPE_LAYOUT_SET_PROTOTYPE) { errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x", LanguageUtil.get(locale, "site-template")); } else { errorMessage = LanguageUtil.format(resourceBundle, "uploaded-lar-file-type-x-does-not-match-x", new Object[] { lte.getActualLARType(), StringUtil.merge(lte.getExpectedLARTypes(), StringPool.COMMA_AND_SPACE) }); } errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; } else if (e instanceof LARFileException) { LARFileException lfe = (LARFileException) e; if (lfe.getType() == LARFileException.TYPE_INVALID_MANIFEST) { errorMessage = LanguageUtil.format(resourceBundle, "invalid-manifest.xml-x", lfe.getMessage()); } else if (lfe.getType() == LARFileException.TYPE_MISSING_MANIFEST) { errorMessage = LanguageUtil.get(resourceBundle, "missing-manifest.xml"); } else { errorMessage = LanguageUtil.get(locale, "please-specify-a-lar-file-to-import"); } errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; } else if (e instanceof LayoutImportException || cause instanceof LayoutImportException) { LayoutImportException lie = null; if (e instanceof LayoutImportException) { lie = (LayoutImportException) e; } else { lie = (LayoutImportException) cause; } if (lie.getType() == LayoutImportException.TYPE_WRONG_BUILD_NUMBER) { errorMessage = LanguageUtil.format(resourceBundle, "lar-build-number-x-does-not-match-portal-build-number-x", lie.getArguments()); } else if (lie.getType() == LayoutImportException.TYPE_WRONG_LAR_SCHEMA_VERSION) { errorMessage = LanguageUtil.format(resourceBundle, "lar-schema-version-x-does-not-match-deployed-export-" + "import-schema-version-x", lie.getArguments()); } else if (lie.getType() == LayoutImportException.TYPE_WRONG_PORTLET_SCHEMA_VERSION) { Object[] arguments = lie.getArguments(); Portlet portlet = _portletLocalService.getPortletById((String) arguments[1]); arguments[1] = portlet.getDisplayName(); errorMessage = LanguageUtil.format(resourceBundle, "portlet's-schema-version-x-in-the-lar-is-not-valid-for-" + "the-deployed-portlet-x-with-schema-version-x", lie.getArguments()); } else { errorMessage = e.getLocalizedMessage(); } errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; } else if (e instanceof LayoutPrototypeException) { LayoutPrototypeException lpe = (LayoutPrototypeException) e; StringBundler sb = new StringBundler(4); sb.append("the-lar-file-could-not-be-imported-because-it-"); sb.append("requires-page-templates-or-site-templates-that-could-"); sb.append("not-be-found.-please-import-the-following-templates-"); sb.append("manually"); errorMessage = LanguageUtil.get(resourceBundle, sb.toString()); errorMessagesJSONArray = JSONFactoryUtil.createJSONArray(); List<Tuple> missingLayoutPrototypes = lpe.getMissingLayoutPrototypes(); for (Tuple missingLayoutPrototype : missingLayoutPrototypes) { JSONObject errorMessageJSONObject = JSONFactoryUtil.createJSONObject(); String layoutPrototypeUuid = (String) missingLayoutPrototype.getObject(1); errorMessageJSONObject.put("info", layoutPrototypeUuid); String layoutPrototypeName = (String) missingLayoutPrototype.getObject(2); errorMessageJSONObject.put("name", layoutPrototypeName); String layoutPrototypeClassName = (String) missingLayoutPrototype.getObject(0); errorMessageJSONObject.put("type", ResourceActionsUtil.getModelResource(locale, layoutPrototypeClassName)); errorMessagesJSONArray.put(errorMessageJSONObject); } errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; } else if (e instanceof LocaleException) { LocaleException le = (LocaleException) e; errorMessage = LanguageUtil.format(locale, "the-available-languages-in-the-lar-file-x-do-not-match-the-" + "site's-available-languages-x", new String[] { StringUtil.merge(le.getSourceAvailableLocales(), StringPool.COMMA_AND_SPACE), StringUtil.merge(le.getTargetAvailableLocales(), StringPool.COMMA_AND_SPACE) }, false); errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; } else if (e instanceof MissingReferenceException) { MissingReferenceException mre = (MissingReferenceException) e; if ((exportImportConfiguration != null) && ((exportImportConfiguration .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_LOCAL) || (exportImportConfiguration .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_REMOTE) || (exportImportConfiguration .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_PORTLET))) { errorMessage = LanguageUtil.get(locale, "there-are-missing-references-that-could-not-be-found-in-" + "the-live-environment-the-following-elements-are-" + "published-from-their-own-site"); } else { errorMessage = LanguageUtil.get(locale, "there-are-missing-references-that-could-not-be-found-in-" + "the-current-site"); } MissingReferences missingReferences = mre.getMissingReferences(); errorMessagesJSONArray = getErrorMessagesJSONArray(locale, missingReferences.getDependencyMissingReferences()); errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; warningMessagesJSONArray = getWarningMessagesJSONArray(locale, missingReferences.getWeakMissingReferences()); } else if (e instanceof PortletDataException) { PortletDataException pde = (PortletDataException) e; String referrerClassName = pde.getStagedModelClassName(); String referrerDisplayName = pde.getStagedModelDisplayName(); String modelResource = ResourceActionsUtil.getModelResource(locale, referrerClassName); if (pde.getType() == PortletDataException.DELETE_PORTLET_DATA) { if (Validator.isNotNull(pde.getLocalizedMessage())) { errorMessage = LanguageUtil.format(locale, "the-following-error-in-x-while-deleting-its-data-" + "has-stopped-the-process-x", new String[] { _portal.getPortletTitle(pde.getPortletId(), locale), pde.getLocalizedMessage() }, false); } else { errorMessage = LanguageUtil.format(locale, "an-unexpected-error-in-x-while-deleting-its-data-" + "has-stopped-the-process", new String[] { _portal.getPortletTitle(pde.getPortletId(), locale) }, false); } } else if (pde.getType() == PortletDataException.EXPORT_PORTLET_DATA) { if (Validator.isNotNull(pde.getLocalizedMessage())) { errorMessage = LanguageUtil.format(locale, "the-following-error-in-x-while-exporting-its-data-" + "has-stopped-the-process-x", new String[] { _portal.getPortletTitle(pde.getPortletId(), locale), pde.getLocalizedMessage() }, false); } else { errorMessage = LanguageUtil.format(locale, "an-unexpected-error-in-x-while-exporting-its-data-" + "has-stopped-the-process", new String[] { _portal.getPortletTitle(pde.getPortletId(), locale) }, false); } } else if (pde.getType() == PortletDataException.IMPORT_PORTLET_DATA) { if (Validator.isNotNull(pde.getLocalizedMessage())) { errorMessage = LanguageUtil.format(locale, "the-following-error-in-x-while-importing-its-data-" + "has-stopped-the-process-x", new String[] { _portal.getPortletTitle(pde.getPortletId(), locale), pde.getLocalizedMessage() }, false); } else { errorMessage = LanguageUtil.format(locale, "an-unexpected-error-in-x-while-importing-its-data-" + "has-stopped-the-process", new String[] { _portal.getPortletTitle(pde.getPortletId(), locale) }, false); } } else if (pde.getType() == PortletDataException.INVALID_GROUP) { errorMessage = LanguageUtil.format(locale, "the-x-x-could-not-be-exported-because-it-is-not-in-the-" + "currently-exported-group", new String[] { modelResource, referrerDisplayName }, false); } else if (pde.getType() == PortletDataException.MISSING_DEPENDENCY) { errorMessage = LanguageUtil.format(locale, "the-x-x-has-missing-references-that-could-not-be-found-" + "during-the-process", new String[] { modelResource, referrerDisplayName }, false); } else if (pde.getType() == PortletDataException.PREPARE_MANIFEST_SUMMARY) { if (Validator.isNotNull(pde.getLocalizedMessage())) { errorMessage = LanguageUtil.format(locale, "the-following-error-in-x-while-preparing-its-" + "manifest-has-stopped-the-process-x", new String[] { _portal.getPortletTitle(pde.getPortletId(), locale), pde.getLocalizedMessage() }, false); } else { errorMessage = LanguageUtil.format(locale, "an-unexpected-error-in-x-while-preparing-its-" + "manifest-has-stopped-the-process", new String[] { _portal.getPortletTitle(pde.getPortletId(), locale) }, false); } } else if (pde.getType() == PortletDataException.STATUS_IN_TRASH) { errorMessage = LanguageUtil.format(locale, "the-x-x-could-not-be-exported-because-it-is-in-the-" + "recycle-bin", new String[] { modelResource, referrerDisplayName }, false); } else if (pde.getType() == PortletDataException.STATUS_UNAVAILABLE) { errorMessage = LanguageUtil.format(locale, "the-x-x-could-not-be-exported-because-its-workflow-" + "status-is-not-exportable", new String[] { modelResource, referrerDisplayName }, false); } else if (Validator.isNotNull(referrerDisplayName)) { errorMessage = LanguageUtil.format(resourceBundle, "the-following-error-occurred-while-processing-the-x-x-x", new String[] { modelResource, referrerDisplayName, e.getLocalizedMessage() }); } else { errorMessage = e.getLocalizedMessage(); } errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; } else if (e instanceof PortletIdException) { PortletIdException pie = (PortletIdException) e; Portlet portlet = _portletLocalService.getPortletById(pie.getMessage()); errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x", portlet.getDisplayName() + " Portlet"); errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; } else { errorMessage = e.getLocalizedMessage(); errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION; } exceptionMessagesJSONObject.put("message", errorMessage); if ((errorMessagesJSONArray != null) && (errorMessagesJSONArray.length() > 0)) { exceptionMessagesJSONObject.put("messageListItems", errorMessagesJSONArray); } exceptionMessagesJSONObject.put("status", errorType); if ((warningMessagesJSONArray != null) && (warningMessagesJSONArray.length() > 0)) { exceptionMessagesJSONObject.put("warningMessages", warningMessagesJSONArray); } return exceptionMessagesJSONObject; }
From source file:com.liferay.knowledgebase.display.portlet.DisplayPortlet.java
License:Open Source License
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try {// w w w . j av a 2s.c om ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); int status = getStatus(renderRequest); renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status); KBArticle kbArticle = null; Tuple resourceTuple = getResourceTuple(renderRequest); long resourcePrimKey = (Long) resourceTuple.getObject(1); if (resourcePrimKey != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { long resourceClassNameId = (Long) resourceTuple.getObject(0); long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName()); if (resourceClassNameId == kbFolderClassNameId) { PortalPreferences portalPreferences = PortletPreferencesFactoryUtil .getPortalPreferences(renderRequest); String preferredKBFolderUrlTitle = portalPreferences .getValue(PortletKeys.KNOWLEDGE_BASE_DISPLAY, "preferredKBFolderUrlTitle"); kbArticle = getKBFolderKBArticle(themeDisplay.getScopeGroupId(), resourcePrimKey, preferredKBFolderUrlTitle); } else { kbArticle = KBArticleServiceUtil.fetchLatestKBArticle(resourcePrimKey, status); } } else { long parentResourcePrimKey = ParamUtil.getLong(renderRequest, "parentResourcePrimKey", KBFolderConstants.DEFAULT_PARENT_FOLDER_ID); if (parentResourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { List<KBArticle> kbArticles = KBArticleLocalServiceUtil.getGroupKBArticles( themeDisplay.getScopeGroupId(), status, 0, 1, new KBArticlePriorityComparator(true)); if (!kbArticles.isEmpty()) { kbArticle = kbArticles.get(0); } } } renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle); } catch (Exception e) { if (e instanceof NoSuchArticleException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); SessionMessages.add(renderRequest, PortalUtil.getPortletId(renderRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); } else { throw new PortletException(e); } } super.render(renderRequest, renderResponse); }
From source file:com.liferay.knowledgebase.display.portlet.DisplayPortlet.java
License:Open Source License
protected int getStatus(RenderRequest renderRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return WorkflowConstants.STATUS_APPROVED; }// w w w.j a v a2 s .c o m String statusString = renderRequest.getParameter("status"); int status = GetterUtil.getInteger(statusString); if ((statusString != null) && (status == WorkflowConstants.STATUS_APPROVED)) { return WorkflowConstants.STATUS_APPROVED; } Tuple resourceTuple = getResourceTuple(renderRequest); long resourcePrimKey = (Long) resourceTuple.getObject(1); if (resourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return WorkflowConstants.STATUS_APPROVED; } long resourceClassNameId = (Long) resourceTuple.getObject(0); long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName()); if (resourceClassNameId == kbArticleClassNameId) { KBArticle kbArticle = KBArticleServiceUtil.fetchLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY); if (kbArticle == null) { return WorkflowConstants.STATUS_APPROVED; } if (KBArticlePermission.contains(themeDisplay.getPermissionChecker(), resourcePrimKey, ActionKeys.UPDATE)) { return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY); } } return WorkflowConstants.STATUS_APPROVED; }
From source file:com.liferay.portlet.blogs.util.LinkbackConsumerUtil.java
License:Open Source License
public static void verifyNewTrackbacks() { Tuple tuple = null; while (!_trackbacks.isEmpty()) { synchronized (_trackbacks) { tuple = _trackbacks.remove(0); }//from w ww . ja va 2 s . c o m long messageId = (Long) tuple.getObject(0); String url = (String) tuple.getObject(1); String entryUrl = (String) tuple.getObject(2); _verifyTrackback(messageId, url, entryUrl); } }
From source file:com.liferay.portlet.blogs.util.LinkbackProducerUtil.java
License:Open Source License
public static synchronized void sendQueuedPingbacks() throws XmlRpcException { Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, -1); Date expiration = cal.getTime(); while (!_pingbackQueue.isEmpty()) { Tuple tuple = _pingbackQueue.get(0); Date time = (Date) tuple.getObject(0); if (time.before(expiration)) { _pingbackQueue.remove(0);//from www .java 2 s. c o m String sourceUri = (String) tuple.getObject(1); String targetUri = (String) tuple.getObject(2); String serverUri = _discoverPingbackServer(targetUri); if (Validator.isNull(serverUri)) { continue; } if (_log.isInfoEnabled()) { _log.info("XML-RPC pingback " + serverUri + ", source " + sourceUri + ", target " + targetUri); } Response response = XmlRpcUtil.executeMethod(serverUri, "pingback.ping", new Object[] { sourceUri, targetUri }); if (_log.isInfoEnabled()) { _log.info(response.toString()); } } else { break; } } }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
protected void updateScope(ActionRequest actionRequest, Portlet portlet) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String oldScopeName = getOldScopeName(actionRequest, portlet); PortletPreferences portletPreferences = actionRequest.getPreferences(); String[] scopes = StringUtil.split(ParamUtil.getString(actionRequest, "scope")); String scopeType = scopes[0]; portletPreferences.setValue("lfrScopeType", scopeType); String scopeLayoutUuid = StringPool.BLANK; if ((scopes.length > 1) && scopeType.equals("layout")) { scopeLayoutUuid = scopes[1];/*from ww w . j a v a 2 s.c o m*/ } portletPreferences.setValue("lfrScopeLayoutUuid", scopeLayoutUuid); String portletTitle = getPortletTitle(actionRequest, portlet, portletPreferences); Tuple newScopeTuple = getNewScope(actionRequest); String newScopeName = (String) newScopeTuple.getObject(1); String newPortletTitle = _portal.getNewPortletTitle(portletTitle, oldScopeName, newScopeName); if (!newPortletTitle.equals(portletTitle)) { portletPreferences.setValue("portletSetupTitle_" + themeDisplay.getLanguageId(), newPortletTitle); portletPreferences.setValue("portletSetupUseCustomTitle", Boolean.TRUE.toString()); } portletPreferences.store(); }