Create {@link CoreContainer} for Solr version 4.4+ and handle changes in .

@param solrHomeDirectory
@param solrXmlFile
@return
3830
private CoreContainer createCoreContainer(String solrHomeDirectory, File solrXmlFile) {

		Method createAndLoadMethod = ClassUtils.getStaticMethod(CoreContainer.class, "createAndLoad", String.class,
				File.class);

		if (createAndLoadMethod != null) {
			return (CoreContainer) ReflectionUtils.invokeMethod(createAndLoadMethod, null, solrHomeDirectory, solrXmlFile);
		}

		createAndLoadMethod = ClassUtils.getStaticMethod(CoreContainer.class, "createAndLoad", Path.class, Path.class);
		return (CoreContainer) ReflectionUtils.invokeMethod(createAndLoadMethod, null,
				FileSystems.getDefault().getPath(solrHomeDirectory), FileSystems.getDefault().getPath(solrXmlFile.getPath()));
	}
619385
public static IndriQueryerBuilder queryerForIndex(File indexDir) {
    final IndriQueryerBuilder builder = new IndriQueryerBuilder();
    builder.addIndex(indexDir);
    return builder;
  }
889687
private SolrServer initCore(String core) {
        boolean isEmbedded = globalConfig.getBoolean(false, "indexer", core,
                "embedded");
        try {
            // Embedded Solr
            if (isEmbedded) {
                // Solr over HTTP - Needed to run commits
                // so the core web server sees them.
                String uri = globalConfig.getString(null, "indexer", core,
                        "uri");
                if (uri == null) {
                    log.error("No URI provided for core: '{}'", core);
                    return null;
                }
                URI solrUri = new URI(uri);
                commit = new CommonsHttpSolrServer(solrUri.toURL());
                username = globalConfig.getString(null, "indexer", core,
                        "username");
                password = globalConfig.getString(null, "indexer", core,
                        "password");
                if (username != null && password != null) {
                    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(
                            username, password);
                    HttpClient hc = ((CommonsHttpSolrServer) solr)
                            .getHttpClient();
                    hc.getParams().setAuthenticationPreemptive(true);
                    hc.getState().setCredentials(AuthScope.ANY, credentials);
                }

                // First time execution
                if (coreContainer == null) {
                    String home = globalConfig.getString(DEFAULT_SOLR_HOME,
                            "indexer", "home");
                    log.info("Embedded Solr Home = {}", home);
                    File homeDir = new File(home);
                    if (!homeDir.exists()) {
                        log.error("Solr directory does not exist!");
                        return null;
                    }
                    System.setProperty("solr.solr.home",
                            homeDir.getAbsolutePath());
                    File coreXmlFile = new File(homeDir, "solr.xml");
                    coreContainer = new CoreContainer(
                            homeDir.getAbsolutePath(), coreXmlFile);
                    for (SolrCore aCore : coreContainer.getCores()) {
                        log.info("Loaded core: {}", aCore.getName());
                    }
                }
                String coreName = globalConfig.getString(null, "indexer", core,
                        "coreName");
                if (coreName == null) {
                    log.error("No 'coreName' node for core: '{}'", core);
                    return null;
                }
                return new EmbeddedSolrServer(coreContainer, coreName);

                // Solr over HTTP
            } else {
                String uri = globalConfig.getString(null, "indexer", core,
                        "uri");
                if (uri == null) {
                    log.error("No URI provided for core: '{}'", core);
                    return null;
                }

                URI solrUri = new URI(uri);
                CommonsHttpSolrServer thisCore = new CommonsHttpSolrServer(
                        solrUri.toURL());
                username = globalConfig.getString(null, "indexer", core,
                        "username");
                password = globalConfig.getString(null, "indexer", core,
                        "password");
                if (username != null && password != null) {
                    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(
                            username, password);
                    HttpClient hc = thisCore.getHttpClient();
                    hc.getParams().setAuthenticationPreemptive(true);
                    hc.getState().setCredentials(AuthScope.ANY, credentials);
                }
                return thisCore;
            }

        } catch (MalformedURLException mue) {
            log.error(core + " : Malformed URL", mue);
        } catch (URISyntaxException urise) {
            log.error(core + " : Invalid URI", urise);
        } catch (IOException ioe) {
            log.error(core + " : Failed to read Solr configuration", ioe);
        } catch (ParserConfigurationException pce) {
            log.error(core + " : Failed to parse Solr configuration", pce);
        } catch (SAXException saxe) {
            log.error(core + " : Failed to load Solr configuration", saxe);
        }
        return null;
    }
