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


Java ContentStreamBase.setContentType方法代码示例

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


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

示例1: toContentStreams

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的package包/类
/**
 * Take a string and make it an iterable ContentStream
 */
public static Collection<ContentStream> toContentStreams( final String str, final String contentType )
{
  if( str == null )
    return null;

  ArrayList<ContentStream> streams = new ArrayList<>( 1 );
  ContentStreamBase ccc = new ContentStreamBase.StringStream( str );
  ccc.setContentType( contentType );
  streams.add( ccc );
  return streams;
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:ClientUtils.java

示例2: toContentStreams

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的package包/类
/**
 * Take a string and make it an iterable ContentStream
 * 
 * This should be moved to a helper class. (it is useful for the client too!)
 */
public static Collection<ContentStream> toContentStreams( final String str, final String contentType )
{
  ArrayList<ContentStream> streams = new ArrayList<>();
  ContentStreamBase stream = new ContentStreamBase.StringStream( str );
  stream.setContentType( contentType );
  streams.add( stream );
  return streams;
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:AutoCommitTest.java

示例3: loadLocal

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的package包/类
void loadLocal(String... args) throws Exception {
  LocalSolrQueryRequest req =  (LocalSolrQueryRequest)req(args);

  // TODO: stop using locally defined streams once stream.file and
  // stream.body work everywhere
  List<ContentStream> cs = new ArrayList<>(1);
  ContentStreamBase f = new ContentStreamBase.FileStream(new File(filename));
  f.setContentType("text/csv");
  cs.add(f);
  req.setContentStreams(cs);
  h.query("/update",req);
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TestCSVLoader.java

示例4: toContentStreams

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的package包/类
/**
 * Take a string and make it an iterable ContentStream
 */
public static Collection<ContentStream> toContentStreams( final String str, final String contentType )
{
  if( str == null )
    return null;

  ArrayList<ContentStream> streams = new ArrayList<ContentStream>( 1 );
  ContentStreamBase ccc = new ContentStreamBase.StringStream( str );
  ccc.setContentType( contentType );
  streams.add( ccc );
  return streams;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:15,代码来源:ClientUtils.java

示例5: toContentStreams

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的package包/类
/**
 * Take a string and make it an iterable ContentStream
 * 
 * This should be moved to a helper class. (it is useful for the client too!)
 */
public static Collection<ContentStream> toContentStreams( final String str, final String contentType )
{
  ArrayList<ContentStream> streams = new ArrayList<ContentStream>();
  ContentStreamBase stream = new ContentStreamBase.StringStream( str );
  stream.setContentType( contentType );
  streams.add( stream );
  return streams;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:14,代码来源:AutoCommitTest.java

示例6: loadLocal

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的package包/类
void loadLocal(String... args) throws Exception {
  LocalSolrQueryRequest req =  (LocalSolrQueryRequest)req(args);

  // TODO: stop using locally defined streams once stream.file and
  // stream.body work everywhere
  List<ContentStream> cs = new ArrayList<ContentStream>(1);
  ContentStreamBase f = new ContentStreamBase.FileStream(new File(filename));
  f.setContentType("text/csv");
  cs.add(f);
  req.setContentStreams(cs);
  h.query("/update",req);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:13,代码来源:TestCSVLoader.java

示例7: showFromZooKeeper

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的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.common.util.ContentStreamBase; //导入方法依赖的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

示例9: showFromZooKeeper

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的package包/类
private void showFromZooKeeper(SolrQueryRequest req, SolrQueryResponse rsp,
    CoreContainer coreContainer) throws KeeperException,
    InterruptedException, UnsupportedEncodingException {
  String adminFile = null;
  SolrCore core = req.getCore();
  SolrZkClient zkClient = coreContainer.getZkController().getZkClient();
  final ZkSolrResourceLoader loader = (ZkSolrResourceLoader) core
      .getResourceLoader();
  String confPath = loader.getCollectionZkPath();
  
  String fname = req.getParams().get("file", null);
  if (fname == null) {
    adminFile = confPath;
  } else {
    fname = fname.replace('\\', '/'); // normalize slashes
    if (hiddenFiles.contains(fname.toUpperCase(Locale.ROOT))) {
      rsp.setException(new SolrException(ErrorCode.FORBIDDEN, "Can not access: " + fname));
      return;
    }
    if (fname.indexOf("..") >= 0) {
      rsp.setException(new SolrException(ErrorCode.FORBIDDEN, "Invalid path: " + fname));
      return;
    }
    if (fname.startsWith("/")) { // Only files relative to conf are valid
      fname = fname.substring(1);
    }
    adminFile = confPath + "/" + fname;
  }
  
  // Make sure the file exists, is readable and is not a hidden file
  if (!zkClient.exists(adminFile, true)) {
    rsp.setException(new SolrException(ErrorCode.NOT_FOUND, "Can not find: "
                                       + adminFile));
    return;
  }
  
  // Show a directory listing
  List<String> children = zkClient.getChildren(adminFile, null, true);
  if (children.size() > 0) {
    
    NamedList<SimpleOrderedMap<Object>> files = new SimpleOrderedMap<SimpleOrderedMap<Object>>();
    for (String f : children) {
      if (hiddenFiles.contains(f.toUpperCase(Locale.ROOT))) {
        continue; // don't show 'hidden' files
      }
      if (f.startsWith(".")) {
        continue; // skip hidden system files...
      }
      
      SimpleOrderedMap<Object> fileInfo = new SimpleOrderedMap<Object>();
      files.add(f, fileInfo);
      List<String> fchildren = zkClient.getChildren(adminFile, 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.StringStream(
        new String(zkClient.getData(adminFile, null, null, true), "UTF-8"));
    content.setContentType(req.getParams().get(USE_CONTENT_TYPE));
    
    rsp.add(RawResponseWriter.CONTENT, content);
  }
  rsp.setHttpCaching(false);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:78,代码来源:ShowFileRequestHandler.java

示例10: showFromZooKeeper

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的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<SimpleOrderedMap<Object>>();
    for (String f : children) {
      if (isHiddenFile(req, rsp, f, false, hiddenFiles)) {
        continue;
      }

      SimpleOrderedMap<Object> fileInfo = new SimpleOrderedMap<Object>();
      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:yintaoxue,项目名称:read-open-source-code,代码行数:49,代码来源:ShowFileRequestHandler.java

示例11: showFromFileSystem

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的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<SimpleOrderedMap<Object>>();
    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<Object>();
      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:yintaoxue,项目名称:read-open-source-code,代码行数:64,代码来源:ShowFileRequestHandler.java

示例12: addFile

import org.apache.solr.common.util.ContentStreamBase; //导入方法依赖的package包/类
/**
 * Add a File to the {@link org.apache.solr.common.util.ContentStream}s.
 * @param file The File to add.
 * @throws IOException if there was an error with the file.
 *
 * @see #getContentStreams()
 * @see org.apache.solr.common.util.ContentStreamBase.FileStream
 */
public void addFile(File file, String contentType) throws IOException {
  ContentStreamBase cs = new ContentStreamBase.FileStream(file);
  cs.setContentType(contentType);
  addContentStream(cs);
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:ContentStreamUpdateRequest.java


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