当前位置: 首页>>代码示例>>Java>>正文


Java URLEncoder.encode方法代码示例

本文整理汇总了Java中org.springframework.extensions.surf.util.URLEncoder.encode方法的典型用法代码示例。如果您正苦于以下问题:Java URLEncoder.encode方法的具体用法?Java URLEncoder.encode怎么用?Java URLEncoder.encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.extensions.surf.util.URLEncoder的用法示例。


在下文中一共展示了URLEncoder.encode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkJsonEvent

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
private void checkJsonEvent(PublishingEvent event, JSONObject json) throws Exception
{
    String url = "api/publishing/events/" + URLEncoder.encode(event.getId());
    assertEquals(url, json.getString(URL));
    
    assertEquals(event.getStatus().name(), json.getString(STATUS));
    
    assertEquals(event.getComment(), json.optString(COMMENT));
    checkCalendar(event.getScheduledTime(), json.optJSONObject(SCHEDULED_TIME));
    assertEquals(event.getCreator(), json.getString(CREATOR));
    checkDate(event.getCreatedTime(), json.getJSONObject(CREATED_TIME));
    
    PublishingPackage pckg = event.getPackage();
    checkContainsNodes(pckg, json.getJSONArray(PUBLISH_NODES), true);
    checkContainsNodes(pckg, json.getJSONArray(UNPUBLISH_NODES), false);
    
    Channel channel = channelService.getChannelById(event.getChannelId());
    checkChannel(json.getJSONObject(CHANNEL), channel);
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:20,代码来源:PublishingRestApiTest.java

示例2: checkChannelType

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
private void checkChannelType(JSONObject jsonType, ChannelType channelType) throws Exception
{
    check(ID, jsonType, channelType.getId());
    check(TITLE, jsonType, channelType.getId());
    
    String expUrl = "api/publishing/channel-types/"+URLEncoder.encode(channelType.getId());
    check(URL, jsonType, expUrl);
    check(CHANNEL_NODE_TYPE, jsonType, channelType.getChannelNodeType().toString());
    
    List<String> contentTypes = CollectionUtils.toListOfStrings(channelType.getSupportedContentTypes());
    checkStrings(jsonType.getJSONArray(SUPPORTED_CONTENT_TYPES), contentTypes);
    checkStrings(jsonType.getJSONArray(SUPPORTED_MIME_TYPES), channelType.getSupportedMimeTypes());
    
    check(CAN_PUBLISH, jsonType, channelType.canPublish());
    check(CAN_PUBLISH_STATUS_UPDATES, jsonType, channelType.canPublishStatusUpdates());
    check(CAN_UNPUBLISH, jsonType, channelType.canUnpublish());
    check(MAX_STATUS_LENGTH, jsonType, channelType.getMaximumStatusLength());

    //TODO Implement Icon URL
    check(ICON, jsonType, expUrl + "/icon");
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:22,代码来源:PublishingRestApiTest.java

示例3: startInvite

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
private JSONObject startInvite(String inviteeFirstName, String inviteeLastName, String inviteeEmail, String inviteeSiteRole,
        String siteShortName, int expectedStatus)
        throws Exception
{
    this.inviteeEmailAddrs.add(inviteeEmail);

    // Inviter sends invitation to Invitee to join a Site
    String startInviteUrl = URL_INVITE + "/" + INVITE_ACTION_START
            + "?inviteeFirstName=" + inviteeFirstName + "&inviteeLastName="
            + inviteeLastName + "&inviteeEmail="
            + URLEncoder.encode(inviteeEmail) + "&siteShortName="
            + siteShortName + "&inviteeSiteRole=" + inviteeSiteRole
            + "&serverPath=" + "http://localhost:8081/share/"
            + "&acceptUrl=" + "page/accept-invite"
            + "&rejectUrl=" + "page/reject-invite";

    Response response = sendRequest(new GetRequest(startInviteUrl), expectedStatus);

    JSONObject result = new JSONObject(response.getContentAsString());

    return result;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:23,代码来源:InviteServiceTest.java

示例4: Person

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
public Person(String name)
{
    this.name = name;
    String encName = URLEncoder.encode(name);
    this.email = encName + "@test.com";
    this.node = new NodeRef(testStore, encName);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:InviteSenderTest.java

示例5: setAttachment

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
/**
 * Set attachment header
 * 
 * @param req WebScriptRequest
 * @param res WebScriptResponse
 * @param attach boolean
 * @param attachFileName String
 */
public void setAttachment(WebScriptRequest req, WebScriptResponse res, boolean attach, String attachFileName)
{
    if (attach == true)
    {
        String headerValue = "attachment";
        if (attachFileName != null && attachFileName.length() > 0)
        {
            if (logger.isDebugEnabled())
                logger.debug("Attaching content using filename: " + attachFileName);

            if (req == null)
            {
                headerValue += "; filename*=UTF-8''" + URLEncoder.encode(attachFileName)
                        + "; filename=\"" + filterNameForQuotedString(attachFileName) + "\"";
            }
            else
            {
                String userAgent = req.getHeader(HEADER_USER_AGENT);
                boolean isLegacy = (null != userAgent) && (userAgent.contains("MSIE 8") || userAgent.contains("MSIE 7"));
                if (isLegacy)
                {
                    headerValue += "; filename=\"" + URLEncoder.encode(attachFileName);
                }
                else
                {
                    headerValue += "; filename=\"" + filterNameForQuotedString(attachFileName) + "\"; filename*=UTF-8''"
                            + URLEncoder.encode(attachFileName);
                }
            }
        }
        
        // set header based on filename - will force a Save As from the browse if it doesn't recognize it
        // this is better than the default response of the browser trying to display the contents
        res.setHeader("Content-Disposition", headerValue);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:45,代码来源:ContentStreamer.java

示例6: testXPathNodeLocator

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
public void testXPathNodeLocator() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    NodeRef first = makeChildFolderNode(companyHome);
    try
    {
        NodeRef second = makeChildFolderNode(first);
        NodeRef content = makeChildContentNode(second);
        
        // Check bad path returns null
        String badPath = URLEncoder.encode("cm:foo/cm:bar/cm:foobar");
        String badPathUrl = baseURL + XPathNodeLocator.NAME + "?query=" + badPath;
        checkNodeLocator(badPathUrl, null);
        
        String path  = nodeService.getPath(content).toPrefixString(namespaceService);
        String encodedPath = URLEncoder.encode(path);
        
        // Check default store ref works.
        String defaultStoreUrl = baseURL + XPathNodeLocator.NAME + "?query=" +encodedPath;
        checkNodeLocator(defaultStoreUrl, content);
        
        // Check specified store ref works.
        String storeIdUrl = defaultStoreUrl + "&store_type=workspace&store_id=SpacesStore";
        checkNodeLocator(storeIdUrl, content);
        
        // Check node store ref works.
        String nodePathUrl = makeUrl(companyHome, XPathNodeLocator.NAME) + "?query=" + encodedPath;
        checkNodeLocator(nodePathUrl, content);
    }
    finally
    {
        nodeService.deleteNode(first);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:35,代码来源:NodeLocatorWebScriptTest.java

示例7: setAttachment

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
/**
 * Set attachment header
 * 
 * @param req WebScriptRequest
 * @param res WebScriptResponse
 * @param attach boolean
 * @param attachFileName String
 */
public void setAttachment(WebScriptRequest req, WebScriptResponse res, boolean attach, String attachFileName)
{
    if (attach == true)
    {
        String headerValue = "attachment";
        if (attachFileName != null && attachFileName.length() > 0)
        {
            if (logger.isDebugEnabled())
                logger.debug("Attaching content using filename: " + attachFileName);

            if (req == null)
            {
                headerValue += "; filename*=UTF-8''" + URLEncoder.encode(attachFileName)
                        + "; filename=\"" + attachFileName + "\"";
            }
            else
            {
                String userAgent = req.getHeader(HEADER_USER_AGENT);
                boolean isLegacy = (null != userAgent) && (userAgent.contains("MSIE 8") || userAgent.contains("MSIE 7"));
                if (isLegacy)
                {
                    headerValue += "; filename=\"" + URLEncoder.encode(attachFileName);
                }
                else
                {
                    headerValue += "; filename=\"" + attachFileName + "\"; filename*=UTF-8''"
                            + URLEncoder.encode(attachFileName);
                }
            }
        }
        
        // set header based on filename - will force a Save As from the browse if it doesn't recognize it
        // this is better than the default response of the browser trying to display the contents
        res.setHeader("Content-Disposition", headerValue);
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:45,代码来源:ContentStreamer.java

示例8: getRequestAttributes

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
@Override
protected String getRequestAttributes()
{
   String mimetypes = getMimetypes();
   if (mimetypes != null)
   {
      return "mimetypes=" + URLEncoder.encode(mimetypes);
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:14,代码来源:UIAjaxFilePicker.java

示例9: encodeURL

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
public final static String encodeURL(String s, String userAgent)
{
      return URLEncoder.encode(s);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:5,代码来源:WebDAVHelper.java

示例10: encodeUrlReservedSymbols

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
/**
 * ALF-5333: Microsoft clients use ISO-8859-1 to decode WebDAV responses
 * so this method should only be used for Microsoft user agents.
 * 
 * @param string String
 * @return The encoded string for Microsoft clients
 * @throws UnsupportedEncodingException
 */
public final static String encodeUrlReservedSymbols(String string) throws UnsupportedEncodingException
{
    if (string == null)
    {
        return "";
    }
    
    StringBuilder sb = null;      // create on demand
    String enc;
    char c;
    for (int i = 0; i < string.length(); i++)
    {
        enc = null;
        c = string.charAt(i);
        switch (c)
        {
            // reserved
            case ';': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '/': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '?': enc = URLEncoder.encode(String.valueOf(c)); break;
            case ':': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '@': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '&': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '=': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '+': enc = URLEncoder.encode(String.valueOf(c)); break;
            
            // unsafe
            case '\"': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '#': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '%': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '>': enc = URLEncoder.encode(String.valueOf(c)); break;
            case '<': enc = URLEncoder.encode(String.valueOf(c)); break;
            default: break;
        }
        
        if (enc != null)
        {
            if (sb == null)
            {
                String soFar = string.substring(0, i);
                sb = new StringBuilder(i + 8);
                sb.append(soFar);
            }
            sb.append(enc);
        }
        else
        {
            if (sb != null)
            {
                sb.append(c);
            }
        }
    }
    
    if (sb == null)
    {
        return string;
    }
    else
    {
        return sb.toString();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:72,代码来源:WebDAVHelper.java

示例11: testAncestorOfTypeNodeLocator

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
public void testAncestorOfTypeNodeLocator() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    NodeRef folder= makeChildFolderNode(companyHome);
    try
    {
        NodeRef sysFolder = makeChildSystemFolderNode(folder);
        NodeRef subFolder = makeChildFolderNode(sysFolder);
        NodeRef source = makeChildContentNode(subFolder);
        
        // No params so should find first parent.
        String ancestorUrl = makeUrl(source, AncestorNodeLocator.NAME);
        checkNodeLocator(ancestorUrl, subFolder);
        
        // Set type to cm:content. Should not match any node.
        String encodedContentType = URLEncoder.encode(ContentModel.TYPE_CONTENT.toPrefixString(namespaceService));
        String contentAncestorUrl = ancestorUrl + "?type=" + encodedContentType;
        checkNodeLocator(contentAncestorUrl, null);
        
        // Set type to cm:systemfolder. Should find the sysFolder node.
        String encodedSysFolderType = URLEncoder.encode(ContentModel.TYPE_SYSTEM_FOLDER.toPrefixString(namespaceService));
        String sysFolderAncestorUrl = ancestorUrl + "?type=" + encodedSysFolderType;
        checkNodeLocator(sysFolderAncestorUrl, sysFolder);
        
        // Set aspect to cm:ownable. Should not match any node.
        String encodedOwnableAspect= URLEncoder.encode(ContentModel.ASPECT_OWNABLE.toPrefixString(namespaceService));
        String ownableAncestorUrl = ancestorUrl + "?aspect=" + encodedOwnableAspect;
        checkNodeLocator(ownableAncestorUrl, null);
        
        // Add ownable aspect to folder node. Now that node should be found.
        nodeService.addAspect(folder, ContentModel.ASPECT_OWNABLE, null);
        checkNodeLocator(ownableAncestorUrl, folder);

        // Set aspect to cm:ownable and type to cm:systemfolder. Should not match any node.
        String ownableSysFolderAncestorUrl = sysFolderAncestorUrl + "&aspect=" + encodedOwnableAspect;
        checkNodeLocator(ownableSysFolderAncestorUrl, null);
        
        // Set aspect to cm:ownable and type to cm:folder. Should find folder node.
        String encodedFOlderType = URLEncoder.encode(ContentModel.TYPE_FOLDER.toPrefixString(namespaceService));
        String ownableFolderAncestorUrl = ownableAncestorUrl + "&type=" + encodedFOlderType;
        checkNodeLocator(ownableFolderAncestorUrl, folder);
    }
    finally
    {
        nodeService.deleteNode(folder);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:48,代码来源:NodeLocatorWebScriptTest.java

示例12: getUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
public static String getUrl(PublishingEvent event)
{
    return "api/publishing/events/"+URLEncoder.encode(event.getId());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:5,代码来源:PublishingModelBuilder.java

示例13: encodeURL

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
public final static String encodeURL(String s, String userAgent)
{
	return URLEncoder.encode(s);
}
 
开发者ID:to2y,项目名称:AlfrescoOnlineEditWebDAV,代码行数:5,代码来源:WebDAVHelper.java

示例14: encodeUrlReservedSymbols

import org.springframework.extensions.surf.util.URLEncoder; //导入方法依赖的package包/类
/**
 * ALF-5333: Microsoft clients use ISO-8859-1 to decode WebDAV responses
 * so this method should only be used for Microsoft user agents.
 * 
 * @param string
 * @return The encoded string for Microsoft clients
 * @throws UnsupportedEncodingException
 */
public final static String encodeUrlReservedSymbols(String string) throws UnsupportedEncodingException
{
	if (string == null)
	{
		return "";
	}

	StringBuilder sb = null;      // create on demand
	String enc;
	char c;
	for (int i = 0; i < string.length(); i++)
	{
		enc = null;
		c = string.charAt(i);
		switch (c)
		{
		// reserved
		case ';': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '/': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '?': enc = URLEncoder.encode(String.valueOf(c)); break;
		case ':': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '@': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '&': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '=': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '+': enc = URLEncoder.encode(String.valueOf(c)); break;

		// unsafe
		case '\"': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '#': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '%': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '>': enc = URLEncoder.encode(String.valueOf(c)); break;
		case '<': enc = URLEncoder.encode(String.valueOf(c)); break;
		default: break;
		}

		if (enc != null)
		{
			if (sb == null)
			{
				String soFar = string.substring(0, i);
				sb = new StringBuilder(i + 8);
				sb.append(soFar);
			}
			sb.append(enc);
		}
		else
		{
			if (sb != null)
			{
				sb.append(c);
			}
		}
	}

	if (sb == null)
	{
		return string;
	}
	else
	{
		return sb.toString();
	}
}
 
开发者ID:to2y,项目名称:AlfrescoOnlineEditWebDAV,代码行数:72,代码来源:WebDAVHelper.java


注:本文中的org.springframework.extensions.surf.util.URLEncoder.encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。