• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ThreadLocalRequestContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.extensions.surf.support.ThreadLocalRequestContext的典型用法代码示例。如果您正苦于以下问题:Java ThreadLocalRequestContext类的具体用法?Java ThreadLocalRequestContext怎么用?Java ThreadLocalRequestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ThreadLocalRequestContext类属于org.springframework.extensions.surf.support包,在下文中一共展示了ThreadLocalRequestContext类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getLessVariables

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
/**
 * Looks for the LESS CSS token which should contain the LESS style variables that
 * can be applied to each CSS file. This will be prepended to each CSS file processed.
 *
 * @return The String of LESS variables.
 */
public String getLessVariables()
{
    String variables = this.getDefaultLessConfig();
    Theme currentTheme = ThreadLocalRequestContext.getRequestContext().getTheme();
    if (currentTheme == null)
    {
        currentTheme = ThreadLocalRequestContext.getRequestContext().getObjectService().getTheme("default");
    }
    final String themeVariables = currentTheme.getCssTokens().get(JLesscCssThemeHandler.LESS_TOKEN);
    if (themeVariables != null)
    {
        variables += "\n" + themeVariables;
    }
    return variables;
}
 
开发者ID:Acosix,项目名称:alfresco-utility,代码行数:22,代码来源:JLesscCssThemeHandler.java


示例2: getTokenMap

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
/**
 *
 * {@inheritDoc}
 */
@Override
public Map<String, String> getTokenMap()
{
    Map<String, String> cssTokens;

    // tokensMap keyed by request context which may have different customizations applied to it than previous contexts
    final RequestContext rc = ThreadLocalRequestContext.getRequestContext();
    cssTokens = this.tokensMap.get(rc);
    if (cssTokens == null)
    {
        Theme currentTheme = rc.getTheme();
        if (currentTheme == null)
        {
            currentTheme = rc.getObjectService().getTheme("default");
        }
        // obtain theme tokens (previously handled by determineThemeTokens in base class)
        cssTokens = currentTheme.getCssTokens();
        this.tokensMap.put(rc, cssTokens);
    }

    // do not expose modifiable internal state
    return Collections.unmodifiableMap(cssTokens);
}
 
开发者ID:Acosix,项目名称:alfresco-utility,代码行数:28,代码来源:JLesscCssThemeHandler.java


示例3: retrieveFormDefinition

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
/**
 * Retrieves the form definition from the repository FormService for the
 * given item.
 * 
 * @param itemKind The form item kind
 * @param itemId The form item id
 * @param visibleFields The list of field names to return or null
 *        to return all fields
 * @param formConfig The form configuration
 * @return Response object from the remote call
 */
protected Response retrieveFormDefinition(String itemKind, String itemId, 
            List<String> visibleFields, FormConfigElement formConfig)
{
    Response response = null;
    
    try
    {
        // setup the connection
        ConnectorService connService = FrameworkUtil.getConnectorService();
        RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
        String currentUserId = requestContext.getUserId();
        HttpSession currentSession = ServletUtil.getSession(true);
        Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
        ConnectorContext context = new ConnectorContext(HttpMethod.POST, null, buildDefaultHeaders());
        context.setContentType("application/json");
        
        // call the form service
        response = connector.call("/api/formdefinitions", context, generateFormDefPostBody(itemKind,
                    itemId, visibleFields, formConfig));
        
        if (logger.isDebugEnabled())
            logger.debug("Response status: " + response.getStatus().getCode());
    }
    catch (Exception e)
    {
        if (logger.isErrorEnabled())
            logger.error("Failed to get form definition: ", e);
    }
    
    return response;
}
 
开发者ID:ecm4u,项目名称:ecm4u-alfresco-bugpatches,代码行数:43,代码来源:FormUIGet.java


示例4: processFieldContent

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
/**
 * Processes the field for content. This method is used when a content field 
 * is being used in a form where JavaScript is disabled and thus AJAX is 
 * unavailable to retrieve the content, it must therefore be done server side.
 * 
 * @param context The context
 * @param field The field to be processed
 * @param fieldDefinition The definition of the field to be processed
 * @param fieldConfig The configuration of the field to be processed
 * @throws JSONException
 */
