List of usage examples for com.liferay.portal.kernel.util StringPool SLASH
String SLASH
To view the source code for com.liferay.portal.kernel.util StringPool SLASH.
Click Source Link
From source file:com.liferay.portlet.journal.model.impl.JournalFolderBaseImpl.java
License:Open Source License
@Override @SuppressWarnings("unused") public String buildTreePath() throws PortalException, SystemException { List<JournalFolder> journalFolders = new ArrayList<JournalFolder>(); JournalFolder journalFolder = this; while (journalFolder != null) { journalFolders.add(journalFolder); journalFolder = JournalFolderLocalServiceUtil.fetchJournalFolder(journalFolder.getParentFolderId()); }/*from ww w . ja v a 2 s .c om*/ StringBundler sb = new StringBundler((journalFolders.size() * 2) + 1); sb.append(StringPool.SLASH); for (int i = journalFolders.size() - 1; i >= 0; i--) { journalFolder = journalFolders.get(i); sb.append(journalFolder.getFolderId()); sb.append(StringPool.SLASH); } return sb.toString(); }
From source file:com.liferay.portlet.journal.service.impl.JournalStructureLocalServiceImpl.java
License:Open Source License
protected void validate(List<Element> elements, Set<String> elNames) throws PortalException { for (Element element : elements) { if (element.getName().equals("meta-data")) { continue; }/* w w w .j ava2 s .c om*/ String elName = element.attributeValue("name", StringPool.BLANK); String elType = element.attributeValue("type", StringPool.BLANK); if (Validator.isNull(elName) || elName.startsWith(JournalStructureConstants.RESERVED)) { throw new StructureXsdException(); } else { char[] c = elType.toCharArray(); for (int i = 0; i < c.length; i++) { if ((!Validator.isChar(c[i])) && (!Validator.isDigit(c[i])) && (c[i] != CharPool.DASH) && (c[i] != CharPool.UNDERLINE)) { throw new StructureXsdException(); } } String completePath = elName; Element parentElement = element.getParent(); while (!parentElement.isRootElement()) { completePath = parentElement.attributeValue("name", StringPool.BLANK) + StringPool.SLASH + completePath; parentElement = parentElement.getParent(); } String elNameLowerCase = completePath.toLowerCase(); if (elNames.contains(elNameLowerCase)) { throw new DuplicateStructureElementException(); } else { elNames.add(elNameLowerCase); } } if (Validator.isNull(elType)) { throw new StructureXsdException(); } validate(element.elements(), elNames); } }
From source file:com.liferay.portlet.journal.util.FreeMarkerTemplateParser.java
License:Open Source License
@Override protected String getJournalTemplatesPath() { StringBundler sb = new StringBundler(5); sb.append(JournalTemplateLoader.JOURNAL_SEPARATOR); sb.append(StringPool.SLASH); sb.append(getCompanyId());// w ww . j a v a 2 s . c om sb.append(StringPool.SLASH); sb.append(getGroupId()); return sb.toString(); }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
@Override public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID); if ((classNameId != null) && (classNameId.longValue() != 0)) { contextQuery.addRequiredTerm("classNameId", classNameId.toString()); }/* w w w .ja va 2s. c o m*/ addStatus(contextQuery, searchContext); addSearchClassTypeIds(contextQuery, searchContext); String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { String[] ddmStructureFieldNameParts = StringUtil.split(ddmStructureFieldName, StringPool.SLASH); DDMStructure structure = DDMStructureLocalServiceUtil .getStructure(GetterUtil.getLong(ddmStructureFieldNameParts[1])); String fieldName = StringUtil.replaceLast(ddmStructureFieldNameParts[2], StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(searchContext.getLocale())), StringPool.BLANK); try { ddmStructureFieldValue = DDMUtil.getIndexedFieldValue(ddmStructureFieldValue, structure.getFieldType(fieldName)); } catch (StructureFieldException sfe) { } contextQuery.addRequiredTerm(ddmStructureFieldName, StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE); } String articleType = (String) searchContext.getAttribute("articleType"); if (Validator.isNotNull(articleType)) { contextQuery.addRequiredTerm(Field.TYPE, articleType); } String ddmStructureKey = (String) searchContext.getAttribute("ddmStructureKey"); if (Validator.isNotNull(ddmStructureKey)) { contextQuery.addRequiredTerm("ddmStructureKey", ddmStructureKey); } String ddmTemplateKey = (String) searchContext.getAttribute("ddmTemplateKey"); if (Validator.isNotNull(ddmTemplateKey)) { contextQuery.addRequiredTerm("ddmTemplateKey", ddmTemplateKey); } }
From source file:com.liferay.portlet.journal.util.JournalConverterImpl.java
License:Open Source License
protected static JSONObject createJsonArray(String initialsearchableString, long groupId) throws PortalException, SystemException { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); _log.info("initialsearchableString in createJsonArray " + initialsearchableString); int startIndex = initialsearchableString.lastIndexOf(StringPool.SLASH); startIndex = startIndex + 1;/*from w w w . ja va 2 s . c o m*/ String fileTitle = initialsearchableString.substring(startIndex, initialsearchableString.length()); _log.info("fileTitle is ::" + fileTitle); int stoxxnetLength = STOXXNET.length(); int folderPathIndex = initialsearchableString.indexOf(STOXXNET); folderPathIndex = folderPathIndex + stoxxnetLength; startIndex = startIndex - 1; String folderPath = initialsearchableString.substring(folderPathIndex, startIndex); _log.info("folderPath is " + folderPath); long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; List<String> addedPagesList = Arrays.asList(folderPath.split(StringPool.SLASH)); for (String folderName : addedPagesList) { _log.info("folderName is " + folderName); if (StringUtils.isNotBlank(folderName)) { parentFolderId = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, folderName) .getFolderId(); } _log.info("parentFolderId is " + parentFolderId); } FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, parentFolderId, fileTitle); if (Validator.isNotNull(fileEntry)) { jsonObject.put("groupId", fileEntry.getGroupId()); jsonObject.put("uuid", fileEntry.getUuid()); jsonObject.put("version", fileEntry.getVersion()); jsonObject.put("fileUrl", initialsearchableString); } _log.info("jsonObject.toString() url in createJsonArray is " + jsonObject.toString()); return jsonObject; }
From source file:com.liferay.portlet.journal.util.VelocityTemplateParser.java
License:Open Source License
protected String getJournalTemplatesPath() { StringBundler sb = new StringBundler(5); sb.append(VelocityResourceListener.JOURNAL_SEPARATOR); sb.append(StringPool.SLASH); sb.append(getCompanyId());//from www. j av a 2s . co m sb.append(StringPool.SLASH); sb.append(getGroupId()); return sb.toString(); }
From source file:com.liferay.portlet.layoutsadmin.util.SitemapImpl.java
License:Open Source License
protected String buildI18NPath(Locale locale) { String languageId = LocaleUtil.toLanguageId(locale); if (Validator.isNull(languageId)) { return null; }//from www . j a v a 2s. c o m if (LanguageUtil.isDuplicateLanguageCode(locale.getLanguage())) { Locale priorityLocale = LanguageUtil.getLocale(locale.getLanguage()); if (locale.equals(priorityLocale)) { languageId = locale.getLanguage(); } } else { languageId = locale.getLanguage(); } return StringPool.SLASH.concat(languageId); }
From source file:com.liferay.portlet.login.util.LoginUtil.java
License:Open Source License
public static void login(HttpServletRequest request, HttpServletResponse response, String login, String password, boolean rememberMe, String authType) throws Exception { CookieKeys.validateSupportCookie(request); HttpSession session = request.getSession(); Company company = PortalUtil.getCompany(request); long userId = getAuthenticatedUserId(request, login, password, authType); if (!PropsValues.AUTH_SIMULTANEOUS_LOGINS) { Map<String, UserTracker> sessionUsers = LiveUsers.getSessionUsers(company.getCompanyId()); List<UserTracker> userTrackers = new ArrayList<UserTracker>(sessionUsers.values()); for (UserTracker userTracker : userTrackers) { if (userId != userTracker.getUserId()) { continue; }//w ww . jav a2s. co m JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); ClusterNode clusterNode = ClusterExecutorUtil.getLocalClusterNode(); if (clusterNode != null) { jsonObject.put("clusterNodeId", clusterNode.getClusterNodeId()); } jsonObject.put("command", "signOut"); long companyId = CompanyLocalServiceUtil.getCompanyIdByUserId(userId); jsonObject.put("companyId", companyId); jsonObject.put("sessionId", userTracker.getSessionId()); jsonObject.put("userId", userId); MessageBusUtil.sendMessage(DestinationNames.LIVE_USERS, jsonObject.toString()); } } if (PropsValues.SESSION_ENABLE_PHISHING_PROTECTION) { session = renewSession(request, session); } // Set cookies String domain = CookieKeys.getDomain(request); User user = UserLocalServiceUtil.getUserById(userId); String userIdString = String.valueOf(userId); session.setAttribute("j_username", userIdString); if (PropsValues.PORTAL_JAAS_PLAIN_PASSWORD) { session.setAttribute("j_password", password); } else { session.setAttribute("j_password", user.getPassword()); } session.setAttribute("j_remoteuser", userIdString); if (PropsValues.SESSION_STORE_PASSWORD) { session.setAttribute(WebKeys.USER_PASSWORD, password); } Cookie companyIdCookie = new Cookie(CookieKeys.COMPANY_ID, String.valueOf(company.getCompanyId())); if (Validator.isNotNull(domain)) { companyIdCookie.setDomain(domain); } companyIdCookie.setPath(StringPool.SLASH); Cookie idCookie = new Cookie(CookieKeys.ID, Encryptor.encrypt(company.getKeyObj(), userIdString)); if (Validator.isNotNull(domain)) { idCookie.setDomain(domain); } idCookie.setPath(StringPool.SLASH); Cookie passwordCookie = new Cookie(CookieKeys.PASSWORD, Encryptor.encrypt(company.getKeyObj(), password)); if (Validator.isNotNull(domain)) { passwordCookie.setDomain(domain); } passwordCookie.setPath(StringPool.SLASH); Cookie rememberMeCookie = new Cookie(CookieKeys.REMEMBER_ME, Boolean.TRUE.toString()); if (Validator.isNotNull(domain)) { rememberMeCookie.setDomain(domain); } rememberMeCookie.setPath(StringPool.SLASH); int loginMaxAge = PropsValues.COMPANY_SECURITY_AUTO_LOGIN_MAX_AGE; String userUUID = userIdString.concat(StringPool.PERIOD).concat(String.valueOf(System.nanoTime())); Cookie userUUIDCookie = new Cookie(CookieKeys.USER_UUID, Encryptor.encrypt(company.getKeyObj(), userUUID)); userUUIDCookie.setPath(StringPool.SLASH); session.setAttribute(WebKeys.USER_UUID, userUUID); if (PropsValues.SESSION_DISABLED) { rememberMe = true; } if (rememberMe) { companyIdCookie.setMaxAge(loginMaxAge); idCookie.setMaxAge(loginMaxAge); passwordCookie.setMaxAge(loginMaxAge); rememberMeCookie.setMaxAge(loginMaxAge); userUUIDCookie.setMaxAge(loginMaxAge); } else { // This was explicitly changed from 0 to -1 so that the cookie lasts // as long as the browser. This allows an external servlet wrapped // in AutoLoginFilter to work throughout the client connection. The // cookies ARE removed on an actual logout, so there is no security // issue. See LEP-4678 and LEP-5177. companyIdCookie.setMaxAge(-1); idCookie.setMaxAge(-1); passwordCookie.setMaxAge(-1); rememberMeCookie.setMaxAge(0); userUUIDCookie.setMaxAge(-1); } Cookie loginCookie = new Cookie(CookieKeys.LOGIN, login); if (Validator.isNotNull(domain)) { loginCookie.setDomain(domain); } loginCookie.setMaxAge(loginMaxAge); loginCookie.setPath(StringPool.SLASH); Cookie screenNameCookie = new Cookie(CookieKeys.SCREEN_NAME, Encryptor.encrypt(company.getKeyObj(), user.getScreenName())); if (Validator.isNotNull(domain)) { screenNameCookie.setDomain(domain); } screenNameCookie.setMaxAge(loginMaxAge); screenNameCookie.setPath(StringPool.SLASH); boolean secure = request.isSecure(); if (secure && !PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS && !StringUtil.equalsIgnoreCase(Http.HTTPS, PropsValues.WEB_SERVER_PROTOCOL)) { Boolean httpsInitial = (Boolean) session.getAttribute(WebKeys.HTTPS_INITIAL); if ((httpsInitial == null) || !httpsInitial.booleanValue()) { secure = false; } } CookieKeys.addCookie(request, response, companyIdCookie, secure); CookieKeys.addCookie(request, response, idCookie, secure); CookieKeys.addCookie(request, response, userUUIDCookie, secure); if (rememberMe) { CookieKeys.addCookie(request, response, loginCookie, secure); CookieKeys.addCookie(request, response, passwordCookie, secure); CookieKeys.addCookie(request, response, rememberMeCookie, secure); CookieKeys.addCookie(request, response, screenNameCookie, secure); } AuthenticatedUserUUIDStoreUtil.register(userUUID); }
From source file:com.liferay.portlet.messageboards.lar.MBPortletDataHandlerImpl.java
License:Open Source License
protected String getMessageAttachementBinPath(PortletDataContext portletDataContext, MBMessage message, String attachment) {//from www . j a v a2 s . co m StringBundler sb = new StringBundler(5); sb.append(portletDataContext.getPortletPath(PortletKeys.MESSAGE_BOARDS)); sb.append("/bin/"); sb.append(message.getMessageId()); sb.append(StringPool.SLASH); sb.append(PortalUUIDUtil.generate()); return sb.toString(); }
From source file:com.liferay.portlet.messageboards.service.impl.MBMailingListLocalServiceImpl.java
License:Open Source License
protected String getSchedulerGroupName(MBMailingList mailingList) { return DestinationNames.MESSAGE_BOARDS_MAILING_LIST.concat(StringPool.SLASH) .concat(String.valueOf(mailingList.getMailingListId())); }