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


Java SolrQueryResponse.setHttpCaching方法代码示例

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


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

示例1: handleRequestBody

import org.apache.solr.response.SolrQueryResponse; //导入方法依赖的package包/类
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException 
{
  Object props = null;
  String name = req.getParams().get( "name" );
  if( name != null ) {
    NamedList<String> p = new SimpleOrderedMap<>();
    p.add( name, System.getProperty(name) );
    props = p;
  }
  else {
    props = System.getProperties();
  }
  rsp.add( "system.properties", props );
  rsp.setHttpCaching(false);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:PropertiesRequestHandler.java

示例2: handleRequestBody

import org.apache.solr.response.SolrQueryResponse; //导入方法依赖的package包/类
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
	rsp.setHttpCaching(false);
	final SolrParams solrParams = req.getParams();

	String dicPath = solrParams.get("dicPath");
	Dictionary dict = Utils.getDict(dicPath, loader);

	NamedList<Object> result = new NamedList<Object>();
	result.add("dicPath", dict.getDicPath().toURI());

	boolean check = solrParams.getBool("check", false);	//仅仅用于检测词库是否有变化
	//用于尝试加载词库,有此参数, check 参数可以省略。
	boolean reload = solrParams.getBool("reload", false);	

	check |= reload;

	boolean changed = false;
	boolean reloaded = false;
	if(check) {
		changed = dict.wordsFileIsChange();
		result.add("changed", changed);
	}
	if(changed && reload) {
		reloaded = dict.reload();
		result.add("reloaded", reloaded);
	}
	rsp.add("result", result);
}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:29,代码来源:MMseg4jHandler.java

示例3: handleRequestBody

import org.apache.solr.response.SolrQueryResponse; //导入方法依赖的package包/类
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
  // Make sure the cores is enabled
  CoreContainer cores = getCoreContainer();
  if (cores == null) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
            "Core container instance missing");
  }

  String path = (String) req.getContext().get("path");
  int i = path.lastIndexOf('/');
  String name = path.substring(i + 1, path.length());
  
  if (name.equalsIgnoreCase("properties")) {
    propertiesHandler.handleRequest(req, rsp);
  } else if (name.equalsIgnoreCase("threads")) {
    threadDumpHandler.handleRequest(req, rsp);
  } else if (name.equalsIgnoreCase("logging")) {
    loggingHandler.handleRequest(req, rsp);
  }  else if (name.equalsIgnoreCase("system")) {
    systemInfoHandler.handleRequest(req, rsp);
  } else {
    if (name.equalsIgnoreCase("info")) name = "";
    throw new SolrException(ErrorCode.NOT_FOUND, "Info Handler not found: " + name);
  }
  
  rsp.setHttpCaching(false);
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:InfoHandler.java

示例4: handleRequestBody

import org.apache.solr.response.SolrQueryResponse; //导入方法依赖的package包/类
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
{
  SolrCore core = req.getCore();
  if (core != null) rsp.add( "core", getCoreInfo( core, req.getSchema() ) );
  boolean solrCloudMode =  getCoreContainer(req, core).isZooKeeperAware();
  rsp.add( "mode", solrCloudMode ? "solrcloud" : "std");
  rsp.add( "lucene", getLuceneInfo() );
  rsp.add( "jvm", getJvmInfo() );
  rsp.add( "system", getSystemInfo() );
  rsp.setHttpCaching(false);
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:SystemInfoHandler.java

示例5: handleRequestBody

import org.apache.solr.response.SolrQueryResponse; //导入方法依赖的package包/类
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
  NamedList<NamedList<NamedList<Object>>> cats = getMBeanInfo(req);
  if(req.getParams().getBool("diff", false)) {
    ContentStream body = null;
    try {
      body = req.getContentStreams().iterator().next();
    }
    catch(Exception ex) {
      throw new SolrException(ErrorCode.BAD_REQUEST, "missing content-stream for diff");
    }
    String content = IOUtils.toString(body.getReader());
    
    NamedList<NamedList<NamedList<Object>>> ref = fromXML(content);
    
    
    // Normalize the output 
    SolrQueryResponse wrap = new SolrQueryResponse();
    wrap.add("solr-mbeans", cats);
    cats = (NamedList<NamedList<NamedList<Object>>>)
        BinaryResponseWriter.getParsedResponse(req, wrap).get("solr-mbeans");
    
    // Get rid of irrelevant things
    ref = normalize(ref);
    cats = normalize(cats);
    
    // Only the changes
    boolean showAll = req.getParams().getBool("all", false);
    rsp.add("solr-mbeans", getDiff(ref,cats, showAll));
  }
  else {
    rsp.add("solr-mbeans", cats);
  }
  rsp.setHttpCaching(false); // never cache, no matter what init config looks like
}
 
开发者ID:europeana,项目名称:search,代码行数:36,代码来源:SolrInfoMBeanHandler.java

示例6: handleRequestBody