protected void processFieldContent(ModelContext context, Field field, 
            JSONObject fieldDefinition, FormField fieldConfig) throws JSONException
{
    // if the field is a content field and JavaScript is disabled
    // we need to retrieve the content here and store in model
    if (context.getFormUIModel().get(MODEL_CAPABILITIES) != null && "content".equals(field.getDataType()))
    {
        // NOTE: In the future when other capabilties are added the 'javascript'
        //       flag will need to be checked, for now it's the only reason
        //       the capabilities object will be present so a check is redundant
       
        if (logger.isDebugEnabled())
            logger.debug("Retrieving content for \"" + field.getConfigName() + "\" as JavaScript is disabled");
       
        // get the nodeRef of the content and then the content itself
        String nodeRef = getParameter(context.getRequest(), "itemId");
       
        try
        {
            ConnectorService connService = FrameworkUtil.getConnectorService();
            RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
            String currentUserId = requestContext.getUserId();
            HttpSession currentSession = ServletUtil.getSession(true);
            Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
           
            // call the form service
            Response response = connector.call("/api/node/content/" + nodeRef.replace("://", "/"));
            if (response.getStatus().getCode() == Status.STATUS_OK)
            {
                field.setContent(response.getText());
            }
        }
        catch (Exception e)
        {
            if (logger.isErrorEnabled())
                logger.error("Failed to get field content: ", e);
        }
    }
}
 
开发者ID:ecm4u,项目名称:ecm4u-alfresco-bugpatches,代码行数:51,代码来源:FormUIGet.java


示例5: getDefaultLessConfig

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
/**
 * Returns the current default LESS configuration. If it has not previously been retrieved then it will
 * attempt to load it.
 *
 * @return A String containing the default LESS configuration variables.
 */
public String getDefaultLessConfig()
{
    final RequestContext rc = ThreadLocalRequestContext.getRequestContext();
    if (this.defaultLessConfig == null)
    {
        String defaultLessConfigPath = null;
        final ScriptConfigModel config = rc.getExtendedScriptConfigModel(null);
        final Map<?, ?> configs = (Map<?, ?>) config.getScoped().get("WebFramework");
        if (configs != null)
        {
            final WebFrameworkConfigElement wfce = (WebFrameworkConfigElement) configs.get("web-framework");
            defaultLessConfigPath = wfce.getDojoDefaultLessConfig();
        }
        else
        {
            defaultLessConfigPath = this.getWebFrameworkConfigElement().getDojoDefaultLessConfig();
        }
        try
        {
            final InputStream in = this.getDependencyHandler().getResourceInputStream(defaultLessConfigPath);
            if (in != null)
            {
                this.defaultLessConfig = this.getDependencyHandler().convertResourceToString(in);
            }
            else
            {
                LOGGER.error("Could not find the default LESS configuration at: {}", defaultLessConfigPath);
                // Set the configuration as the empty string as it's not in the configured location
                this.defaultLessConfig = "";
            }
        }
        catch (final IOException e)
        {
            LOGGER.error("An exception occurred retrieving the default LESS configuration from: {}", defaultLessConfigPath, e);
        }
    }
    return this.defaultLessConfig;
}
 
开发者ID:Acosix,项目名称:alfresco-utility,代码行数:45,代码来源:JLesscCssThemeHandler.java


示例6: evaluate

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
/**
 * @see org.alfresco.web.evaluator.BaseEvaluator#evaluate(org.json.simple.JSONObject)
 */
@Override
public boolean evaluate(JSONObject jsonObject)
{
    boolean result = true;
    ParameterCheck.mandatory("jsonObject", jsonObject);
    try
    {
        JSONObject node = (JSONObject) jsonObject.get("node");
        if (node != null)
        {
            boolean isEnabled = (Boolean)node.get(IS_RECORD_CONTRIBUTOR_GROUP_ENABLED);
            if (isEnabled)
            {
                // get the name of the record contributor group
                String groupName = (String)node.get(RECORD_CONTRIBUTOR_GROUP_NAME);

                // check the record contributor group
                final RequestContext rc = ThreadLocalRequestContext.getRequestContext();
                result = util.isMemberOfGroups(rc, Collections.singletonList("GROUP_" + groupName), true);
            }
            else
            {
                // if group check is not enabled then allow
                result = true;
            }
        }
    }
    catch (Exception err)
    {
        throw new AlfrescoRuntimeException("Exception whilst running UI evaluator: " + err.getMessage());
    };
    return result;
}
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:37,代码来源:IsUserRecordContributor.java


