"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "solr/core/src/java/org/apache/solr/packagemanager/RepositoryManager.java" between
solr-8.4.0-src.tgz and solr-8.4.1-src.tgz

About: Solr is the search platform from the Apache Lucene project. Its major features include full-text search, hit highlighting, faceted search, caching, replication, and a web admin interface.

RepositoryManager.java  (solr-8.4.0-src.tgz):RepositoryManager.java  (solr-8.4.1-src.tgz)
skipping to change at line 25 skipping to change at line 25
* limitations under the License. * limitations under the License.
*/ */
package org.apache.solr.packagemanager; package org.apache.solr.packagemanager;
import static org.apache.solr.packagemanager.PackageUtils.getMapper; import static org.apache.solr.packagemanager.PackageUtils.getMapper;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
skipping to change at line 51 skipping to change at line 51
import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.V2Request; import org.apache.solr.client.solrj.request.V2Request;
import org.apache.solr.client.solrj.request.beans.Package; import org.apache.solr.client.solrj.request.beans.Package;
import org.apache.solr.client.solrj.response.V2Response; import org.apache.solr.client.solrj.response.V2Response;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.SolrZkClient; import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.core.BlobRepository; import org.apache.solr.core.BlobRepository;
import org.apache.solr.filestore.PackageStoreAPI;
import org.apache.solr.packagemanager.SolrPackage.Artifact; import org.apache.solr.packagemanager.SolrPackage.Artifact;
import org.apache.solr.packagemanager.SolrPackage.SolrPackageRelease; import org.apache.solr.packagemanager.SolrPackage.SolrPackageRelease;
import org.apache.solr.pkg.PackageAPI; import org.apache.solr.pkg.PackageAPI;
import org.apache.solr.pkg.PackagePluginHolder; import org.apache.solr.pkg.PackagePluginHolder;
import org.apache.solr.util.SolrCLI;
import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Handles most of the management of repositories and packages present in extern al repositories. * Handles most of the management of repositories and packages present in extern al repositories.
*/ */
public class RepositoryManager { public class RepositoryManager {
skipping to change at line 119 skipping to change at line 121
for (PackageRepository updateRepository: repositories) { for (PackageRepository updateRepository: repositories) {
updateRepository.refresh(); updateRepository.refresh();
} }
return repositories; return repositories;
} }
/** /**
* Add a repository to Solr * Add a repository to Solr
*/ */
public void addRepository(String name, String uri) throws KeeperException, Int erruptedException, MalformedURLException, IOException { public void addRepository(String repoName, String uri) throws Exception {
String existingRepositoriesJson = getRepositoriesJson(packageManager.zkClien t); String existingRepositoriesJson = getRepositoriesJson(packageManager.zkClien t);
log.info(existingRepositoriesJson); log.info(existingRepositoriesJson);
List<PackageRepository> repos = getMapper().readValue(existingRepositoriesJs on, List.class); List<PackageRepository> repos = getMapper().readValue(existingRepositoriesJs on, List.class);
repos.add(new DefaultPackageRepository(name, uri)); repos.add(new DefaultPackageRepository(repoName, uri));
if (packageManager.zkClient.exists(PackageUtils.REPOSITORIES_ZK_PATH, true) == false) { if (packageManager.zkClient.exists(PackageUtils.REPOSITORIES_ZK_PATH, true) == false) {
packageManager.zkClient.create(PackageUtils.REPOSITORIES_ZK_PATH, getMappe r().writeValueAsString(repos).getBytes("UTF-8"), CreateMode.PERSISTENT, true); packageManager.zkClient.create(PackageUtils.REPOSITORIES_ZK_PATH, getMappe r().writeValueAsString(repos).getBytes("UTF-8"), CreateMode.PERSISTENT, true);
} else { } else {
packageManager.zkClient.setData(PackageUtils.REPOSITORIES_ZK_PATH, getMapp er().writeValueAsString(repos).getBytes("UTF-8"), true); packageManager.zkClient.setData(PackageUtils.REPOSITORIES_ZK_PATH, getMapp er().writeValueAsString(repos).getBytes("UTF-8"), true);
} }
if (packageManager.zkClient.exists("/keys", true)==false) packageManager.zkC addKey(IOUtils.toByteArray(new URL(uri + "/publickey.der").openStream()), re
lient.create("/keys", new byte[0], CreateMode.PERSISTENT, true); poName + ".der");
if (packageManager.zkClient.exists("/keys/exe", true)==false) packageManager }
.zkClient.create("/keys/exe", new byte[0], CreateMode.PERSISTENT, true);
if (packageManager.zkClient.exists("/keys/exe/" + name + ".der", true)==fals public void addKey(byte[] key, String destinationKeyFilename) throws Exception
e) { {
packageManager.zkClient.create("/keys/exe/" + name + ".der", new byte[0], // get solr_home directory from info servlet
CreateMode.PERSISTENT, true); String systemInfoUrl = solrClient.getBaseURL() + "/solr/admin/info/system";
} Map<String,Object> systemInfo = SolrCLI.getJson(solrClient.getHttpClient(),
packageManager.zkClient.setData("/keys/exe/" + name + ".der", IOUtils.toByte systemInfoUrl, 2, true);
Array(new URL(uri + "/publickey.der").openStream()), true); String solrHome = (String) systemInfo.get("solr_home");
// put the public key into package store's trusted key store and request a s
ync.
String path = PackageStoreAPI.KEYS_DIR + "/" + destinationKeyFilename;
PackageUtils.uploadKey(key, path, Paths.get(solrHome), solrClient);
PackageUtils.getJsonStringFromUrl(solrClient.getHttpClient(), solrClient.get
BaseURL() + "/api/node/files" + path + "?sync=true");
} }
private String getRepositoriesJson(SolrZkClient zkClient) throws UnsupportedEn codingException, KeeperException, InterruptedException { private String getRepositoriesJson(SolrZkClient zkClient) throws UnsupportedEn codingException, KeeperException, InterruptedException {
if (zkClient.exists(PackageUtils.REPOSITORIES_ZK_PATH, true)) { if (zkClient.exists(PackageUtils.REPOSITORIES_ZK_PATH, true)) {
return new String(zkClient.getData(PackageUtils.REPOSITORIES_ZK_PATH, null , null, true), "UTF-8"); return new String(zkClient.getData(PackageUtils.REPOSITORIES_ZK_PATH, null , null, true), "UTF-8");
} }
return "[]"; return "[]";
} }
/** /**
 End of changes. 7 change blocks. 
14 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)