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


Java WebScriptResponse.getWriter方法代码示例

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


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

示例1: execute

import org.springframework.extensions.webscripts.WebScriptResponse; //导入方法依赖的package包/类
@Override
public void execute(final WebScriptRequest request, final WebScriptResponse response) throws IOException {

	final Writer w = response.getWriter();
	String siteId = request.getParameter(PARAM_SITE_ID);
	String role = siteService.getMembersRole(siteId, authenticationService.getCurrentUserName());
	if (authorityService.hasAdminAuthority() || SiteModel.SITE_MANAGER.equals(role)) {

		log.debug("Starting job manually. jobdetailbean=" + jobdetailbean);
		SchedulerFactory schedFact = new StdSchedulerFactory();

		// Create a trigger that fires exactly once, ten seconds from now
		final long startTime = System.currentTimeMillis() + 1000L;
		final SimpleTrigger trigger = new SimpleTrigger("manualTrigger", null, new Date(startTime), null, 0, 0L);

		try {
			final Scheduler s = schedFact.getScheduler();
			s.addJobListener(new ManualJobListener());
			log.debug("trigger: " + trigger + ", scheduler: " + s);

			s.scheduleJob(jobdetailbean, trigger);
			s.start();

			String msgStart = "LDAP Sync triggered at " + new Date(startTime);
			log.info(msgStart);
			w.write(msgStart);

		} catch (final Exception e) {
			log.error("Error while executing " + jobdetailbean + " manually");
			throw new AlfrescoRuntimeException("Error while executing " + jobdetailbean + " manually", e);
		}

	} else {
		String msg = "Only Alfresco Administrators or SiteManagers can trigger ldpa sync action manually.";
		log.error(msg);
		throw new AlfrescoRuntimeException(msg);
	}
}
 
开发者ID:form4,项目名称:alfresco-triggerauthenticationsync,代码行数:39,代码来源:StartPeopleSyncWebScript.java

示例2: 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


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