示例7: evaluate

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
@Override
public boolean evaluate(JSONObject jsonObject) {
   try
   {
      String username = getUserId();
      JSONObject modifier =(JSONObject) getProperty(jsonObject,"cm:modifier");
      
      if (username.equalsIgnoreCase((String)modifier.get("userName")))
      {
          return true;
      }
      
      
      
      String siteName = getSiteId(jsonObject);
      
      if (siteName == null)
      {
         // It's not a site, so we have no opinion on access
         return true;
      }

      // Fetch the membership information for the site
      RequestContext rc = ThreadLocalRequestContext.getRequestContext();
      Connector conn = rc.getServiceRegistry().getConnectorService().getConnector(
            "alfresco", username, ServletUtil.getSession());
      Response response = conn.call("/api/sites/"+siteName+"/memberships/"+username);
      
      if (response.getStatus().getCode() == Status.STATUS_OK)
      {
         // Convert the response text to jsonobject
         JSONObject responsetext = (JSONObject)new JSONParser().parse(response.getResponse());
         
         // Get the user role and compare with required role
         return requiredRole.equalsIgnoreCase(this.getUserRole(responsetext));         
      }
      else if (response.getStatus().getCode() == Status.STATUS_NOT_FOUND)
      {
         // Not a member of the site / site not found / etc
         // Shouldn't be showing in this case
         return false;
      }
      else
      {
         logger.warn("Invalid response fetching memberships for " + username + " in " + siteName + " - " + response);
         return false;
      }
   }
   catch (Exception err)
   {
      throw new AlfrescoRuntimeException("Failed to run UI evaluator: " + err.getMessage());
   }
 }
 
开发者ID:muralidharand,项目名称:alfresco-disable-enable-download-action,代码行数:54,代码来源:DownloadActionEvaluator.java


示例8: getFormConfig

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
/**
 * Returns the form configuration for the given item id and optional form id.
 * 
 * @param itemId The form itemId
 * @param formId The id of the form to lookup
 * @return The FormConfigElement object or null if no configuration is found
 */
protected FormConfigElement getFormConfig(String itemId, String formId)
{
    FormConfigElement formConfig = null;
    FormsConfigElement formsConfig = null;
    RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
    ConfigModel extendedTemplateConfigModel = requestContext.getExtendedTemplateConfigModel(null);
    
    if(extendedTemplateConfigModel != null) {
    	@SuppressWarnings("unchecked")
     Map<String, ConfigElement> configs = (Map<String, ConfigElement>) extendedTemplateConfigModel.getScoped().get(itemId);
     formsConfig = (FormsConfigElement) configs.get(CONFIG_FORMS);
    }
    
    if(formsConfig == null)
    {
    	Config configResult = this.configService.getConfig(itemId);
        formsConfig = (FormsConfigElement)configResult.getConfigElement(CONFIG_FORMS);
    }
    
    if (formsConfig != null)
    {
       // Extract the form we are looking for
        if (formsConfig != null)
        {
            // try and retrieve the specified form 
            if (formId != null && formId.length() > 0)
            {
                formConfig = formsConfig.getForm(formId);
            }
            
            // fall back to the default form
            if (formConfig == null)
            {
                formConfig = formsConfig.getDefaultForm();
            }
        }
    }
    else if (logger.isWarnEnabled())
    {
        logger.warn("Could not lookup form configuration as configService has not been set");
    }
    return formConfig;
}
 
开发者ID:ecm4u,项目名称:ecm4u-alfresco-bugpatches,代码行数:51,代码来源:FormUIGet.java


