public static RepositoryAdapter getServerRepository(String host, int port,
			String repositoryName, boolean createIfNeeded) throws DuplicateNameException {

		RepositoryServerAdapter repositoryServer = ClientUtil.getRepositoryServer(host, port, true);
		if (!repositoryServer.isConnected()) {
			return null;
		}
		try {
			boolean exists = false;
			for (String name : repositoryServer.getRepositoryNames()) {
				if (name.equals(repositoryName)) {
					exists = true;
					break;
				}
			}
			if (exists) {
				return repositoryServer.getRepository(repositoryName);
			}
			return repositoryServer.createRepository(repositoryName);
		}
		catch (NotConnectedException e) {
			Msg.error(GhidraProject.class, "Unexpected exception getting server repository", e);
		}
		catch (IOException e) {
			ClientUtil.handleException(null, e, "Get Repository", false, null);
		}
		return null;
	}
Get/Create shared repository.

@param host Ghidra Server host
@param port Ghidra Server port (0 = use default port)
@param repositoryName The repository name
@param createIfNeeded if true repository will be created if it does not exist
@throws DuplicateNameException if the repository name already exists
@return A {@link RepositoryAdapter handle} to the new repository
Ghidra/Features/Base/src/main/java/ghidra/base/project/GhidraProject.java