40696
public static RecyclerViewHeader fromXml(Context context, @LayoutRes int layoutRes) {
        RecyclerViewHeader header = new RecyclerViewHeader(context);
        View.inflate(context, layoutRes, header);
        return header;
    }
592458
public static XContentBuilder marshall(PlanVersionBean bean) throws StorageException {
        try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
            PlanBean plan = bean.getPlan();
            OrganizationBean org = plan.getOrganization();
            preMarshall(bean);
            builder
                .startObject()
                    .field("organizationId", org.getId())
                    .field("organizationName", org.getName())
                    .field("planId", plan.getId())
                    .field("planName", plan.getName())
                    .field("planDescription", plan.getDescription())
                    .field("version", bean.getVersion())
                    .field("status", bean.getStatus())
                    .field("createdBy", bean.getCreatedBy())
                    .field("createdOn", bean.getCreatedOn().getTime())
                    .field("modifiedBy", bean.getModifiedBy())
                    .field("modifiedOn", bean.getModifiedOn().getTime())
                    .field("lockedOn", bean.getLockedOn() != null ? bean.getLockedOn().getTime() : null)
                .endObject();
            postMarshall(bean);
            return builder;
        } catch (IOException e) {
            throw new StorageException(e);
        }
    }
1176112
final AbstractSingleFileObjectStore.Directory makeDirectory(int minimumNodeSize,
                                                                long directoryRootByteAddress,
                                                                long directoryRootLength)
                    throws ObjectManagerException {
        return new Directory(minimumNodeSize,
                             directoryRootByteAddress,
                             directoryRootLength);
    }
295905
public static XContentBuilder marshall(RoleBean bean) throws StorageException {
        try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
            preMarshall(bean);
            builder
                .startObject()
                    .field("id", bean.getId())
                    .field("name", bean.getName())
                    .field("description", bean.getDescription())
                    .field("createdBy", bean.getCreatedBy())
                    .field("createdOn", bean.getCreatedOn().getTime())
                    .field("autoGrant", bean.getAutoGrant());
            Set<PermissionType> permissions = bean.getPermissions();
            if (permissions != null && !permissions.isEmpty()) {
                builder.array("permissions", permissions.toArray(new PermissionType[permissions.size()]));
            }
            builder.endObject();
            postMarshall(bean);
            return builder;
        } catch (IOException e) {
            throw new StorageException(e);
        }
    }