示例9: getProbeSettings

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
@Override
protected Settings getProbeSettings(final WebScriptRequest req) {
  try {
    Pair<String, String> parseRequestedTransformation = parseRequestedTransformation(req);
    final RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();

    final ConnectorService connService = requestContext.getServiceRegistry().getConnectorService();

    final String currentUserId = requestContext.getUserId();

    final HttpSession currentSession = ServletUtil.getSession(true);

    final Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);

    final String alfrescoURL = "/org/redpill/alfresco/clusterprobe/probe/transform/" + parseRequestedTransformation.getFirst() + "/" + parseRequestedTransformation.getSecond();

    final Response response = connector.call(alfrescoURL);

    return new Settings(response.getResponse(), response.getStatus().getCode());
  } catch (final Exception ex) {
    LOG.error(ex.getMessage(), ex);
    final StringBuilder sb = new StringBuilder();

    StackTraceUtil.buildStackTrace(ex.getMessage(), ex.getStackTrace(), sb, 0);

    return new Settings("Couldn't get settings from repo server.\n" + sb.toString(), 500);
  }
}
 
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:29,代码来源:ProbeTransform.java


示例10: getProbeSettings

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
@Override
protected Settings getProbeSettings(final WebScriptRequest req) {
  try {

    final RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();

    final ConnectorService connService = requestContext.getServiceRegistry().getConnectorService();

    final String currentUserId = requestContext.getUserId();

    final HttpSession currentSession = ServletUtil.getSession(true);

    final Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);

    final String alfrescoURL = "/org/redpill/alfresco/clusterprobe/probe/search";

    final Response response = connector.call(alfrescoURL);

    return new Settings(response.getResponse(), response.getStatus().getCode());
  } catch (final Exception ex) {
    LOG.error(ex.getMessage(), ex);
    final StringBuilder sb = new StringBuilder();

    StackTraceUtil.buildStackTrace(ex.getMessage(), ex.getStackTrace(), sb, 0);

    return new Settings("Couldn't get settings from repo server.\n" + sb.toString(), 500);
  }
}
 
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:29,代码来源:ProbeSearch.java


示例11: getProbeSettings

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
@Override
protected Settings getProbeSettings(final WebScriptRequest req) {
  try {
    final String server = getServer();

    final RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();

    final ConnectorService connService = requestContext.getServiceRegistry().getConnectorService();

    final String currentUserId = requestContext.getUserId();

    final HttpSession currentSession = ServletUtil.getSession(true);

    final Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);

    final String alfrescoURL = "/org/redpill/alfresco/clusterprobe/settings?server=" + server;

    final Response response = connector.call(alfrescoURL);

    final String jsonResponse = response.getResponse();

    final JSONObject json = new JSONObject(new JSONTokener(jsonResponse));

    return new Settings(json.getString("text"), json.getInt("code"));
  } catch (final Exception ex) {
    LOG.error(ex.getMessage(), ex);
    final StringBuilder sb = new StringBuilder();

    StackTraceUtil.buildStackTrace(ex.getMessage(), ex.getStackTrace(), sb, 0);

    return new Settings("Couldn't get settings from repo server.\n" + sb.toString(), 500);
  }
}
 
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:34,代码来源:ProbeGet.java


示例12: getProbeSettings

import org.springframework.extensions.surf.support.ThreadLocalRequestContext; //导入依赖的package包/类
@Override
protected Settings getProbeSettings(final WebScriptRequest req) {
  try {

    final RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();

    final ConnectorService connService = requestContext.getServiceRegistry().getConnectorService();

    final String currentUserId = requestContext.getUserId();

    final HttpSession currentSession = ServletUtil.getSession(true);

    final Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);

    final String alfrescoURL = "/org/redpill/alfresco/clusterprobe/probe";

    final Response response = connector.call(alfrescoURL);

    return new Settings(response.getResponse(), response.getStatus().getCode());
  } catch (final Exception ex) {
    LOG.error(ex.getMessage(), ex);
    final StringBuilder sb = new StringBuilder();

    StackTraceUtil.buildStackTrace(ex.getMessage(), ex.getStackTrace(), sb, 0);

    return new Settings("Couldn't get settings from repo server.\n" + sb.toString(), 500);
  }
}
 
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:29,代码来源:ProbeRepoGet.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OWL类代码示例发布时间:2022-05-23
下一篇:
Java BlogsEntry类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap