本文整理汇总了Java中org.springframework.extensions.webscripts.WebScriptResponse类的典型用法代码示例。如果您正苦于以下问题:Java WebScriptResponse类的具体用法?Java WebScriptResponse怎么用?Java WebScriptResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebScriptResponse类属于org.springframework.extensions.webscripts包,在下文中一共展示了WebScriptResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
// create empty map of args
Map<String, String> args = new HashMap<String, String>(0, 1.0f);
// create map of template vars
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
// create object reference from url
ObjectReference reference = createObjectReferenceFromUrl(args, templateVars);
NodeRef nodeRef = reference.getNodeRef();
if (nodeRef == null)
{
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
}
// render content
QName propertyQName = ContentModel.PROP_CONTENT;
// Stream the content
streamContent(req, res, nodeRef, propertyQName, false, null, null);
}
示例2: execute
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
ChildApplicationContextFactory subsystem = (ChildApplicationContextFactory)applicationContext.getBean("imap");
// note: getting property (rather than getting imapService bean to check isEnabled) does not cause subsystem startup (if stopped)
// hence providing ability for subsystem to be disabled (whilst still supporting ability to check status and/or dynamically start via JMX)
String isEnabled = (String)subsystem.getProperty("imap.server.enabled");
if (new Boolean(isEnabled).booleanValue())
{
res.getWriter().write("enabled");
}
else
{
res.getWriter().write("disabled");
}
res.getWriter().flush();
res.getWriter().close();
}
示例3: transactionedExecuteAs
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
/**
* Execute script within required level of transaction as required effective user.
*
* @param script WebScript
* @param scriptReq WebScriptRequest
* @param scriptRes WebScriptResponse
* @throws IOException
*/
private void transactionedExecuteAs(final WebScript script, final WebScriptRequest scriptReq,
final WebScriptResponse scriptRes) throws IOException
{
String runAs = script.getDescription().getRunAs();
if (runAs == null)
{
transactionedExecute(script, scriptReq, scriptRes);
}
else
{
RunAsWork<Object> work = new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
transactionedExecute(script, scriptReq, scriptRes);
return null;
}
};
AuthenticationUtil.runAs(work, runAs);
}
}
示例4: streamContentLocal
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
protected void streamContentLocal(WebScriptRequest req, WebScriptResponse res, NodeRef nodeRef, boolean attach, QName propertyQName, Map<String, Object> model) throws IOException
{
String userAgent = req.getHeader("User-Agent");
userAgent = userAgent != null ? userAgent.toLowerCase() : "";
boolean rfc5987Supported = (userAgent.contains("msie") ||
userAgent.contains(" trident/") ||
userAgent.contains(" chrome/") ||
userAgent.contains(" firefox/") ||
userAgent.contains(" safari/"));
if (attach && rfc5987Supported)
{
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
// maintain the original name of the node during the download - do not modify it - see MNT-16510
streamContent(req, res, nodeRef, propertyQName, attach, name, model);
}
else
{
streamContent(req, res, nodeRef, propertyQName, attach, null, model);
}
}
示例5: executeImpl
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public JSONArray executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException,
ParseException
{
JSONArray jsonUsers = (JSONArray) JSONValue.parseWithException(req.getContent().getContent());
JSONArray result = new JSONArray();
for (Object o : jsonUsers)
{
String user = (o == null ? null : o.toString());
if (user != null)
{
JSONObject item = new JSONObject();
item.put(user, subscriptionService.follows(userId, user));
result.add(item);
}
}
return result;
}
示例6: executeImpl
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
public JSONObject executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException,
ParseException
{
JSONArray jsonUsers = (JSONArray) JSONValue.parseWithException(req.getContent().getContent());
for (Object o : jsonUsers)
{
String user = (o == null ? null : o.toString());
if (user != null)
{
subscriptionService.follow(userId, user);
}
}
return null;
}
示例7: executeImpl
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
public JSONObject executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException,
ParseException
{
JSONObject obj = (JSONObject) JSONValue.parseWithException(req.getContent().getContent());
Object setPrivate = obj.get("private");
if (setPrivate != null)
{
if (setPrivate.toString().equalsIgnoreCase("true"))
{
subscriptionService.setSubscriptionListPrivate(userId, true);
} else if (setPrivate.toString().equalsIgnoreCase("false"))
{
subscriptionService.setSubscriptionListPrivate(userId, false);
}
}
return super.executeImpl(userId, req, res);
}
示例8: executeImpl
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
public JSONObject executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException,
ParseException
{
JSONArray jsonUsers = (JSONArray) JSONValue.parseWithException(req.getContent().getContent());
for (Object o : jsonUsers)
{
String user = (o == null ? null : o.toString());
if (user != null)
{
subscriptionService.unfollow(userId, user);
}
}
return null;
}
示例9: execute
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
Map<String, String> params = req.getServiceMatch().getTemplateVars();
// getting workflow instance id from request parameters
String workflowInstanceId = params.get("workflow_instance_id");
WorkflowInstance workflowInstance = workflowService.getWorkflowById(workflowInstanceId);
// workflow instance was not found -> return 404
if (workflowInstance == null)
{
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow instance with id: " + workflowInstanceId);
}
// check whether there is a diagram available
if (!workflowService.hasWorkflowImage(workflowInstanceId))
{
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find diagram for workflow instance with id: " + workflowInstanceId);
}
// copy image data into temporary file
File file = TempFileProvider.createTempFile("workflow-diagram-", ".png");
InputStream imageData = workflowService.getWorkflowImage(workflowInstanceId);
OutputStream os = new FileOutputStream(file);
FileCopyUtils.copy(imageData, os);
// stream temporary file back to client
streamContent(req, res, file);
}
示例10: testSerializePagedCollection
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes" })
@Test
public void testSerializePagedCollection() throws IOException
{
assertNotNull(helper);
CollectionWithPagingInfo paged = CollectionWithPagingInfo.asPaged(null,null);
String out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api,null, Params.valueOf("notUsed", null, null), paged));
assertTrue("There must be json output as List with pagination", StringUtils.startsWith(out, "{\"list\":{\"pagination\":{\"count\":0,"));
Paging pageRequest = Paging.valueOf(1, 2);
paged = CollectionWithPagingInfo.asPaged(pageRequest,Arrays.asList(new Goat(), new Sheep("ABCD"), new Sheep("XYZ")));
out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api,null, Params.valueOf("notUsed", null, null), paged));
assertTrue("There must be json output as List with pagination", StringUtils.startsWith(out, "{\"list\":{\"pagination\":{\"count\":3,"));
paged = CollectionWithPagingInfo.asPaged(pageRequest,Arrays.asList(new Goat(), new Sheep("ABCD"), new Sheep("XYZ")),true,5000);
out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api,null, Params.valueOf("notUsed", null, null), paged));
assertTrue("There must be json output as List with pagination", StringUtils.startsWith(out, "{\"list\":{\"pagination\":{\"count\":3,\"hasMoreItems\":true,\"totalItems\":5000"));
}
示例11: lastModified
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
/**
* Gets the last modified timestamp for the document.
* <p>
* The output will be the last modified date as a long toString().
*
* @param path document path to an existing document
*/
@Override
protected void lastModified(final WebScriptResponse res, final String store, final String path)
throws IOException
{
AuthenticationUtil.runAs(new RunAsWork<Void>()
{
@SuppressWarnings("synthetic-access")
public Void doWork() throws Exception
{
final String encpath = encodePath(path);
final FileInfo fileInfo = resolveFilePath(encpath);
if (fileInfo == null)
{
throw new WebScriptException("Unable to locate file: " + encpath);
}
Writer out = res.getWriter();
out.write(Long.toString(fileInfo.getModifiedDate().getTime()));
out.close();
if (logger.isDebugEnabled())
logger.debug("lastModified: " + Long.toString(fileInfo.getModifiedDate().getTime()));
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
示例12: hasDocument
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
/**
* Determines if the document exists.
*
* The output will be either the string "true" or the string "false".
*
* @param path document path
*/
@Override
protected void hasDocument(final WebScriptResponse res, final String store, final String path) throws IOException
{
AuthenticationUtil.runAs(new RunAsWork<Void>()
{
@SuppressWarnings("synthetic-access")
public Void doWork() throws Exception
{
final String encpath = encodePath(path);
final FileInfo fileInfo = resolveFilePath(encpath);
Writer out = res.getWriter();
out.write(Boolean.toString(fileInfo != null && !fileInfo.isFolder()));
out.close();
if (logger.isDebugEnabled())
logger.debug("hasDocument: " + Boolean.toString(fileInfo != null && !fileInfo.isFolder()));
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
示例13: createDocument
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
/**
* Creates a document.
* <p>
* Create methods are user authenticated, so the creation of site config must be
* allowed for the current user.
*
* @param path document path
* @param content content of the document to write
*/
@Override
protected void createDocument(final WebScriptResponse res, final String store, final String path, final InputStream content)
{
try
{
writeDocument(path, content);
}
catch (AccessDeniedException ae)
{
res.setStatus(Status.STATUS_UNAUTHORIZED);
throw ae;
}
catch (FileExistsException feeErr)
{
res.setStatus(Status.STATUS_CONFLICT);
throw feeErr;
}
}
示例14: execute
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
@Override
public void execute(WebScriptRequest webScriptRequest, WebScriptResponse webScriptResponse) throws IOException
{
try
{
checkEnabled();
DiscoveryDetails discoveryDetails = new DiscoveryDetails(getRepositoryInfo());
// Write response
setResponse(webScriptResponse, DEFAULT_SUCCESS);
renderJsonResponse(webScriptResponse, discoveryDetails, assistant.getJsonHelper());
}
catch (Exception exception)
{
renderException(exception, webScriptResponse, assistant);
}
}
示例15: execute
import org.springframework.extensions.webscripts.WebScriptResponse; //导入依赖的package包/类
public Object execute(final ResourceWithMetadata resource, final Params params, final WebScriptResponse res, boolean isReadOnly)
{
final String entityCollectionName = ResourceInspector.findEntityCollectionNameName(resource.getMetaData());
final ResourceOperation operation = resource.getMetaData().getOperation(getHttpMethod());
final WithResponse callBack = new WithResponse(operation.getSuccessStatus(), DEFAULT_JSON_CONTENT,CACHE_NEVER);
Object toReturn = transactionService.getRetryingTransactionHelper().doInTransaction(
new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
{
@Override
public Object execute() throws Throwable
{
Object result = executeAction(resource, params, callBack);
if (result instanceof BinaryResource)
{
return result; //don't postprocess it.
}
return helper.processAdditionsToTheResponse(res, resource.getMetaData().getApi(), entityCollectionName, params, result);
}
}, isReadOnly, true);
setResponse(res,callBack);
return toReturn;
}