120735
@SuppressWarnings("unchecked")
  private void init(SolrQueryRequest req) throws IOException {
    if (config == null) {
      // initialise
      config = new MtasUpdateRequestProcessorConfig();
      // required info
      Map<String, FieldType> fieldTypes = req.getSchema().getFieldTypes();
      Map<String, SchemaField> fields = req.getSchema().getFields();
      SolrResourceLoader resourceLoader = req.getCore().getSolrConfig()
          .getResourceLoader();
      // check fieldTypes
      // for (String name : fieldTypes.keySet()) {
      for (Entry<String, FieldType> entry : fieldTypes.entrySet()) {
        // only for MtasPreAnalyzedField
        if (entry.getValue() instanceof MtasPreAnalyzedField) {
          MtasPreAnalyzedField mpaf = (MtasPreAnalyzedField) entry.getValue();
          config.fieldTypeDefaultConfiguration.put(entry.getKey(),
              mpaf.defaultConfiguration);
          config.fieldTypeConfigurationFromField.put(entry.getKey(),
              mpaf.configurationFromField);
          config.fieldTypeNumberOfTokensField.put(entry.getKey(),
              mpaf.setNumberOfTokens);
          config.fieldTypeNumberOfPositionsField.put(entry.getKey(),
              mpaf.setNumberOfPositions);
          config.fieldTypeSizeField.put(entry.getKey(), mpaf.setSize);
          config.fieldTypeErrorField.put(entry.getKey(), mpaf.setError);
          config.fieldTypePrefixField.put(entry.getKey(), mpaf.setPrefix);
          config.fieldTypePrefixNumbersFieldPrefix.put(entry.getKey(), mpaf.setPrefixNumbers);
          if (mpaf.followIndexAnalyzer == null
              || !fieldTypes.containsKey(mpaf.followIndexAnalyzer)) {
            throw new IOException(
                entry.getKey() + " can't follow " + mpaf.followIndexAnalyzer);
          } else {
            FieldType fieldType = fieldTypes.get(mpaf.followIndexAnalyzer);
            SimpleOrderedMap<?> analyzer = null;
            Object tmpObj1 = fieldType.getNamedPropertyValues(false)
                .get(FieldType.INDEX_ANALYZER);
            if (tmpObj1 != null && tmpObj1 instanceof SimpleOrderedMap) {
              analyzer = (SimpleOrderedMap<?>) tmpObj1;
            }
            if (analyzer == null) {
              Object tmpObj2 = fieldType.getNamedPropertyValues(false)
                  .get(FieldType.ANALYZER);
              if (tmpObj2 != null && tmpObj2 instanceof SimpleOrderedMap) {
                analyzer = (SimpleOrderedMap<?>) tmpObj2;
              }
            }
            if (analyzer == null) {
              throw new IOException("no analyzer");
            } else {
              // charfilters
              ArrayList<SimpleOrderedMap<Object>> listCharFilters = null;
              SimpleOrderedMap<Object> configTokenizer = null;
              try {
                listCharFilters = (ArrayList<SimpleOrderedMap<Object>>) analyzer
                    .findRecursive(FieldType.CHAR_FILTERS);
                ;
                configTokenizer = (SimpleOrderedMap<Object>) analyzer
                    .findRecursive(FieldType.TOKENIZER);
              } catch (ClassCastException e) {
                throw new IOException(
                    "could not cast charFilters and/or tokenizer from analyzer",
                    e);
              }
              if (listCharFilters != null && !listCharFilters.isEmpty()) {
                CharFilterFactory[] charFilterFactories = new CharFilterFactory[listCharFilters
                    .size()];
                int number = 0;
                for (SimpleOrderedMap<Object> configCharFilter : listCharFilters) {
                  String className = null;
                  Map<String, String> args = new HashMap<>();
                  Iterator<Map.Entry<String, Object>> it = configCharFilter
                      .iterator();
                  // get className and args
                  while (it.hasNext()) {
                    Map.Entry<String, Object> obj = it.next();
                    if (obj.getValue() instanceof String) {
                      if (obj.getKey().equals(FieldType.CLASS_NAME)) {
                        className = (String) obj.getValue();
                      } else {
                        args.put(obj.getKey(), (String) obj.getValue());
                      }
                    }
                  }
                  if (className != null) {
                    try {
                      Class<?> cls = Class.forName((String) className);
                      if (cls.isAssignableFrom(MtasCharFilterFactory.class)) {
                        Class<?>[] types = { Map.class, ResourceLoader.class };
                        Constructor<?> cnstr = cls.getConstructor(types);
                        Object cff = cnstr.newInstance(args, resourceLoader);
                        if (cff instanceof MtasCharFilterFactory) {
                          charFilterFactories[number] = (MtasCharFilterFactory) cff;
                          number++;
                        } else {
                          throw new IOException(
                              className + " is no MtasCharFilterFactory");
                        }
                      } else {
                        Class<?>[] types = { Map.class };
                        Constructor<?> cnstr = cls.getConstructor(types);
                        Object cff = cnstr.newInstance(args);
                        if (cff instanceof CharFilterFactory) {
                          charFilterFactories[number] = (CharFilterFactory) cff;
                          number++;
                        } else {
                          throw new IOException(
                              className + " is no CharFilterFactory");
                        }
                      }
                    } catch (ClassNotFoundException | InstantiationException
                        | IllegalAccessException | IllegalArgumentException
                        | InvocationTargetException | NoSuchMethodException e) {
                      throw new IOException(e);
                    }
                  } else {
                    throw new IOException("no className");
                  }
                }
                config.fieldTypeCharFilterFactories.put(entry.getKey(),
                    charFilterFactories);
              } else {
                config.fieldTypeCharFilterFactories.put(entry.getKey(), null);
              }
              if (configTokenizer != null) {
                String className = null;
                Map<String, String> args = new HashMap<>();
                Iterator<Map.Entry<String, Object>> it = configTokenizer
                    .iterator();
                // get className and args
                while (it.hasNext()) {
                  Map.Entry<String, Object> obj = it.next();
                  if (obj.getValue() instanceof String) {
                    if (obj.getKey().equals(FieldType.CLASS_NAME)) {
                      className = (String) obj.getValue();
                    } else {
                      args.put(obj.getKey(), (String) obj.getValue());
                    }
                  }
                }
                if (className != null) {
                  try {
                    Class<?> cls = Class.forName((String) className);
                    Class<?>[] types = { Map.class, ResourceLoader.class };
                    Constructor<?> cnstr = cls.getConstructor(types);
                    Object cff = cnstr.newInstance(args, resourceLoader);
                    if (cff instanceof MtasTokenizerFactory) {
                      config.fieldTypeTokenizerFactory.put(entry.getKey(),
                          (MtasTokenizerFactory) cff);
                    } else {
                      throw new IOException(
                          className + " is no MtasTokenizerFactory");
                    }
                  } catch (ClassNotFoundException | InstantiationException
                      | IllegalAccessException | IllegalArgumentException
                      | InvocationTargetException | NoSuchMethodException e) {
                    throw new IOException(e);
                  }
                } else {
                  throw new IOException("no className");
                }
              }

            }
          }
        }
      }
      for (Entry<String, SchemaField> entry : fields.entrySet()) {
        if (entry.getValue().getType() != null
            && config.fieldTypeTokenizerFactory
                .containsKey(entry.getValue().getType().getTypeName())) {
          config.fieldMapping.put(entry.getKey(),
              entry.getValue().getType().getTypeName());
        }
      }
    }
  }
