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


Java ResponseBuilder.location方法代码示例

本文整理汇总了Java中javax.ws.rs.core.Response.ResponseBuilder.location方法的典型用法代码示例。如果您正苦于以下问题:Java ResponseBuilder.location方法的具体用法?Java ResponseBuilder.location怎么用?Java ResponseBuilder.location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.core.Response.ResponseBuilder的用法示例。


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

示例1: createFolderPost

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
/**
 * @param stagingUuid
 * @param parentFolder May or may not be present. This folder must already
 *            exist.
 * @param folder Mandatory
 * @return
 */
@Override
public Response createFolderPost(String stagingUuid, String parentFolder, GenericFileBean folder)
{
	final StagingFile stagingFile = getStagingFile(stagingUuid);
	ensureFileExists(stagingFile, parentFolder);

	final String filename = folder.getFilename();
	final String newPath = PathUtils.filePath(parentFolder, filename);

	boolean exists = fileSystemService.fileExists(stagingFile, newPath);
	fileSystemService.mkdir(stagingFile, newPath);

	// was: .entity(convertFile(stagingFile, newPath, false))
	ResponseBuilder resp = Response.status(exists ? Status.OK : Status.CREATED);
	if( !exists )
	{
		resp = resp.location(itemLinkService.getFileDirURI(stagingFile, URLUtils.urlEncode(newPath, false)));
	}
	return resp.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:FileResourceImpl.java

示例2: createOrRenameFolder

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
private Response createOrRenameFolder(String stagingUuid, String parentFolder, String oldFoldername,
	String newFoldername)
{
	final StagingFile stagingFile = getStagingFile(stagingUuid);

	final String oldPath = PathUtils.filePath(parentFolder, oldFoldername);
	final String newPath = PathUtils.filePath(parentFolder, newFoldername);
	boolean created = false;

	if( !newFoldername.equals(oldFoldername) )
	{
		// build folder structure if required
		if( !fileSystemService.fileExists(stagingFile, parentFolder) )
		{
			fileSystemService.mkdir(stagingFile, parentFolder);
		}
		fileSystemService.rename(stagingFile, oldPath, newPath);
		created = true;
	}
	else if( !fileSystemService.fileExists(stagingFile, newPath) )
	{
		fileSystemService.mkdir(stagingFile, newPath);
		created = true;
	}
	// else No-op

	// was: .entity(convertFile(stagingFile, newPath, false)
	ResponseBuilder resp = Response.status(created ? Status.CREATED : Status.OK);
	if( created )
	{
		resp = resp.location(itemLinkService.getFileDirURI(stagingFile, URLUtils.urlEncode(newPath, false)));
	}
	return resp.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:FileResourceImpl.java

示例3: uploadOrReplaceFile

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@Override
public Response uploadOrReplaceFile(String stagingUuid, String filepath, boolean append, String unzipTo, long size,
	String contentType, InputStream binaryData)
{
	final StagingFile stagingFile = getStagingFile(stagingUuid);

	boolean creating = !fileSystemService.fileExists(stagingFile, filepath);
	try( InputStream bd = binaryData )
	{
		final FileInfo fileInfo = fileSystemService.write(stagingFile, filepath, bd, append);
		final FileBean fileBean = new FileBean();
		fileBean.setFilename(fileInfo.getFilename());
		fileBean.setParent(getParent(stagingFile, filepath));
		fileBean.setSize(fileInfo.getLength());

		// unzip?
		if( !Strings.isNullOrEmpty(unzipTo) )
		{
			fileSystemService.mkdir(stagingFile, unzipTo);
			fileSystemService.unzipFile(stagingFile, filepath, unzipTo);
		}

		// Returns both the file dir entity and the location of the content
		// so that you can know both locations
		ResponseBuilder resp = Response.status(creating ? Status.CREATED : Status.OK)
			.entity(itemLinkService.addLinks(stagingFile, fileBean, filepath));
		if( creating )
		{
			resp.location(itemLinkService.getFileContentURI(stagingFile, URLUtils.urlEncode(filepath, false)));
		}
		return resp.build();
	}
	catch( IOException e )
	{
		throw Throwables.propagate(e);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:38,代码来源:FileResourceImpl.java


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