本文整理汇总了Java中org.springframework.extensions.surf.util.URLEncoder类的典型用法代码示例。如果您正苦于以下问题:Java URLEncoder类的具体用法?Java URLEncoder怎么用?Java URLEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
URLEncoder类属于org.springframework.extensions.surf.util包,在下文中一共展示了URLEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDownloadAPIUrl
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
* @param node the node to construct the download URL for
* @return For a content document, this method returns the URL to the /api/node/content
* API for the default content property
* <p>
* For a container node, this method returns an empty string
* </p>
*/
public String getDownloadAPIUrl(ScriptNode node)
{
if (node.getIsDocument())
{
return MessageFormat.format(CONTENT_DOWNLOAD_API_URL, new Object[]{
node.nodeRef.getStoreRef().getProtocol(),
node.nodeRef.getStoreRef().getIdentifier(),
node.nodeRef.getId(),
URLEncoder.encode(node.getName())});
}
else
{
return "";
}
}
示例2: getDownloadUrl
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
* @return For a content document, this method returns the download URL to the content for
* the default content property (@see ContentModel.PROP_CONTENT)
* <p>
* For a container node, this method returns an empty string
*/
public String getDownloadUrl()
{
if (getIsDocument() == true)
{
return MessageFormat.format(CONTENT_DOWNLOAD_URL, new Object[] {
nodeRef.getStoreRef().getProtocol(),
nodeRef.getStoreRef().getIdentifier(),
nodeRef.getId(),
URLEncoder.encode(getName()) });
}
else
{
return "";
}
}
示例3: getContentDispositionHeader
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
protected String getContentDispositionHeader(FileInfo nodeInfo)
{
String filename = nodeInfo.getName();
StringBuilder sb = new StringBuilder();
sb.append("attachment; filename=\"");
for(int i = 0; i < filename.length(); i++)
{
char c = filename.charAt(i);
if(isValidQuotedStringHeaderParamChar(c))
{
sb.append(c);
}
else
{
sb.append(" ");
}
}
sb.append("\"; filename*=UTF-8''");
sb.append(URLEncoder.encode(filename));
return sb.toString();
}
示例4: encode
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
* <p>
* encode string to share specific manner (all characters with code > 127 will be encoded in %u0... format)
* </p>
*
* @param value to encode
* @return encoded value
* @throws UnsupportedEncodingException
*/
public static String encode(String value) throws UnsupportedEncodingException
{
StringBuilder result = new StringBuilder(value.length());
for (int i = 0; i < value.length(); i++)
{
char c = value.charAt(i);
if (c > 127)
{
result.append("%u0" + Integer.toHexString(c).toUpperCase());
}
else
{
if (c > 'a' && c < 'z' || c > 'A' && c < 'Z' || c == '/' || c == '@' || c == '+')
{
result.append(c);
}
else
{
result.append(URLEncoder.encode(c + ""));
}
}
}
return result.toString();
}
示例5: testChannelPut
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
public void testChannelPut() throws Exception
{
Channel channel1 = testHelper.createChannel(publishAnyType);
Channel channel2 = testHelper.createChannel(publishAnyType);
String name1 = channel1.getName();
String name2 = channel2.getName();
String newName = name1 + "Foo";
JSONObject json = new JSONObject();
json.put(NAME, newName);
String jsonStr = json.toString();
String channel1Url = MessageFormat.format(CHANNEL_URL, URLEncoder.encode(channel1.getId()));
// Post JSON content.
sendRequest(new PutRequest(channel1Url, jsonStr, JSON), 200);
Channel renamedCH1 = channelService.getChannelById(channel1.getId());
assertEquals("Channel1 was not renamed correctly!", newName, renamedCH1.getName());
Channel renamedCH2 = channelService.getChannelById(channel2.getId());
assertEquals("Channel2 name should not have changed!", name2, renamedCH2.getName());
}
示例6: 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);
}
示例7: 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");
}
示例8: 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;
}
示例9: testJobWithSpace
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
public void testJobWithSpace() throws Exception
{
String userName = RandomStringUtils.randomNumeric(6);
String userJob = "myJob" + RandomStringUtils.randomNumeric(2) + " myJob" + RandomStringUtils.randomNumeric(3);
//we need to ecape a spaces for search
String jobSearchString = userJob.replace(" ", "\\ ");
createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
userJob, "[email protected]", "myBio", "images/avatar.jpg",
Status.STATUS_OK);
// Get a person
Response response = sendRequest(new GetRequest(URL_PEOPLE + "?filter=" + URLEncoder.encode("jobtitle:" + jobSearchString)), 200);
JSONObject res = new JSONObject(response.getContentAsString());
assertEquals(1, res.getJSONArray("people").length());
response = sendRequest(new GetRequest(URL_PEOPLE + "?filter=" + URLEncoder.encode("jobtitle:" + userJob)), 200);
res = new JSONObject(response.getContentAsString());
assertEquals(0, res.getJSONArray("people").length());
}
示例10: getWebdavUrl
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
* Get the WebDavUrl for the specified nodeRef
*
* @param nodeRef the node that the webdav URL (or null)
* @return the URL of the node in webdav or "" if a URL cannot be built.
*/
public String getWebdavUrl(NodeRef nodeRef)
{
String url = "";
if (!enabled)
{
return url;
}
try
{
QName typeName = nodeService.getType(nodeRef);
if (getIsContainer(typeName) || getIsDocument(typeName))
{
List<String> paths = fileFolderService.getNameOnlyPath(getRootNode().getNodeForCurrentTenant(), nodeRef);
// build up the webdav url
StringBuilder path = new StringBuilder(128);
path.append("/" + WEBDAV_PREFIX);
for (int i=0; i<paths.size(); i++)
{
path.append("/")
.append(URLEncoder.encode(paths.get(i)));
}
url = path.toString();
}
}
catch (InvalidTypeException typeErr)
{
// cannot build path if file is a type such as a rendition
}
catch (FileNotFoundException nodeErr)
{
// cannot build path if file no longer exists, return default
}
return url;
}
示例11: getUrl
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
* @return For a content document, this method returns the URL to the content stream for the default content
* property (@see ContentModel.PROP_CONTENT)
* <p>
* For a container node, this method return the URL to browse to the folder in the web-client
*/
public String getUrl()
{
if (getIsDocument() == true)
{
return MessageFormat.format(CONTENT_DEFAULT_URL, new Object[] { nodeRef.getStoreRef().getProtocol(),
nodeRef.getStoreRef().getIdentifier(), nodeRef.getId(),
URLEncoder.encode(getName())});
}
else
{
return MessageFormat.format(FOLDER_BROWSE_URL, new Object[] { nodeRef.getStoreRef().getProtocol(),
nodeRef.getStoreRef().getIdentifier(), nodeRef.getId() });
}
}
示例12: getWebdavUrl
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
* @return The WebDav cm:name based path to the content for the default content property
* (@see ContentModel.PROP_CONTENT)
*/
public String getWebdavUrl()
{
String url = "";
try
{
if (getIsContainer() || getIsDocument())
{
List<String> paths = this.services.getFileFolderService().getNameOnlyPath(null, getNodeRef());
// build up the webdav url
StringBuilder path = new StringBuilder(128);
path.append("/webdav");
// build up the path skipping the first path as it is the root folder
for (int i=1; i<paths.size(); i++)
{
path.append("/")
.append(URLEncoder.encode(paths.get(i)));
}
url = path.toString();
}
}
catch (InvalidTypeException typeErr)
{
// cannot build path if file is a type such as a rendition
}
catch (FileNotFoundException nodeErr)
{
// cannot build path if file no longer exists
}
return url;
}
示例13: buildUrlParamString
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private String buildUrlParamString(Map<String, String> properties)
{
StringBuilder params = new StringBuilder("?inviteId=");
params.append(properties.get(WF_INSTANCE_ID));
params.append("&inviteeUserName=");
params.append(URLEncoder.encode(properties.get(wfVarInviteeUserName)));
params.append("&siteShortName=");
params.append(properties.get(wfVarResourceName));
params.append("&inviteTicket=");
params.append(properties.get(wfVarInviteTicket));
return params.toString();
}
示例14: getUrl
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
* @return Returns the URL to the content stream for the frozen state of the node from
* the default content property (@see ContentModel.PROP_CONTENT)
*/
@Override
public String getUrl()
{
NodeRef nodeRef = this.version.getFrozenStateNodeRef();
return MessageFormat.format(parent.CONTENT_GET_URL, new Object[] {
nodeRef.getStoreRef().getProtocol(),
nodeRef.getStoreRef().getIdentifier(),
nodeRef.getId(),
URLEncoder.encode(getName()) } );
}
示例15: buildUrl
import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private String buildUrl(String format)
{
return MessageFormat.format(format, new Object[] {
getNodeRef().getStoreRef().getProtocol(),
getNodeRef().getStoreRef().getIdentifier(),
getNodeRef().getId(),
URLEncoder.encode(getName()) } );
}