222464
private void writeResp(ServletResponse response, SolrQueryRequest queryRequest, SolrQueryResponse queryResponse)
    throws IOException, UnsupportedEncodingException {

        if (m_solr instanceof EmbeddedSolrServer) {
            SolrCore core = ((EmbeddedSolrServer)m_solr).getCoreContainer().getCore(getCoreName());
            Writer out = null;
            try {
                QueryResponseWriter responseWriter = core.getQueryResponseWriter(queryRequest);

                final String ct = responseWriter.getContentType(queryRequest, queryResponse);
                if (null != ct) {
                    response.setContentType(ct);
                }

                if (responseWriter instanceof BinaryQueryResponseWriter) {
                    BinaryQueryResponseWriter binWriter = (BinaryQueryResponseWriter)responseWriter;
                    binWriter.write(response.getOutputStream(), queryRequest, queryResponse);
                } else {
                    String charset = ContentStreamBase.getCharsetFromContentType(ct);
                    out = ((charset == null) || charset.equalsIgnoreCase(UTF8.toString()))
                    ? new OutputStreamWriter(response.getOutputStream(), UTF8)
                    : new OutputStreamWriter(response.getOutputStream(), charset);
                    out = new FastWriter(out);
                    responseWriter.write(out, queryRequest, queryResponse);
                    out.flush();
                }
            } finally {
                core.close();
                if (out != null) {
                    out.close();
                }
            }
        } else {
            throw new UnsupportedOperationException();
        }
    }
985640
private IndexedContainer createContainerForBundleWithDescriptor() throws IOException, CmsException {

        IndexedContainer container = new IndexedContainer();

        // create properties
        container.addContainerProperty(TableProperty.KEY, String.class, "");
        container.addContainerProperty(TableProperty.DESCRIPTION, String.class, "");
        container.addContainerProperty(TableProperty.DEFAULT, String.class, "");
        container.addContainerProperty(TableProperty.TRANSLATION, String.class, "");

        // add entries
        SortedProperties localization = getLocalization(m_locale);
        CmsXmlContentValueSequence messages = m_descContent.getValueSequence(Descriptor.N_MESSAGE, Descriptor.LOCALE);
        String descValue;
        boolean hasDescription = false;
        String defaultValue;
        boolean hasDefault = false;
        for (int i = 0; i < messages.getElementCount(); i++) {

            String prefix = messages.getValue(i).getPath() + "/";
            Object itemId = container.addItem();
            Item item = container.getItem(itemId);
            String key = m_descContent.getValue(prefix + Descriptor.N_KEY, Descriptor.LOCALE).getStringValue(m_cms);
            item.getItemProperty(TableProperty.KEY).setValue(key);
            String translation = localization.getProperty(key);
            item.getItemProperty(TableProperty.TRANSLATION).setValue(null == translation ? "" : translation);
            descValue = m_descContent.getValue(prefix + Descriptor.N_DESCRIPTION, Descriptor.LOCALE).getStringValue(
                m_cms);
            item.getItemProperty(TableProperty.DESCRIPTION).setValue(descValue);
            hasDescription = hasDescription || !descValue.isEmpty();
            defaultValue = m_descContent.getValue(prefix + Descriptor.N_DEFAULT, Descriptor.LOCALE).getStringValue(
                m_cms);
            item.getItemProperty(TableProperty.DEFAULT).setValue(defaultValue);
            hasDefault = hasDefault || !defaultValue.isEmpty();
        }

        m_hasDefault = hasDefault;
        m_hasDescription = hasDescription;
        return container;

    }