import org.apache.solr.response.SolrQueryResponse; //导入方法依赖的package包/类
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception 
{
  SolrParams params = req.getParams();
  
  boolean stats = params.getBool( "stats", false );
  rsp.add( "plugins", getSolrInfoBeans( req.getCore(), stats ) );
  rsp.setHttpCaching(false);
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:PluginInfoHandler.java

示例7: showFromZooKeeper

import org.apache.solr.response.SolrQueryResponse; //导入方法依赖的package包/类
private void showFromZooKeeper(SolrQueryRequest req, SolrQueryResponse rsp,
    CoreContainer coreContainer) throws KeeperException,
    InterruptedException, UnsupportedEncodingException {

  SolrZkClient zkClient = coreContainer.getZkController().getZkClient();

  String adminFile = getAdminFileFromZooKeeper(req, rsp, zkClient, hiddenFiles);

  if (adminFile == null) {
    return;
  }

  // Show a directory listing
  List<String> children = zkClient.getChildren(adminFile, null, true);
  if (children.size() > 0) {
    
    NamedList<SimpleOrderedMap<Object>> files = new SimpleOrderedMap<>();
    for (String f : children) {
      if (isHiddenFile(req, rsp, f, false, hiddenFiles)) {
        continue;
      }

      SimpleOrderedMap<Object> fileInfo = new SimpleOrderedMap<>();
      files.add(f, fileInfo);
      List<String> fchildren = zkClient.getChildren(adminFile + "/" + f, null, true);
      if (fchildren.size() > 0) {
        fileInfo.add("directory", true);
      } else {
        // TODO? content type
        fileInfo.add("size", f.length());
      }
      // TODO: ?
      // fileInfo.add( "modified", new Date( f.lastModified() ) );
    }
    rsp.add("files", files);
  } else {
    // Include the file contents
    // The file logic depends on RawResponseWriter, so force its use.
    ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
    params.set(CommonParams.WT, "raw");
    req.setParams(params);
    ContentStreamBase content = new ContentStreamBase.ByteArrayStream(zkClient.getData(adminFile, null, null, true), adminFile);
    content.setContentType(req.getParams().get(USE_CONTENT_TYPE));
    
    rsp.add(RawResponseWriter.CONTENT, content);
  }
  rsp.setHttpCaching(false);
}
 
开发者ID:europeana,项目名称:search,代码行数:49,代码来源:ShowFileRequestHandler.java

示例8: showFromFileSystem

import org.apache.solr.response.SolrQueryResponse; //导入方法依赖的package包/类
private void showFromFileSystem(SolrQueryRequest req, SolrQueryResponse rsp) {
  File adminFile = getAdminFileFromFileSystem(req, rsp, hiddenFiles);

  if (adminFile == null) { // exception already recorded
    return;
  }

  // Make sure the file exists, is readable and is not a hidden file
  if( !adminFile.exists() ) {
    log.error("Can not find: "+adminFile.getName() + " ["+adminFile.getAbsolutePath()+"]");
    rsp.setException(new SolrException
                     ( ErrorCode.NOT_FOUND, "Can not find: "+adminFile.getName() 
                       + " ["+adminFile.getAbsolutePath()+"]" ));
    return;
  }
  if( !adminFile.canRead() || adminFile.isHidden() ) {
    log.error("Can not show: "+adminFile.getName() + " ["+adminFile.getAbsolutePath()+"]");
    rsp.setException(new SolrException
                     ( ErrorCode.NOT_FOUND, "Can not show: "+adminFile.getName() 
                       + " ["+adminFile.getAbsolutePath()+"]" ));
    return;
  }
  
  // Show a directory listing
  if( adminFile.isDirectory() ) {
    // it's really a directory, just go for it.
    int basePath = adminFile.getAbsolutePath().length() + 1;
    NamedList<SimpleOrderedMap<Object>> files = new SimpleOrderedMap<>();
    for( File f : adminFile.listFiles() ) {
      String path = f.getAbsolutePath().substring( basePath );
      path = path.replace( '\\', '/' ); // normalize slashes

      if (isHiddenFile(req, rsp, f.getName().replace('\\', '/'), false, hiddenFiles)) {
        continue;
      }

      SimpleOrderedMap<Object> fileInfo = new SimpleOrderedMap<>();
      files.add( path, fileInfo );
      if( f.isDirectory() ) {
        fileInfo.add( "directory", true ); 
      }
      else {
        // TODO? content type
        fileInfo.add( "size", f.length() );
      }
      fileInfo.add( "modified", new Date( f.lastModified() ) );
    }
    rsp.add("files", files);
  }
  else {
    // Include the file contents
    //The file logic depends on RawResponseWriter, so force its use.
    ModifiableSolrParams params = new ModifiableSolrParams( req.getParams() );
    params.set( CommonParams.WT, "raw" );
    req.setParams(params);

    ContentStreamBase content = new ContentStreamBase.FileStream( adminFile );
    content.setContentType(req.getParams().get(USE_CONTENT_TYPE));

    rsp.add(RawResponseWriter.CONTENT, content);
  }
  rsp.setHttpCaching(false);
}
 
开发者ID:europeana,项目名称:search,代码行数:64,代码来源:ShowFileRequestHandler.java


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