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


Java WebScriptResponse.setStatus方法代码示例

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


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

示例1: 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;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:28,代码来源:ADMRemoteStore.java

示例2: execute

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
    if (enabled)
    {
        //log.debug("Transfer webscript invoked by user: " + AuthenticationUtil.getFullyAuthenticatedUser() +
        //        " running as " + AuthenticationUtil.getRunAsAuthentication().getName());
        processCommand(req.getServiceMatch().getTemplateVars().get("command"), req, res);
    }
    else
    {
        res.setStatus(Status.STATUS_NOT_FOUND);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-file-transfer-receiver,代码行数:14,代码来源:FileTransferWebScript.java

示例3: process

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
public int process(WebScriptRequest req, WebScriptResponse resp)
{
    //Since all the checks that are needed are actually carried out by the transfer web script, this processor
    //effectively becomes a no-op.
    int result = Status.STATUS_OK;
    resp.setStatus(result);
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:9,代码来源:TestCredentialsCommandProcessor.java

示例4: execute

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
    if (enabled) 
    {
        log.debug("Transfer webscript invoked by user: " + AuthenticationUtil.getFullyAuthenticatedUser() + 
                " running as " + AuthenticationUtil.getRunAsAuthentication().getName());
        processCommand(req.getServiceMatch().getTemplateVars().get("command"), req, res);
    }
    else
    {
        res.setStatus(Status.STATUS_NOT_FOUND);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:14,代码来源:TransferWebScript.java

示例5: streamContent

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
/**
 * Streams the content on a given node's content property to the response of the web script.
 *
 * @param req            Request
 * @param res            Response
 * @param nodeRef        The node reference
 * @param propertyQName  The content property name
 * @param attach         Indicates whether the content should be streamed as an attachment or not
 * @param attachFileName Optional file name to use when attach is <code>true</code>
 * @throws IOException
 */
public void streamContent(WebScriptRequest req,
            WebScriptResponse res,
            NodeRef nodeRef,
            QName propertyQName,
            boolean attach,
            String attachFileName,
            Map<String, Object> model) throws IOException
{
    if (logger.isDebugEnabled())
        logger.debug("Retrieving content from node ref " + nodeRef.toString() + " (property: " + propertyQName.toString() + ") (attach: " + attach + ")");

    // TODO
    // This was commented out to accomadate records management permissions.  We need to review how we cope with this
    // hard coded permission checked.

    // check that the user has at least READ_CONTENT access - else redirect to the login page
    //        if (permissionService.hasPermission(nodeRef, PermissionService.READ_CONTENT) == AccessStatus.DENIED)
    //        {
    //            throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Permission denied");
    //        }

    // check If-Modified-Since header and set Last-Modified header as appropriate
    Date modified = (Date) nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
    if (modified != null)
    {
        long modifiedSince = -1;
        String modifiedSinceStr = req.getHeader("If-Modified-Since");
        if (modifiedSinceStr != null)
        {
            try
            {
                modifiedSince = dateFormat.parse(modifiedSinceStr).getTime();
            }
            catch (Throwable e)
            {
                if (logger.isInfoEnabled())
                    logger.info("Browser sent badly-formatted If-Modified-Since header: " + modifiedSinceStr);
            }

            if (modifiedSince > 0L)
            {
                // round the date to the ignore millisecond value which is not supplied by header
                long modDate = (modified.getTime() / 1000L) * 1000L;
                if (modDate <= modifiedSince)
                {
                    res.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                    return;
                }
            }
        }
    }

    // get the content reader
    ContentReader reader = contentService.getReader(nodeRef, propertyQName);
    if (reader == null || !reader.exists())
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to locate content for node ref " + nodeRef + " (property: " + propertyQName.toString() + ")");
    }

    // Stream the content
    streamContentImpl(req, res, reader, nodeRef, propertyQName, attach, modified, modified == null ? null : Long.toString(modified.getTime()), attachFileName, model);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:74,代码来源:ContentStreamer.java

示例6: execute

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
    CMISDispatcher dispatcher = registry.getDispatcher(req);
    if(dispatcher == null)
    {
    	res.setStatus(404);	
    }
    else
    {
    	dispatcher.execute(req, res);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:13,代码来源:CMISWebScript.java

示例7: process

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
public int process(WebScriptRequest req, WebScriptResponse resp)
{
    String transferRecordId = null;
    try
    {
        // return the unique transfer id (the lock id)
        StringWriter stringWriter = new StringWriter(300);
        JSONWriter jsonWriter = new JSONWriter(stringWriter);
        
        jsonWriter.startValue("data");

        jsonWriter.startArray();
        jsonWriter.startObject();
        //TODO - clearly a dummy message for now.
        jsonWriter.writeValue("message", "hello world");
        jsonWriter.endObject();
        jsonWriter.startObject();
        //TODO - clearly a dummy message for now.
        jsonWriter.writeValue("message", "message2");
        jsonWriter.endObject();
        jsonWriter.endArray();
        jsonWriter.endValue();
        String response = stringWriter.toString();
        
        resp.setContentType("application/json");
        resp.setContentEncoding("UTF-8");
        int length = response.getBytes("UTF-8").length;
        resp.addHeader("Content-Length", "" + length);
        resp.setStatus(Status.STATUS_OK);
        resp.getWriter().write(response);
        
        return Status.STATUS_OK;

    } catch (Exception ex)
    {
        receiver.end(transferRecordId);
        if (ex instanceof TransferException)
        {
            throw (TransferException) ex;
        }
        throw new TransferException(MSG_CAUGHT_UNEXPECTED_EXCEPTION, ex);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:44,代码来源:MessagesTransferCommandProcessor.java

示例8: execute

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
    if (!subscriptionService.isActive())
    {
        res.setStatus(404);
        return;
    }

    try
    {
        String userId = req.getServiceMatch().getTemplateVars().get("userid");
        Object obj = executeImpl(userId, req, res);

        if (obj instanceof JSONObject || obj instanceof JSONArray)
        {
            res.setContentEncoding(Charset.defaultCharset().displayName());
            res.setContentType(Format.JSON.mimetype() + ";charset=UTF-8");

            Writer writer = res.getWriter();
            if (obj instanceof JSONObject)
            {
                ((JSONObject) obj).writeJSONString(writer);
            } else
            {
                ((JSONArray) obj).writeJSONString(writer);
            }
            writer.flush();
        } else
        {
            res.setStatus(204);
        }
    } catch (SubscriptionsDisabledException sde)
    {
        throw new WebScriptException(404, "Subscription service is disabled!", sde);
    } catch (NoSuchPersonException nspe)
    {
        throw new WebScriptException(404, "Unknown user '" + nspe.getUserName() + "'!", nspe);
    } catch (PrivateSubscriptionListException psle)
    {
        throw new WebScriptException(403, "Subscription list is private!", psle);
    } catch (ParseException pe)
    {
        throw new WebScriptException(400, "Unable to parse JSON!", pe);
    } catch (ClassCastException cce)
    {
        throw new WebScriptException(400, "Unable to parse JSON!", cce);
    } catch (IOException ioe)
    {
        throw new WebScriptException(500, "Unable to serialize JSON!", ioe);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:52,代码来源:AbstractSubscriptionServiceWebScript.java

示例9: execute

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
    res.setStatus(Status.STATUS_OK);
    res.getWriter().close();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:6,代码来源:Touch.java

示例10: createDocuments

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
/**
 * Creates multiple XML documents encapsulated in a single one. 
 * 
 * @param res       WebScriptResponse
 * @param store       String
 * @param in       XML document containing multiple document contents to write
 */
@Override
protected void createDocuments(WebScriptResponse res, String store, InputStream in)
{
    try
    {
        DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); 
        Document document;
        document = documentBuilder.parse(in);
        Element docEl = document.getDocumentElement();
        Transformer transformer = ADMRemoteStore.this.transformer.get();
        for (Node n = docEl.getFirstChild(); n != null; n = n.getNextSibling())
        {
            if (!(n instanceof Element))
            {
                continue;
            }
            final String path = ((Element) n).getAttribute("path");
            
            // Turn the first element child into a document
            Document doc = documentBuilder.newDocument();
            Node child;
            for (child = n.getFirstChild(); child != null ; child=child.getNextSibling())
            {
               if (child instanceof Element)
               {
                   doc.appendChild(doc.importNode(child, true));
                   break;
               }
            }
            ByteArrayOutputStream out = new ByteArrayOutputStream(512);
            transformer.transform(new DOMSource(doc), new StreamResult(out));
            out.close();
            
            writeDocument(path, new ByteArrayInputStream(out.toByteArray()));
        }
    }
    catch (AccessDeniedException ae)
    {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
        throw ae;
    }
    catch (FileExistsException feeErr)
    {
        res.setStatus(Status.STATUS_CONFLICT);
        throw feeErr;
    }
    catch (Exception e)
    {
        // various annoying checked SAX/IO exceptions related to XML processing can be thrown
        // none of them should occur if the XML document is well formed
        logger.error(e);
        res.setStatus(Status.STATUS_INTERNAL_SERVER_ERROR);
        throw new AlfrescoRuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:63,代码来源:ADMRemoteStore.java

示例11: deleteDocument

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
/**
 * Deletes an existing document.
 * <p>
 * Delete methods are user authenticated, so the deletion of the document must be
 * allowed for the current user.
 * 
 * @param path  document path
 */
@Override
protected void deleteDocument(final WebScriptResponse res, final String store, final String path)
{
    final String encpath = encodePath(path);
    final FileInfo fileInfo = resolveFilePath(encpath);
    if (fileInfo == null || fileInfo.isFolder())
    {
        res.setStatus(Status.STATUS_NOT_FOUND);
        return;
    }
    
    final String runAsUser = getPathRunAsUser(path);
    AuthenticationUtil.runAs(new RunAsWork<Void>()
    {
        @SuppressWarnings("synthetic-access")
        public Void doWork() throws Exception
        {
            try
            {
                final NodeRef fileRef = fileInfo.getNodeRef();
                // MNT-16371: Revoke ownership privileges for surf-config folder contents, to tighten access for former SiteManagers.
                nodeService.addAspect(fileRef, ContentModel.ASPECT_TEMPORARY, null);

                // ALF-17729
                NodeRef parentFolderRef = unprotNodeService.getPrimaryParent(fileRef).getParentRef();
                behaviourFilter.disableBehaviour(parentFolderRef, ContentModel.ASPECT_AUDITABLE);

                try
                {
                    nodeService.deleteNode(fileRef);
                }
                finally
                {
                    behaviourFilter.enableBehaviour(parentFolderRef, ContentModel.ASPECT_AUDITABLE);
                }

                if (logger.isDebugEnabled())
                    logger.debug("deleteDocument: " + fileInfo.toString());
            }
            catch (AccessDeniedException ae)
            {
                res.setStatus(Status.STATUS_UNAUTHORIZED);
                throw ae;
            }
            return null;
        }
    }, runAsUser);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:57,代码来源:ADMRemoteStore.java


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