987119
public static XContentBuilder marshall(ContractBean bean) throws StorageException {
        try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
            preMarshall(bean);
            builder
                .startObject()
                    .field("id", bean.getId())
                    .field("clientOrganizationId", bean.getClient().getClient().getOrganization().getId())
                    .field("clientOrganizationName", bean.getClient().getClient().getOrganization().getName())
                    .field("clientId", bean.getClient().getClient().getId())
                    .field("clientName", bean.getClient().getClient().getName())
                    .field("clientVersion", bean.getClient().getVersion())
                    .field("apiOrganizationId", bean.getApi().getApi().getOrganization().getId())
                    .field("apiOrganizationName", bean.getApi().getApi().getOrganization().getName())
                    .field("apiId", bean.getApi().getApi().getId())
                    .field("apiName", bean.getApi().getApi().getName())
                    .field("apiVersion", bean.getApi().getVersion())
                    .field("apiDescription", bean.getApi().getApi().getDescription())
                    .field("planName", bean.getPlan().getPlan().getName())
                    .field("planId", bean.getPlan().getPlan().getId())
                    .field("planVersion", bean.getPlan().getVersion())
                    .field("createdOn", bean.getCreatedOn().getTime())
                    .field("createdBy", bean.getCreatedBy())
                .endObject();
            postMarshall(bean);
            return builder;
        } catch (IOException e) {
            throw new StorageException(e);
        }
    }
1012725
public boolean addDescriptor() {

        saveLocalization();
        IndexedContainer oldContainer = m_container;
        try {
            createAndLockDescriptorFile();
            unmarshalDescriptor();
            updateBundleDescriptorContent();
            m_hasMasterMode = true;
            m_container = createContainer();
            m_editorState.put(EditMode.DEFAULT, getDefaultState());
            m_editorState.put(EditMode.MASTER, getMasterState());
        } catch (CmsException | IOException e) {
            LOG.error(e.getLocalizedMessage(), e);
            if (m_descContent != null) {
                m_descContent = null;
            }
            if (m_descFile != null) {
                m_descFile = null;
            }
            if (m_desc != null) {
                try {
                    m_cms.deleteResource(m_desc, CmsResourceDeleteMode.valueOf(1));
                } catch (CmsException ex) {
                    LOG.error(ex.getLocalizedMessage(), ex);
                }
                m_desc = null;
            }
            m_hasMasterMode = false;
            m_container = oldContainer;
            return false;
        }
        m_removeDescriptorOnCancel = true;
        return true;
    }
1311149
@Override
	protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType) {

		SolrOperations solrOperations = getDependencyInstance(solrOperationsBean, SolrOperations.class);

		return create(() -> new SolrRepositoryFactory(solrOperations), repositoryType);
	}
42665
public static List<ContentRepositoryElement> listFiles(final Path rootPath, Path tempDir, final ContentFilter filter) throws IOException {
        List<ContentRepositoryElement> result = new ArrayList<>();
        if (Files.exists(rootPath)) {
            if(isArchive(rootPath)) {
                return listZipContent(rootPath, filter);
            }
            Files.walkFileTree(rootPath, new FileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    if (filter.acceptFile(rootPath, file)) {
                        result.add(ContentRepositoryElement.createFile(formatPath(rootPath.relativize(file)), Files.size(file)));
                    }
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                    if (filter.acceptDirectory(rootPath, dir)) {
                        String directoryPath = formatDirectoryPath(rootPath.relativize(dir));
                        if(! "/".equals(directoryPath)) {
                            result.add(ContentRepositoryElement.createFolder(directoryPath));
                        }
                    }
                    return FileVisitResult.CONTINUE;
                }

                private String formatDirectoryPath(Path path) {
                    return formatPath(path) + '/';
                }

                private String formatPath(Path path) {
                    return path.toString().replace(File.separatorChar, '/');
                }
            });
        } else {
            Path file = getFile(rootPath);
            if(isArchive(file)) {
                Path relativePath = file.relativize(rootPath);
                Path target = createTempDirectory(tempDir, "unarchive");
                unzip(file, target);
                return listFiles(target.resolve(relativePath), tempDir, filter);
            } else {
                throw new FileNotFoundException(rootPath.toString());
            }
        }
        return result;
    }
