List of usage examples for com.liferay.portal.kernel.util StringPool PERIOD
String PERIOD
To view the source code for com.liferay.portal.kernel.util StringPool PERIOD.
Click Source Link
From source file:com.rivetlogic.elasticsearch.portlet.util.ElasticsearchPropsValues.java
License:Open Source License
/** * Sets the suggestion excluded types.//from ww w . jav a2 s . com */ private void setSuggestionExcludedTypes() { suggestionExcludedTypes = new HashSet<String>(); String csExcludedTypes = getPortletProperty(ElasticsearchPortletConstants.SUGGESTION_EXCLUDED_TYPES_KEY); if (Validator.isNotNull(csExcludedTypes)) { String[] excludedTypes = csExcludedTypes.split(StringPool.COMMA); /** Iterate over the fields and add to Querybuilder */ for (String type : excludedTypes) { String elasticsearchType = type.replace(StringPool.PERIOD, StringPool.UNDERLINE); suggestionExcludedTypes.add(elasticsearchType); } } else { if (_log.isDebugEnabled()) { _log.debug("Suggestion query excluded index types are not defined....."); } } }
From source file:com.rivetlogic.portal.search.elasticsearch.indexer.document.ElasticsearchDocumentJSONBuilder.java
License:Open Source License
/** * Convert to json.// w w w. jav a 2s. co m * * @param document * the document * @return the string */ public ElasticserachJSONDocument convertToJSON(final Document document) { Map<String, Field> fields = document.getFields(); ElasticserachJSONDocument elasticserachJSONDocument = new ElasticserachJSONDocument(); try { XContentBuilder contentBuilder = XContentFactory.jsonBuilder().startObject(); Field classnameField = document.getField(ElasticsearchIndexerConstants.ENTRY_CLASSNAME); String entryClassName = (classnameField == null) ? "" : classnameField.getValue(); /** * Handle all error scenarios prior to conversion */ if (isDocumentHidden(document)) { elasticserachJSONDocument.setError(true); elasticserachJSONDocument .setErrorMessage(ElasticserachJSONDocument.DocumentError.HIDDEN_DOCUMENT.toString()); return elasticserachJSONDocument; } if (entryClassName.isEmpty()) { elasticserachJSONDocument.setError(true); elasticserachJSONDocument .setErrorMessage(ElasticserachJSONDocument.DocumentError.MISSING_ENTRYCLASSNAME.toString()); return elasticserachJSONDocument; } if (isExcludedType(entryClassName)) { elasticserachJSONDocument.setError(true); elasticserachJSONDocument.setErrorMessage("Index Type:" + entryClassName + StringPool.COMMA + ElasticserachJSONDocument.DocumentError.EXCLUDED_TYPE.toString()); return elasticserachJSONDocument; } /** * To avoid multiple documents for versioned assets such as Journal articles, DL entry etc * the primary Id will be Indextype + Entry class PK. The primary Id is to maintain uniqueness * in ES server database and nothing to do with UID or is not used for any other purpose. */ Field classPKField = document.getField(ElasticsearchIndexerConstants.ENTRY_CLASSPK); String entryClassPK = (classPKField == null) ? "" : classPKField.getValue(); if (entryClassPK.isEmpty()) { elasticserachJSONDocument.setError(true); elasticserachJSONDocument .setErrorMessage(ElasticserachJSONDocument.DocumentError.MISSING_CLASSPK.toString()); return elasticserachJSONDocument; } /** Replace '.' by '_' in Entry class name,since '.' is not recommended by Elasticsearch in Index type */ String indexType = entryClassName.replace(StringPool.PERIOD, StringPool.UNDERLINE); elasticserachJSONDocument.setIndexType(indexType); elasticserachJSONDocument.setId(indexType + entryClassPK); /** Create a JSON string for remaining fields of document */ for (Iterator<Map.Entry<String, Field>> it = fields.entrySet().iterator(); it.hasNext();) { Map.Entry<String, Field> entry = it.next(); Field field = entry.getValue(); contentBuilder.field(entry.getKey(), field.getValue()); } contentBuilder.endObject(); elasticserachJSONDocument.setJsonDocument(contentBuilder.string()); if (_log.isDebugEnabled()) { _log.debug("Liferay Document converted to ESJSON document successfully:" + contentBuilder.string()); } } catch (IOException e) { _log.error("IO Error during converstion of Liferay Document to JSON format" + e.getMessage()); } return elasticserachJSONDocument; }
From source file:com.rivetlogic.quickquestions.action.util.MBUtil.java
License:Open Source License
public static String getReplyToAddress(long categoryId, long messageId, String mx, String defaultMailingListAddress) { if (PropsValues.POP_SERVER_SUBDOMAIN.length() <= 0) { return defaultMailingListAddress; }//from w w w .ja v a 2 s . c o m StringBundler sb = new StringBundler(8); sb.append(MESSAGE_POP_PORTLET_PREFIX); sb.append(categoryId); sb.append(StringPool.PERIOD); sb.append(messageId); sb.append(StringPool.AT); sb.append(PropsValues.POP_SERVER_SUBDOMAIN); sb.append(StringPool.PERIOD); sb.append(mx); return sb.toString(); }
From source file:com.vportal.portlet.vcalendar.util.CalUtil.java
License:Open Source License
public static String toString(Calendar cal) { StringBundler sb = new StringBundler(7); sb.append(cal.get(Calendar.YEAR)); sb.append(StringPool.PERIOD); sb.append(cal.get(Calendar.MONTH)); sb.append(StringPool.PERIOD);/* w w w . j a v a 2s . com*/ sb.append(cal.get(Calendar.DATE)); sb.append(StringPool.PERIOD); sb.append(cal.getTimeZone().getRawOffset()); return sb.toString(); }
From source file:it.smc.calendar.sync.caldav.LiferayCalDAVStorageImpl.java
License:Open Source License
@Override public Resource getResource(WebDAVRequest webDAVRequest) throws WebDAVException { try {// w w w . ja va 2 s . co m String[] pathArray = webDAVRequest.getPathArray(); String method = webDAVRequest.getHttpServletRequest().getMethod(); if (CalDAVUtil.isPrincipalRequest(webDAVRequest)) { long userid = GetterUtil.getLong(pathArray[2]); User user = null; try { user = UserServiceUtil.getUserById(userid); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(e); } } if (user == null) { throw new WebDAVException("No user were found with id " + pathArray[2]); } return toResource(webDAVRequest, user); } // calendar resource collection request String calendarResourceGUID = pathArray[0]; CalendarResource calendarResource = CalendarResourceLocalServiceUtil .fetchCalendarResourceByUuidAndCompanyId(calendarResourceGUID, webDAVRequest.getCompanyId()); if (calendarResource == null) { throw new ResourceNotFoundException( "No calendar resource were found for GUID " + calendarResourceGUID); } //CalendarResourcePermission.check( // webDAVRequest.getPermissionChecker(), calendarResource, // ActionKeys.VIEW); if (CalDAVUtil.isCalendarBookingRequest(webDAVRequest) && !method.equals(CalDAVHttpMethods.PUT)) { // calendar booking resource String resourceName = pathArray[pathArray.length - 1]; String resourceExtension = StringPool.PERIOD.concat(FileUtil.getExtension(resourceName)); if (resourceName.endsWith(resourceExtension)) { String resourceShortName = StringUtil.replace(resourceName, resourceExtension, StringPool.BLANK); long calendarBookingId = GetterUtil.getLong(resourceShortName); CalendarBooking calendarBooking = CalendarBookingServiceUtil .fetchCalendarBooking(calendarBookingId); if (calendarBooking == null) { throw new ResourceNotFoundException( "Calendar booking not found with id: " + calendarBookingId); } return toResource(webDAVRequest, calendarBooking); } } if (CalDAVUtil.isCalendarRequest(webDAVRequest)) { // calendar request String calendarGUID = pathArray[2]; Calendar calendar = CalendarLocalServiceUtil.fetchCalendarByUuidAndCompanyId(calendarGUID, webDAVRequest.getCompanyId()); if (calendar == null) { throw new ResourceNotFoundException("No calendar were found for GUID " + calendarGUID); } //CalendarPermission.check( // webDAVRequest.getPermissionChecker(), calendar, // ActionKeys.VIEW); return toResource(webDAVRequest, calendar); } else { return toResource(webDAVRequest, calendarResource); } } catch (Exception e) { throw new WebDAVException(e); } }
From source file:it.smc.calendar.sync.caldav.util.CalDAVUtil.java
License:Open Source License
public static CalendarBooking getCalendarBookingFromURL(String URL) throws PortalException, SystemException { if (!URL.endsWith(CalendarDataFormat.ICAL.getValue())) { return null; }//from ww w . j a v a 2 s. c om String calendarBookingICSStr = StringUtil.extractLast(URL, StringPool.SLASH); String calendarBookingIdStr = StringUtil.extractFirst(calendarBookingICSStr, StringPool.PERIOD); long calendarBookingId = GetterUtil.getLong(calendarBookingIdStr); return CalendarBookingServiceUtil.getCalendarBooking(calendarBookingId); }
From source file:it.smc.calendar.sync.caldav.util.CalDAVUtil.java
License:Open Source License
public static String getCalendarBookingURL(CalendarBooking calendarBooking) throws PortalException, SystemException { StringBuilder sb = new StringBuilder(11); sb.append(PortalUtil.getPathContext()); sb.append("/webdav/"); sb.append(calendarBooking.getCalendarResource().getUuid()); sb.append(StringPool.SLASH);//from w w w. j a va 2 s. c o m sb.append(WebKeys.CALDAV_TOKEN); sb.append(StringPool.SLASH); sb.append(calendarBooking.getCalendar().getUuid()); sb.append(StringPool.SLASH); sb.append(calendarBooking.getCalendarBookingId()); sb.append(StringPool.PERIOD); sb.append(CalendarDataFormat.ICAL.getValue()); return sb.toString(); }
From source file:it.smc.calendar.sync.caldav.util.CalDAVUtil.java
License:Open Source License
public static boolean isCalendarBookingRequest(WebDAVRequest webDAVRequest) { if (webDAVRequest.getPathArray().length <= 3) { return false; }/* w w w. j a v a2s . c o m*/ String path = webDAVRequest.getPath(); return path.endsWith(StringPool.PERIOD + CalendarDataFormat.ICAL.getValue()); }
From source file:jorgediazest.missingrefchecker.chk.DLStoreReferenceChecker.java
License:Open Source License
@Override public boolean isValidData(Reference reference, boolean ignoreNullValues, Data d) { if (com.liferay.portal.kernel.model.Image.class.getName().equals(d.getModel().getClassName())) { String imageId = (d.get("imageId")).toString(); String type = (String) d.get("type"); d.set("name", imageId + StringPool.PERIOD + type); }//from w ww.ja v a 2 s . co m String name = (String) d.get("name"); Long fileEntryId = (Long) d.get("fileEntryId"); ModelQueryFactory queryFactory = reference.getModelQueryFactory(); if (Validator.isNull(name) && Validator.isNotNull(fileEntryId)) { Map<Long, String> fileEntryIdNameMap = getFileEntryIdNameMap(queryFactory); if (fileEntryIdNameMap != null) { name = fileEntryIdNameMap.get(fileEntryId); } } if (Validator.isNull(name)) { return false; } long companyId = (Long) d.get("companyId", 0L); long repositoryId = (Long) d.get("repositoryId", 0L); long folderId = (Long) d.get("folderId", 0L); String version = (String) d.get("version"); long dataRepositoryId = DLFolderConstants.getDataRepositoryId(repositoryId, folderId); try { if (version == null) { return DLStoreUtil.hasFile(companyId, dataRepositoryId, name); } return DLStoreUtil.hasFile(companyId, dataRepositoryId, name, version); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:m.omarh.liferay.resources.importer.generator.util.tree.JournalArticleUtil.java
License:Open Source License
public static JSONObject getJournalArticleContentJSONObject(ThemeDisplay themeDisplay, String resourceId) { JSONObject htmlJSONObject = JSONFactoryUtil.createJSONObject(); try {/*from w w w . j a v a 2s . c om*/ String name = resourceId.substring(0, resourceId.indexOf(StringPool.PERIOD)); String content = getJournalArticleContent(themeDisplay, name); htmlJSONObject.put("content", content); } catch (PortalException e) { _log.error(e.getMessage()); } catch (SystemException e) { _log.error(e.getMessage()); } return htmlJSONObject; }