protected void updatePreferencesClassPKs(PortletPreferences preferences, String key) throws Exception { String[] oldValues = preferences.getValues(key, null); if (oldValues == null) { return; } String[] newValues = new String[oldValues.length]; for (int i = 0; i < oldValues.length; i++) { String oldValue = oldValues[i]; String newValue = oldValue; String[] oldPrimaryKeys = StringUtil.split(oldValue); for (String oldPrimaryKey : oldPrimaryKeys) { if (!Validator.isNumber(oldPrimaryKey)) { break; } Long newPrimaryKey = _ddmStructurePKs.get(GetterUtil.getLong(oldPrimaryKey)); if (Validator.isNotNull(newPrimaryKey)) { newValue = StringUtil.replace(newValue, oldPrimaryKey, String.valueOf(newPrimaryKey)); } } newValues[i] = newValue; } preferences.setValues(key, newValues); }
protected String fixComments(String content) { Matcher matcher = _commentPattern.matcher(content); while (matcher.find()) { String[] words = StringUtil.split(matcher.group(1), CharPool.SPACE); for (int i = 1; i < words.length; i++) { String previousWord = words[i - 1]; if (previousWord.endsWith(StringPool.PERIOD) || previousWord.equals(StringPool.SLASH)) { continue; } String word = words[i]; if ((word.length() > 1) && Character.isUpperCase(word.charAt(0)) && StringUtil.isLowerCase(word.substring(1))) { content = StringUtil.replaceFirst(content, word, StringUtil.toLowerCase(word), matcher.start()); } } } return content; }
@Override public String replaceImportContentReferences( PortletDataContext portletDataContext, StagedModel stagedModel, String content) throws Exception { JournalFeed feed = (JournalFeed) stagedModel; Group group = _groupLocalService.getGroup(portletDataContext.getScopeGroupId()); String newGroupFriendlyURL = group.getFriendlyURL(); newGroupFriendlyURL = newGroupFriendlyURL.substring(1); String[] friendlyURLParts = StringUtil.split(feed.getTargetLayoutFriendlyUrl(), '/'); String oldGroupFriendlyURL = friendlyURLParts[2]; if (oldGroupFriendlyURL.equals(DATA_HANDLER_GROUP_FRIENDLY_URL)) { feed.setTargetLayoutFriendlyUrl( StringUtil.replace( feed.getTargetLayoutFriendlyUrl(), DATA_HANDLER_GROUP_FRIENDLY_URL, newGroupFriendlyURL)); } return content; }
protected void checkStringBundler(String line, String fileName, int lineCount) { if ((!line.startsWith("sb.append(") && !line.contains("SB.append(")) || !line.endsWith(");")) { return; } int pos = line.indexOf(".append("); line = line.substring(pos + 8, line.length() - 2); line = stripQuotes(line, CharPool.QUOTE); if (!line.contains(" + ")) { return; } String[] lineParts = StringUtil.split(line, " + "); for (String linePart : lineParts) { int closeParenthesesCount = StringUtil.count(linePart, StringPool.CLOSE_PARENTHESIS); int openParenthesesCount = StringUtil.count(linePart, StringPool.OPEN_PARENTHESIS); if (closeParenthesesCount != openParenthesesCount) { return; } if (Validator.isNumber(linePart)) { return; } } processErrorMessage(fileName, "plus: " + fileName + " " + lineCount); }
protected void readResourceActions() { Configuration configuration = ConfigurationFactoryUtil.getConfiguration(_classLoader, "portlet"); String[] resourceActionsConfigs = StringUtil.split(configuration.get(PropsKeys.RESOURCE_ACTIONS_CONFIGS)); for (String resourceActionsConfig : resourceActionsConfigs) { try { ResourceActionsUtil.read(null, _classLoader, resourceActionsConfig); } catch (Exception e) { _log.error("Unable to read resource actions config in " + resourceActionsConfig, e); } } String[] portletIds = StringUtil.split(configuration.get("portlet.ids")); for (String portletId : portletIds) { List<String> modelNames = ResourceActionsUtil.getPortletModelResources(portletId); List<String> portletActions = ResourceActionsUtil.getPortletResourceActions(portletId); ResourceActionLocalServiceUtil.checkResourceActions(portletId, portletActions); for (String modelName : modelNames) { List<String> modelActions = ResourceActionsUtil.getModelResourceActions(modelName); ResourceActionLocalServiceUtil.checkResourceActions(modelName, modelActions); } } }
/** * Escapes the HREF attribute so that it is safe to use as an HREF attribute. * * @param href the HREF attribute to escape * @return the escaped HREF attribute, or <code>null</code> if the HREF attribute is <code>null * </code> */ @Override public String escapeHREF(String href) { if (href == null) { return null; } if (href.length() == 0) { return StringPool.BLANK; } int index = href.indexOf(StringPool.COLON); if (index == 4) { String protocol = StringUtil.toLowerCase(href.substring(0, 4)); if (protocol.equals("data")) { href = StringUtil.replaceFirst(href, CharPool.COLON, "%3a"); } } else if (index == 10) { String protocol = StringUtil.toLowerCase(href.substring(0, 10)); if (protocol.equals("javascript")) { href = StringUtil.replaceFirst(href, CharPool.COLON, "%3a"); } } return escapeAttribute(href); }
protected String replaceStatusJoin(String sql, QueryDefinition<JournalArticle> queryDefinition) { if (queryDefinition.getStatus() == WorkflowConstants.STATUS_ANY) { return StringUtil.replace(sql, "[$STATUS_JOIN$] AND", StringPool.BLANK); } if (queryDefinition.isExcludeStatus()) { StringBundler sb = new StringBundler(5); sb.append("(JournalArticle.status != "); sb.append(queryDefinition.getStatus()); sb.append(") AND (tempJournalArticle.status != "); sb.append(queryDefinition.getStatus()); sb.append(")"); sql = StringUtil.replace(sql, "[$STATUS_JOIN$]", sb.toString()); } else { StringBundler sb = new StringBundler(5); sb.append("(JournalArticle.status = "); sb.append(queryDefinition.getStatus()); sb.append(") AND (tempJournalArticle.status = "); sb.append(queryDefinition.getStatus()); sb.append(")"); sql = StringUtil.replace(sql, "[$STATUS_JOIN$]", sb.toString()); } return sql; }
protected void exportAssetTags(PortletDataContext portletDataContext) throws Exception { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("tags"); Map<String, String[]> assetTagNamesMap = portletDataContext.getAssetTagNamesMap(); for (Map.Entry<String, String[]> entry : assetTagNamesMap.entrySet()) { String[] assetTagNameParts = StringUtil.split(entry.getKey(), CharPool.POUND); String className = assetTagNameParts[0]; String classPK = assetTagNameParts[1]; Element assetElement = rootElement.addElement("asset"); assetElement.addAttribute("class-name", className); assetElement.addAttribute("class-pk", classPK); assetElement.addAttribute("tags", StringUtil.merge(entry.getValue())); } List<AssetTag> assetTags = AssetTagServiceUtil.getGroupTags(portletDataContext.getScopeGroupId()); for (AssetTag assetTag : assetTags) { exportAssetTag(portletDataContext, assetTag, rootElement); } portletDataContext.addZipEntry( portletDataContext.getRootPath() + "/tags.xml", document.formattedString()); }
public BaseWebDriverImpl(String projectDirName, String browserURL, WebDriver webDriver) { super(webDriver); _projectDirName = projectDirName; if (OSDetector.isWindows()) { _dependenciesDirName = StringUtil.replace(_dependenciesDirName, "//", "\\"); _outputDirName = StringUtil.replace(_outputDirName, "//", "\\"); _projectDirName = StringUtil.replace(_projectDirName, "//", "\\"); _sikuliImagesDirName = StringUtil.replace(_sikuliImagesDirName, "//", "\\"); _sikuliImagesDirName = StringUtil.replace(_sikuliImagesDirName, "linux", "windows"); } if (!TestPropsValues.MOBILE_DEVICE_ENABLED) { WebDriver.Options options = webDriver.manage(); WebDriver.Window window = options.window(); int x = 1065; int y = 1040; window.setSize(new Dimension(x, y)); } webDriver.get(browserURL); }
protected String reword(String data) throws IOException { UnsyncBufferedReader unsyncBufferedReader = new UnsyncBufferedReader(new UnsyncStringReader(data)); StringBundler sb = new StringBundler(); String line = null; while ((line = unsyncBufferedReader.readLine()) != null) { if (line.startsWith(ALTER_COLUMN_NAME)) { String[] template = buildColumnNameTokens(line); line = StringUtil.replace( "exec sp_rename '@table@.@old-column@', '@new-column@', " + "'column';", REWORD_TEMPLATE, template); } else if (line.startsWith(ALTER_COLUMN_TYPE)) { String[] template = buildColumnTypeTokens(line); line = StringUtil.replace( "alter table @table@ alter column @old-column@ @type@;", REWORD_TEMPLATE, template); } sb.append(line); sb.append("\n"); } unsyncBufferedReader.close(); return sb.toString(); }
protected void exportAssetLinks(PortletDataContext portletDataContext) throws Exception { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("links"); Map<String, String[]> assetLinkUuidsMap = portletDataContext.getAssetLinkUuidsMap(); for (Map.Entry<String, String[]> entry : assetLinkUuidsMap.entrySet()) { String[] assetLinkNameParts = StringUtil.split(entry.getKey(), CharPool.POUND); String[] targetAssetEntryUuids = entry.getValue(); String sourceAssetEntryUuid = assetLinkNameParts[0]; String assetLinkType = assetLinkNameParts[1]; Element assetElement = rootElement.addElement("asset-link"); assetElement.addAttribute("source-uuid", sourceAssetEntryUuid); assetElement.addAttribute("target-uuids", StringUtil.merge(targetAssetEntryUuids)); assetElement.addAttribute("type", assetLinkType); } portletDataContext.addZipEntry( portletDataContext.getRootPath() + "/links.xml", document.formattedString()); }
protected String replaceJoinAndWhere(String sql, LinkedHashMap<String, Object> params) { sql = StringUtil.replace(sql, "[$JOIN$]", getJoin(params)); sql = StringUtil.replace(sql, "[$WHERE$]", getWhere(params)); return sql; }
protected List<String> getPortletMimeTypeActions(String name) { List<String> actions = new UniqueList<String>(); Portlet portlet = portletLocalService.getPortletById(name); if (portlet != null) { Map<String, Set<String>> portletModes = portlet.getPortletModes(); Set<String> mimeTypePortletModes = portletModes.get(ContentTypes.TEXT_HTML); if (mimeTypePortletModes != null) { for (String actionId : mimeTypePortletModes) { if (StringUtil.equalsIgnoreCase(actionId, "edit")) { actions.add(ActionKeys.PREFERENCES); } else if (StringUtil.equalsIgnoreCase(actionId, "edit_guest")) { actions.add(ActionKeys.GUEST_PREFERENCES); } else { actions.add(StringUtil.toUpperCase(actionId)); } } } } else { if (_log.isDebugEnabled()) { _log.debug("Unable to obtain resource actions for unknown portlet " + name); } } return actions; }
@Before public void setUp() throws Exception { VelocityEngineConfiguration _velocityEngineConfiguration = Configurable.createConfigurable(VelocityEngineConfiguration.class, Collections.emptyMap()); _templateContextHelper = new MockTemplateContextHelper(); _velocityEngine = new VelocityEngine(); boolean cacheEnabled = false; ExtendedProperties extendedProperties = new FastExtendedProperties(); extendedProperties.setProperty( VelocityEngine.DIRECTIVE_IF_TOSTRING_NULLCHECK, String.valueOf(_velocityEngineConfiguration.directiveIfToStringNullCheck())); extendedProperties.setProperty( VelocityEngine.EVENTHANDLER_METHODEXCEPTION, LiferayMethodExceptionEventHandler.class.getName()); extendedProperties.setProperty( RuntimeConstants.INTROSPECTOR_RESTRICT_CLASSES, StringUtil.merge(_velocityEngineConfiguration.restrictedClasses())); extendedProperties.setProperty( RuntimeConstants.INTROSPECTOR_RESTRICT_PACKAGES, StringUtil.merge(_velocityEngineConfiguration.restrictedPackages())); extendedProperties.setProperty(VelocityEngine.RESOURCE_LOADER, "liferay"); extendedProperties.setProperty( "liferay." + VelocityEngine.RESOURCE_LOADER + ".cache", String.valueOf(cacheEnabled)); extendedProperties.setProperty( "liferay." + VelocityEngine.RESOURCE_LOADER + ".resourceModificationCheckInterval", _velocityEngineConfiguration.resourceModificationCheckInterval() + ""); extendedProperties.setProperty( "liferay." + VelocityEngine.RESOURCE_LOADER + ".class", LiferayResourceLoader.class.getName()); extendedProperties.setProperty( VelocityEngine.RESOURCE_MANAGER_CLASS, LiferayResourceManager.class.getName()); extendedProperties.setProperty( "liferay." + VelocityEngine.RESOURCE_MANAGER_CLASS + ".resourceModificationCheckInterval", _velocityEngineConfiguration.resourceModificationCheckInterval() + ""); extendedProperties.setProperty( VelocityTemplateResourceLoader.class.getName(), _templateResourceLoader); extendedProperties.setProperty( VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, _velocityEngineConfiguration.logger()); extendedProperties.setProperty( VelocityEngine.RUNTIME_LOG_LOGSYSTEM + ".log4j.category", _velocityEngineConfiguration.loggerCategory()); extendedProperties.setProperty( RuntimeConstants.UBERSPECT_CLASSNAME, SecureUberspector.class.getName()); extendedProperties.setProperty( VelocityEngine.VM_LIBRARY, StringUtil.merge(_velocityEngineConfiguration.velocimacroLibrary())); extendedProperties.setProperty( VelocityEngine.VM_LIBRARY_AUTORELOAD, String.valueOf(!cacheEnabled)); extendedProperties.setProperty( VelocityEngine.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, String.valueOf(!cacheEnabled)); _velocityEngine.setExtendedProperties(extendedProperties); _velocityEngine.init(); }
public void editRoleAssignments(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long roleId = ParamUtil.getLong(actionRequest, "roleId"); Role role = RoleLocalServiceUtil.getRole(roleId); if (role.getName().equals(RoleConstants.OWNER)) { throw new RoleAssignmentException(role.getName()); } long[] addUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "addUserIds"), 0L); long[] removeUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeUserIds"), 0L); if (!ArrayUtil.isEmpty(addUserIds) || !ArrayUtil.isEmpty(removeUserIds)) { UserServiceUtil.addRoleUsers(roleId, addUserIds); UserServiceUtil.unsetRoleUsers(roleId, removeUserIds); } long[] addGroupIds = StringUtil.split(ParamUtil.getString(actionRequest, "addGroupIds"), 0L); long[] removeGroupIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeGroupIds"), 0L); if (!ArrayUtil.isEmpty(addGroupIds) || !ArrayUtil.isEmpty(removeGroupIds)) { GroupServiceUtil.addRoleGroups(roleId, addGroupIds); GroupServiceUtil.unsetRoleGroups(roleId, removeGroupIds); } }
public int compare(DDLRecordVersion recordVersion1, DDLRecordVersion recordVersion2) { int value = 0; String version1 = recordVersion1.getVersion(); String version2 = recordVersion2.getVersion(); int[] versionParts1 = StringUtil.split(version1, StringPool.PERIOD, 0); int[] versionParts2 = StringUtil.split(version2, StringPool.PERIOD, 0); if ((versionParts1.length != 2) && (versionParts2.length != 2)) { value = 0; } else if (versionParts1.length != 2) { value = -1; } else if (versionParts2.length != 2) { value = 1; } else if (versionParts1[0] > versionParts2[0]) { value = 1; } else if (versionParts1[0] < versionParts2[0]) { value = -1; } else if (versionParts1[1] > versionParts2[1]) { value = 1; } else if (versionParts1[1] < versionParts2[1]) { value = -1; } if (_ascending) { return value; } else { return -value; } }
@Test public void testUserGroupMemberRule() throws Exception { ServiceContext serviceContext = ServiceTestUtil.getServiceContext(); AnonymousUser anonymousUser = _anonymousUserLocalService.addAnonymousUser( TestPropsValues.getUserId(), "127.0.0.1", StringPool.BLANK, serviceContext); Rule rule = _rulesRegistry.getRule("UserGroupMemberRule"); UserGroup userGroup = UserGroupLocalServiceUtil.addUserGroup( TestPropsValues.getUserId(), TestPropsValues.getCompanyId(), StringUtil.randomString(), StringUtil.randomString(), new ServiceContext()); UserGroupLocalServiceUtil.addUserUserGroup( TestPropsValues.getUserId(), userGroup.getUserGroupId()); RuleInstance ruleInstance = _ruleInstanceLocalService.addRuleInstance( TestPropsValues.getUserId(), rule.getRuleKey(), 0, String.valueOf(userGroup.getUserGroupId()), serviceContext); Assert.assertTrue(rule.evaluate(null, ruleInstance, anonymousUser)); }
protected List<String> getFieldNames( String fieldNamespace, String fieldName, ServiceContext serviceContext) { String[] fieldsDisplayValues = StringUtil.split( (String) serviceContext.getAttribute(fieldNamespace + FIELDS_DISPLAY_NAME)); List<String> privateFieldNames = ListUtil.fromArray(new String[] {FIELDS_DISPLAY_NAME}); List<String> fieldNames = new ArrayList<>(); if ((fieldsDisplayValues.length == 0) || privateFieldNames.contains(fieldName)) { fieldNames.add(fieldNamespace + fieldName); } else { for (String namespacedFieldName : fieldsDisplayValues) { String fieldNameValue = StringUtil.extractFirst(namespacedFieldName, INSTANCE_SEPARATOR); if (fieldNameValue.equals(fieldName)) { fieldNames.add(fieldNamespace + namespacedFieldName); } } } return fieldNames; }
public void execute() throws BuildException { try { InetAddress localHost = InetAddress.getLocalHost(); if (Validator.isNotNull(_hostAddressProperty)) { getProject().setUserProperty(_hostAddressProperty, localHost.getHostAddress()); } if (Validator.isNotNull(_hostNameProperty)) { getProject().setUserProperty(_hostNameProperty, localHost.getHostName()); } if (Validator.isNotNull(_vmId1Property)) { int id = GetterUtil.getInteger(StringUtil.extractDigits(localHost.getHostName())); getProject().setUserProperty(_vmId1Property, String.valueOf((id * 2) - 1)); } if (Validator.isNotNull(_vmId2Property)) { int id = GetterUtil.getInteger(StringUtil.extractDigits(localHost.getHostName())); getProject().setUserProperty(_vmId2Property, String.valueOf((id * 2))); } } catch (UnknownHostException uhe) { throw new BuildException(uhe); } }
@Before public void setUp() throws Exception { ServiceTestUtil.setUser(TestPropsValues.getUser()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); _repository = RepositoryLocalServiceUtil.addRepository( TestPropsValues.getUserId(), TestPropsValues.getGroupId(), ClassNameLocalServiceUtil.getClassNameId(_REPOSITORY_CLASS_NAME), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), new UnicodeProperties(), true, serviceContext); _repositoryEntry = RepositoryEntryLocalServiceUtil.createRepositoryEntry(_repository.getDlFolderId()); _repositoryEntry.setUuid(serviceContext.getUuid()); _repositoryEntry.setGroupId(serviceContext.getScopeGroupId()); _repositoryEntry.setCompanyId(serviceContext.getCompanyId()); _repositoryEntry.setUserId(serviceContext.getUserId()); _repositoryEntry.setUserName(StringUtil.randomString()); _repositoryEntry.setCreateDate(serviceContext.getCreateDate(null)); _repositoryEntry.setModifiedDate(serviceContext.getModifiedDate(null)); _repositoryEntry.setRepositoryId(_repository.getRepositoryId()); _repositoryEntry.setMappedId(_MAPPED_ID); RepositoryEntryLocalServiceUtil.addRepositoryEntry(_repositoryEntry); }
protected String trimLine(String line, boolean allowLeadingSpaces) { if (line.trim().length() == 0) { return StringPool.BLANK; } line = StringUtil.trimTrailing(line); if (allowLeadingSpaces || !line.startsWith(StringPool.SPACE) || line.startsWith(" *")) { return line; } if (!line.startsWith(StringPool.FOUR_SPACES)) { while (line.startsWith(StringPool.SPACE)) { line = StringUtil.replaceFirst(line, StringPool.SPACE, StringPool.BLANK); } } else { int pos = 0; String temp = line; while (temp.startsWith(StringPool.FOUR_SPACES)) { line = StringUtil.replaceFirst(line, StringPool.FOUR_SPACES, StringPool.TAB); pos++; temp = line.substring(pos); } } return line; }
public List<Group> getMySites(String[] classNames, boolean includeControlPanel, int max) throws PortalException, SystemException { ThreadLocalCache<List<Group>> threadLocalCache = ThreadLocalCacheManager.getThreadLocalCache(Lifecycle.REQUEST, UserImpl.class.getName()); String key = StringUtil.toHexString(max); if ((classNames != null) && (classNames.length > 0)) { key = StringUtil.merge(classNames).concat(StringPool.POUND).concat(key); } key = key.concat(StringPool.POUND).concat(String.valueOf(includeControlPanel)); List<Group> myPlaces = threadLocalCache.get(key); if (myPlaces != null) { return myPlaces; } myPlaces = GroupServiceUtil.getUserPlaces(getUserId(), classNames, includeControlPanel, max); threadLocalCache.put(key, myPlaces); return myPlaces; }
protected boolean hasRedundantParentheses(String s, String operator1, String operator2) { String[] parts = StringUtil.split(s, operator1); if (parts.length < 3) { return false; } for (int i = 1; i < (parts.length - 1); i++) { String part = parts[i]; if (part.contains(operator2) || part.contains("!(")) { continue; } int closeParenthesesCount = StringUtil.count(part, StringPool.CLOSE_PARENTHESIS); int openParenthesesCount = StringUtil.count(part, StringPool.OPEN_PARENTHESIS); if (Math.abs(closeParenthesesCount - openParenthesesCount) == 1) { return true; } } return false; }
@Override protected String getTitle( JSONObject jsonObject, AssetRenderer<?> assetRenderer, ServiceContext serviceContext) { MBMessage mbMessage = MBMessageLocalServiceUtil.fetchMBMessage(jsonObject.getLong("classPK")); AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName( assetRenderer.getClassName()); String typeName = assetRendererFactory.getTypeName(serviceContext.getLocale()); ResourceBundle resourceBundle = ResourceBundle.getBundle("content.Language", serviceContext.getLocale()); if ((mbMessage != null) && mbMessage.isDiscussion()) { return LanguageUtil.format( resourceBundle, "x-mentioned-you-in-a-comment-in-a-x", new String[] { HtmlUtil.escape(assetRenderer.getUserName()), StringUtil.toLowerCase(HtmlUtil.escape(typeName)) }, false); } else { return LanguageUtil.format( resourceBundle, "x-mentioned-you-in-a-x", new String[] { HtmlUtil.escape(assetRenderer.getUserName()), StringUtil.toLowerCase(HtmlUtil.escape(typeName)) }, false); } }
@Override public boolean hasCompanyMx(String emailAddress) throws SystemException { emailAddress = StringUtil.toLowerCase(emailAddress.trim()); int pos = emailAddress.indexOf(CharPool.AT); if (pos == -1) { return false; } String mx = emailAddress.substring(pos + 1); if (mx.equals(getMx())) { return true; } String[] mailHostNames = PrefsPropsUtil.getStringArray( getCompanyId(), PropsKeys.ADMIN_MAIL_HOST_NAMES, StringPool.NEW_LINE, PropsValues.ADMIN_MAIL_HOST_NAMES); for (int i = 0; i < mailHostNames.length; i++) { if (StringUtil.equalsIgnoreCase(mx, mailHostNames[i])) { return true; } } return false; }
protected boolean consumeHttpResponseHead(DataInput dataInput) throws IOException { String statusLine = dataInput.readLine(); if (!statusLine.equals("HTTP/1.1 200 OK")) { throw new IOException("Error status line: " + statusLine); } boolean forceCloseSocket = false; String line = null; while (((line = dataInput.readLine()) != null) && (line.length() > 0)) { String[] headerKeyValuePair = StringUtil.split(line, CharPool.COLON); String headerName = headerKeyValuePair[0].trim(); headerName = StringUtil.toLowerCase(headerName); if (headerName.equals("connection")) { String headerValue = headerKeyValuePair[1].trim(); headerValue = StringUtil.toLowerCase(headerValue); if (headerValue.equals("close")) { forceCloseSocket = true; } } } return forceCloseSocket; }
@Override public void removeNestedColumns(String portletNamespace) { UnicodeProperties typeSettingsProperties = getTypeSettingsProperties(); UnicodeProperties newTypeSettingsProperties = new UnicodeProperties(); for (Map.Entry<String, String> entry : typeSettingsProperties.entrySet()) { String key = entry.getKey(); if (!key.startsWith(portletNamespace)) { newTypeSettingsProperties.setProperty(key, entry.getValue()); } } Layout layout = getLayout(); layout.setTypeSettingsProperties(newTypeSettingsProperties); String nestedColumnIds = GetterUtil.getString(getTypeSettingsProperty(LayoutTypePortletConstants.NESTED_COLUMN_IDS)); String[] nestedColumnIdsArray = ArrayUtil.removeByPrefix(StringUtil.split(nestedColumnIds), portletNamespace); setTypeSettingsProperty( LayoutTypePortletConstants.NESTED_COLUMN_IDS, StringUtil.merge(nestedColumnIdsArray)); }
public PortletURL getPortletURL() throws PortalException { PortletURL portletURL = _liferayPortletResponse.createRenderURL(); User selUser = PortalUtil.getSelectedUser(_request); if (selUser != null) { portletURL.setParameter("p_u_i_d", String.valueOf(selUser.getUserId())); } long[] selectedGroupIds = StringUtil.split(ParamUtil.getString(_request, "selectedGroupIds"), 0L); boolean includeCompany = ParamUtil.getBoolean(_request, "includeCompany"); boolean includeCurrentGroup = ParamUtil.getBoolean(_request, "includeCurrentGroup", true); boolean includeUserPersonalSite = ParamUtil.getBoolean(_request, "includeUserPersonalSite"); String eventName = ParamUtil.getString( _request, "eventName", _liferayPortletResponse.getNamespace() + "selectSite"); String target = ParamUtil.getString(_request, "target"); portletURL.setParameter("groupId", String.valueOf(getGroupId())); portletURL.setParameter("selectedGroupIds", StringUtil.merge(selectedGroupIds)); portletURL.setParameter("type", getType()); portletURL.setParameter("types", getTypes()); portletURL.setParameter("displayStyle", getDisplayStyle()); portletURL.setParameter("filter", getFilter()); portletURL.setParameter("includeCompany", String.valueOf(includeCompany)); portletURL.setParameter("includeCurrentGroup", String.valueOf(includeCurrentGroup)); portletURL.setParameter("includeUserPersonalSite", String.valueOf(includeUserPersonalSite)); portletURL.setParameter("manualMembership", String.valueOf(isManualMembership())); portletURL.setParameter("eventName", eventName); portletURL.setParameter("target", target); return portletURL; }
public void updateKBArticlesPriorities(Map<Long, Double> resourcePrimKeyToPriorityMap) throws PortalException, SystemException { for (double priority : resourcePrimKeyToPriorityMap.values()) { validate(priority); } long[] resourcePrimKeys = StringUtil.split(StringUtil.merge(resourcePrimKeyToPriorityMap.keySet()), 0L); List<KBArticle> kbArticles1 = getKBArticles(resourcePrimKeys, WorkflowConstants.STATUS_ANY, null); for (KBArticle kbArticle1 : kbArticles1) { double priority = resourcePrimKeyToPriorityMap.get(kbArticle1.getResourcePrimKey()); List<KBArticle> kbArticles2 = getKBArticleVersions( kbArticle1.getResourcePrimKey(), WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); for (KBArticle kbArticle2 : kbArticles2) { kbArticle2.setPriority(priority); kbArticlePersistence.update(kbArticle2, false); } } }
protected long getParentMessageId(String recipient, Message message) throws Exception { if (!StringUtil.startsWith(recipient, MBUtil.MESSAGE_POP_PORTLET_PREFIX)) { return MBUtil.getParentMessageId(message); } int pos = recipient.indexOf(CharPool.AT); if (pos < 0) { return MBUtil.getParentMessageId(message); } String target = recipient.substring(MBUtil.MESSAGE_POP_PORTLET_PREFIX.length(), pos); String[] parts = StringUtil.split(target, StringPool.PERIOD); long parentMessageId = 0; if (parts.length == 2) { parentMessageId = GetterUtil.getLong(parts[1]); } if (parentMessageId > 0) { return parentMessageId; } return MBUtil.getParentMessageId(message); }