342717
public void indexDocument(HashMap<String,Object>indexMap) throws Exception {
		SolrInputDocument solrDoc=this.buildSolrDocument(indexMap);
		String docXML=this.convertSolrDocInXML(solrDoc);
		String xml = "<add>" + docXML + "</add>";
		DirectXmlRequest xmlreq = new DirectXmlRequest("/update", xml);
		server.request(xmlreq);
	}
1365790
@SuppressWarnings("resource")
    public void registerSolrIndex(CmsSolrIndex index) throws CmsConfigurationException {

        if ((m_solrConfig == null) || !m_solrConfig.isEnabled()) {
            // No solr server configured
            throw new CmsConfigurationException(Messages.get().container(Messages.ERR_SOLR_NOT_ENABLED_0));
        }

        if (m_solrConfig.getServerUrl() != null) {
            // HTTP Server configured
            // TODO Implement multi core support for HTTP server
            // @see http://lucidworks.lucidimagination.com/display/solr/Configuring+solr.xml
            index.setSolrServer(new Builder().withBaseSolrUrl(m_solrConfig.getServerUrl()).build());
        }

        // get the core container that contains one core for each configured index
        if (m_coreContainer == null) {
            m_coreContainer = createCoreContainer();
        }

        // unload the existing core if it exists to avoid problems with forced unlock.
        if (m_coreContainer.getAllCoreNames().contains(index.getCoreName())) {
            m_coreContainer.unload(index.getCoreName(), false, false, true);
        }
        // ensure that all locks on the index are gone
        ensureIndexIsUnlocked(index.getPath());

        // load the core to the container
        File dataDir = new File(index.getPath());
        if (!dataDir.exists()) {
            dataDir.mkdirs();
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(
                    Messages.get().getBundle().key(
                        Messages.INIT_SOLR_INDEX_DIR_CREATED_2,
                        index.getName(),
                        index.getPath()));
            }
        }
        File instanceDir = new File(m_solrConfig.getHome() + FileSystems.getDefault().getSeparator() + index.getName());
        if (!instanceDir.exists()) {
            instanceDir.mkdirs();
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(
                    Messages.get().getBundle().key(
                        Messages.INIT_SOLR_INDEX_DIR_CREATED_2,
                        index.getName(),
                        index.getPath()));
            }
        }

        // create the core
        // TODO: suboptimal - forces always the same schema
        SolrCore core = null;
        try {
            // creation includes registration.
            // TODO: this was the old code: core = m_coreContainer.create(descriptor, false);
            Map<String, String> properties = new HashMap<String, String>(3);
            properties.put(CoreDescriptor.CORE_DATADIR, dataDir.getAbsolutePath());
            properties.put(CoreDescriptor.CORE_CONFIGSET, "default");
            core = m_coreContainer.create(index.getCoreName(), instanceDir.toPath(), properties, false);
        } catch (NullPointerException e) {
            if (core != null) {
                core.close();
            }
            throw new CmsConfigurationException(
                Messages.get().container(
                    Messages.ERR_SOLR_SERVER_NOT_CREATED_3,
                    index.getName() + " (" + index.getCoreName() + ")",
                    index.getPath(),
                    m_solrConfig.getSolrConfigFile().getAbsolutePath()),
                e);
        }

        if (index.isNoSolrServerSet()) {
            index.setSolrServer(new EmbeddedSolrServer(m_coreContainer, index.getCoreName()));
        }
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(
                    Messages.INIT_SOLR_SERVER_CREATED_1,
                    index.getName() + " (" + index.getCoreName() + ")"));
        }
    }
381043
private CoreContainer createCoreContainer() {

        CoreContainer container = null;
        try {
            // get the core container
            // still no core container: create it
            container = CoreContainer.createAndLoad(
                Paths.get(m_solrConfig.getHome()),
                m_solrConfig.getSolrFile().toPath());
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(
                    Messages.get().getBundle().key(
                        Messages.INIT_SOLR_CORE_CONTAINER_CREATED_2,
                        m_solrConfig.getHome(),
                        m_solrConfig.getSolrFile().getName()));
            }
        } catch (Exception e) {
            LOG.error(
                Messages.get().getBundle().key(
                    Messages.ERR_SOLR_CORE_CONTAINER_NOT_CREATED_1,
                    m_solrConfig.getSolrFile().getAbsolutePath()),
                e);
        }
        return container;

    }