void NamespaceOperations::rename(string newName, string oldName)
{
  if (IsEmpty(&oldName))
  {
    oldName = myNamespace;
  }
  
  string id = namespaces[oldName];
  
  if (IsEmpty(&id) || id == "accumulo" )
  {
    throw ClientException(DELETE_DEFAULT_NAMESPACE);
  }
  else
  {
    interconnect::AccumuloMasterTransporter *baseTransport =
	        clientInterface->getTransport ().get ();
		
    if (!baseTransport->renamenamespace(credentials,oldName,newName))
    {
      throw ClientException(COULD_NOT_CREATE_NAMESPACE);
    }
    else{
      loadNamespaces();
    }
  }
}
示例#2
0
void Client::run() {
  if (!m_is_connected) {
    ERR("No connection established to Server");
    throw ClientException();
  }

  // receive Server's hello
  bool is_stopped = false;
  Response response = getResponse(m_socket, &is_stopped);
  if (response.isEmpty()) {
    ERR("Received empty response. Connection closed");
    throw ClientException();
  } else {
    std::string system = "", payload = "";
    Path action = Path::UNKNOWN;
    ID_t id = UNKNOWN_ID;
    if (util::checkSystemMessage(response.body, &system, &payload, action, id)) {
      processSystemPayload(payload);
    } else {
      ERR("Incoming response is not a Server's hello!");
      throw ClientException();
    }
  }

  goToMainMenu();
}
bool NamespaceOperations::remove(string name)
{
  if (IsEmpty(&name))
    name = myNamespace;
  string id = namespaces[name];
  
  if (IsEmpty(&id) || id == "accumulo" )
  {
    throw ClientException(DELETE_DEFAULT_NAMESPACE);
  }
  else
  {
    interconnect::AccumuloMasterTransporter *baseTransport =
	        clientInterface->getTransport ().get ();
		
    if (!baseTransport->deletenamespace(credentials,name))
    {
      throw ClientException(COULD_NOT_CREATE_NAMESPACE);
    }
    else{
      loadNamespaces();
    }
  }
    
  
  return false;
  
}
示例#4
0
  /**
   * Create a new temporary file in @a dstPath. If @a dstPath
   * is empty (""), then construct the temporary filename
   * from the temporary directory and the filename component
   * of @a path. The file-extension of @a path will be transformed
   * to @a dstPath and @a dstPath will be a unique filename
   *
   * @param dstPath path to temporary file. Will be constructed
   *                from @a path and temporary dir (and unique elements)
   *                if empty string
   * @param path existing filename. Necessary only for construction
   *             of @a dstPath
   * @param pool pool to use
   * @return open file
   */
  static apr_file_t *
  openTempFile(Path & dstPath, const Path & path,
               const Revision & revision, Pool & pool)
  throw(ClientException)
  {
    apr_file_t * file = 0;

    if (dstPath.length() > 0)
    {
      apr_status_t status =
        apr_file_open(&file, dstPath.c_str(),
                      APR_WRITE | APR_CREATE |
                      APR_TRUNCATE | APR_BINARY,
                      APR_OS_DEFAULT,
                      pool);
      if (status != 0)
        throw ClientException(status);
    }
    else
    {
      // split the path into its components
      std::string dir, filename, ext;
      path.split(dir, filename, ext);

      // add the revision number to the filename
      char revstring[20];
      if (revision.kind() == revision.HEAD)
        strcpy(revstring, "HEAD");
      else
        sprintf(revstring, "%" SVN_REVNUM_T_FMT, revision.revnum());
      filename += "-";
      filename += revstring;

      // replace the dir component with tempdir
      Path tempPath = Path::getTempDir();
      tempPath.addComponent(filename);

      const char * unique_name;
      svn_error_t * error =
        svn_io_open_unique_file(
          &file, &unique_name,
          tempPath.c_str(),  // path
          ext.c_str(),  // suffix
          0, // dont delete on close
          pool);

      if (error != 0)
        throw ClientException(error);

      dstPath = unique_name;
    }

    return file;
  }
示例#5
0
  svn_revnum_t
  Client::checkout(const char * url,
                   const Path & destPath,
                   const Revision & revision,
                   bool recurse,
                   bool ignore_externals,
                   const Revision & peg_revision) throw(ClientException)
  {
    Pool subPool;
    apr_pool_t * apr_pool = subPool.pool();
    svn_revnum_t revnum = 0;

    svn_error_t * error =
      svn_client_checkout2(&revnum,
                           url,
                           destPath.c_str(),
                           peg_revision.revision(),  // peg_revision
                           revision.revision(),  // revision
                           recurse,
                           ignore_externals,
                           *m_context,
                           apr_pool);

    if (error != NULL)
      throw ClientException(error);

    return revnum;
  }
示例#6
0
  void
  Client::doExport(const Path & from_path,
                   const Path & to_path,
                   const Revision & revision,
                   bool overwrite,
                   const Revision & peg_revision,
                   bool ignore_externals,
                   bool recurse,
                   const char * native_eol) throw(ClientException)
  {
    Pool pool;
    svn_revnum_t revnum = 0;

    svn_error_t * error =
      svn_client_export3(&revnum,
                         from_path.c_str(),
                         to_path.c_str(),
                         peg_revision.revision(),
                         revision.revision(),
                         overwrite,
                         ignore_externals,
                         recurse,
                         native_eol,
                         *m_context,
                         pool);

    if (error != NULL)
      throw ClientException(error);
  }
示例#7
0
  svn_revnum_t
  Client::commit(const Targets & targets,
                 const char * message,
                 bool recurse,
                 bool keep_locks) throw(ClientException)
  {
    Pool pool;

    m_context->setLogMessage(message);

    svn_client_commit_info_t *commit_info = NULL;

    svn_error_t * error =
      svn_client_commit2(&commit_info,
                         targets.array(pool),
                         recurse,
                         keep_locks,
                         *m_context,
                         pool);
    if (error != NULL)
      throw ClientException(error);

    if (commit_info && SVN_IS_VALID_REVNUM(commit_info->revision))
      return commit_info->revision;

    return -1;
  }
示例#8
0
  std::vector<svn_revnum_t>
  Client::update(const Targets & targets,
                 const Revision & revision,
                 bool recurse,
                 bool ignore_externals) throw(ClientException)
  {
    Pool pool;
    apr_array_header_t * result_revs;

    svn_error_t * error =
      svn_client_update2(&result_revs,
                         const_cast<apr_array_header_t*>(targets.array(pool)),
                         revision.revision(),
                         recurse,
                         ignore_externals,
                         *m_context,
                         pool);
    if (error != NULL)
      throw ClientException(error);

    std::vector<svn_revnum_t> revnums;
    int i;
    for (i = 0; i < result_revs->nelts; i++)
    {
      svn_revnum_t revnum=
        APR_ARRAY_IDX(result_revs, i, svn_revnum_t);

      revnums.push_back(revnum);
    }

    return revnums;
  }
示例#9
0
void Client_impl::merge_peg(const MergeParameter &parameters) throw (ClientException)
{
    Pool pool;
    internal::RevisionRangesToHash _rhash(parameters.revisions());

    // todo svn 1.8: svn_client_merge_peg5
    svn_error_t *error =
#if SVN_API_VERSION >= SVN_VERSION_CHECK(1,7,0)
        svn_client_merge_peg4
#else
        svn_client_merge_peg3
#endif
        (
            parameters.path1().cstr(),
            _rhash.array(pool),
            parameters.peg(),
            parameters.localPath().cstr(),
            internal::DepthToSvn(parameters.depth()),
            !parameters.notice_ancestry(),
            parameters.force(),
            parameters.record_only(),
            parameters.dry_run(),
#if SVN_API_VERSION >= SVN_VERSION_CHECK(1,7,0)
            parameters.allow_mixed_rev(),
#endif
            parameters.merge_options().array(pool),
            *m_context,
            pool
        );
    if (error != 0) {
        throw ClientException(error);
    }
}
示例#10
0
  static StatusEntries
  localStatus(const char * path,
              const bool descend,
              const bool get_all,
              const bool update,
              const bool no_ignore,
              Context * context,
              const bool ignore_externals)
  {
    svn_error_t *error;
    StatusEntries entries;
    svn_revnum_t revnum;
    Revision rev(Revision::HEAD);
    Pool pool;

    error = svn_client_status2(
              &revnum,    // revnum
              path,       // path
              rev,        // revision
              statusEntriesFunc, // status func
              &entries,   // status baton
              descend,    // recurse
              get_all,
              update,     // need 'update' to be true to get repository lock info
              no_ignore,
              ignore_externals, // ignore_externals
              *context,   // client ctx
              pool);

    if (error!=NULL)
      throw ClientException(error);

    return entries;
  }
示例#11
0
  const LogEntries *
  Client::log(const char * path, const Revision & revisionStart,
              const Revision & revisionEnd, bool discoverChangedPaths,
              bool strictNodeHistory) throw(ClientException)
  {
    Pool pool;
    Targets target(path);
    LogEntries * entries = new LogEntries();
    svn_error_t *error;
    int limit = 0;

    error = svn_client_log2(
              target.array(pool),
              revisionStart.revision(),
              revisionEnd.revision(),
              limit,
              discoverChangedPaths ? 1 : 0,
              strictNodeHistory ? 1 : 0,
              logReceiver,
              entries,
              *m_context, // client ctx
              pool);

    if (error != NULL)
    {
      delete entries;
      throw ClientException(error);
    }

    return entries;
  }
示例#12
0
  static svn_revnum_t
  localFilteredStatus(const char * path,
                      const StatusFilter & filter,
                      const bool descend,
                      const bool update,
                      StatusEntries & entries,
                      Context * context)
  {
    svn_error_t *error;
    svn_revnum_t revnum;
    Revision rev(Revision::HEAD);
    Pool pool;
    StatusBaton baton(filter, entries);

    error = svn_client_status2(
              &revnum,    // revnum
              path,       // path
              rev,        // revision
              filteredStatusFunc, // status func
              &baton,   // status baton
              descend,    // recurse
              filter.showUnmodified,
              update,     // need 'update' to be true to get repository lock info
              filter.showIgnored, // no_ignores
              !filter.showExternals, // ignore_externals
              *context,   // client ctx
              pool);

    if (error!=NULL)
      throw ClientException(error);

    return revnum;
  }
示例#13
0
  void
  Client::merge(const Path & path1, const Revision & revision1,
                const Path & path2, const Revision & revision2,
                const Path & localPath, bool force,
                bool recurse,
                bool notice_ancestry,
                bool dry_run) throw(ClientException)
  {
    Pool pool;
    svn_error_t * error =
      svn_client_merge(path1.c_str(),
                       revision1.revision(),
                       path2.c_str(),
                       revision2.revision(),
                       localPath.c_str(),
                       recurse,
                       !notice_ancestry,
                       force,
                       dry_run,
                       *m_context,
                       pool);

    if (error != NULL)
      throw ClientException(error);
  }
示例#14
0
  DirEntries
  Client::list(const char * pathOrUrl,
               svn_opt_revision_t * revision,
               bool recurse) throw(ClientException)
  {
    Pool pool;

    DirEntries entries;
    svn_error_t * error =
      svn_client_list2(pathOrUrl,
                       revision,
                       revision,
                       recurse ? svn_depth_infinity : svn_depth_immediates,
                       SVN_DIRENT_ALL,
                       true,
                       listEntriesFunc,
                       &entries,
                       *m_context,
                       pool);

    if (error != 0)
      throw ClientException(error);

    return entries;
  }
示例#15
0
  AnnotatedFile *
  Client::annotate(const Path & path,
                   const Revision & revisionStart,
                   const Revision & revisionEnd) throw(ClientException)
  {
    Pool pool;
    AnnotatedFile * entries = new AnnotatedFile;
    svn_error_t *error;
    error = svn_client_blame(
              path.c_str(),
              revisionStart.revision(),
              revisionEnd.revision(),
              annotateReceiver,
              entries,
              *m_context, // client ctx
              pool);

    if (error != NULL)
    {
      delete entries;
      throw ClientException(error);
    }

    return entries;
  }
示例#16
0
/*!
    \fn svn::Repository::hotcopy(const QString&src,const QString&dest,bool cleanlogs)
 */
void Repository::hotcopy(const QString&src,const QString&dest,bool cleanlogs)throw (ClientException)
{
    svn_error_t * error = RepositoryData::hotcopy(src,dest,cleanlogs);
    if (error!=0) {
        throw ClientException (error);
    }
}
示例#17
0
void Repository::CreateOpen(const CreateRepoParameter&params) throw (ClientException)
{
    svn_error_t * error = m_Data->CreateOpen(params);
    if (error!=0) {
        throw ClientException (error);
    }
}
示例#18
0
/*!
    \fn svn::Repository::dump(const QString&output,const svn::Revision&start,const svn::Revision&end, bool incremental, bool use_deltas)throw (ClientException)
 */
void Repository::dump(const QString&output,const svn::Revision&start,const svn::Revision&end, bool incremental, bool use_deltas)throw (ClientException)
{
    svn_error_t * error = m_Data->dump(output,start,end,incremental,use_deltas);
    if (error!=0) {
        throw ClientException (error);
    }
}
示例#19
0
  /**
   * set property in @a path no matter whether local or
   * repository
   *
   * @param path
   * @param revision
   * @param propName
   * @param propValue
   * @param recurse
   * @param revprop
   * @return PropertiesList
   */
  svn_revnum_t
  Client::revpropset(const char *propName,
                     const char *propValue,
                     const Path &path,
                     const Revision &revision,
                     bool force)
  {
    Pool pool;

    const svn_string_t * propval
    = svn_string_create((const char *) propValue, pool);

    svn_revnum_t revnum;
    svn_error_t * error =
      svn_client_revprop_set(propName,
                             propval,
                             path.c_str(),
                             revision.revision(),
                             &revnum,
                             force,
                             *m_context,
                             pool);
    if (error != nullptr)
      throw ClientException(error);

    return revnum;
  }
示例#20
0
/*!
    \fn svn::Repository::Open(const QString&)
 */
void Repository::Open(const QString&name) throw (ClientException)
{
    svn_error_t * error = m_Data->Open(name);
    if (error!=0) {
        throw ClientException (error);
    }
}
示例#21
0
  void
  Client::get(Path & dstPath,
              const Path & path,
              const Revision & revision,
              const Revision & peg_revision) throw(ClientException)
  {
    Pool pool;

    // create a new file and suppose we only want
    // this users to be able to read and write the file

    apr_file_t * file = openTempFile(dstPath, path, revision, pool);

    // now create a stream and let svn_client_cat write to the
    // stream
    svn_stream_t * stream = svn_stream_from_aprfile(file, pool);
    if (stream != 0)
    {
      svn_error_t * error = svn_client_cat2(
                              stream,
                              path.c_str(),
                              peg_revision.revision() ,
                              revision.revision(),
                              *m_context,
                              pool);

      if (error != 0)
        throw ClientException(error);

      svn_stream_close(stream);
    }

    // finalize stuff
    apr_file_close(file);
  }
示例#22
0
  std::pair<svn_revnum_t,std::string>
  Client::revpropget(const char *propName,
                     const Path &path,
                     const Revision &revision)
  {
    Pool pool;

    svn_string_t *propval;
    svn_revnum_t revnum;
    svn_error_t * error =
      svn_client_revprop_get(propName,
                             &propval,
                             path.c_str(),
                             revision.revision(),
                             &revnum,
                             *m_context,
                             pool);
    if (error != nullptr)
    {
      throw ClientException(error);
    }

    // if the property does not exist NULL is returned
    if (propval == nullptr)
      return std::pair<svn_revnum_t,std::string> (0, std::string());

    return std::pair<svn_revnum_t,std::string> (revnum, std::string(propval->data));
  }
示例#23
0
Client::Client(Resources& resources, Subsystem& subsystem, hostaddr_t host,
    hostport_t port, Configuration& config, const std::string& password)
    throw (Exception)
    : ClientServer(host, port),
      Gui(resources, subsystem, resources.get_font("normal")),
      OptionsMenu(*this, resources, subsystem, config, this),
      resources(resources), subsystem(subsystem), player_config(config),
      logged_in(false), me(0), updatecnt(0),
      factory(resources, subsystem, this), my_id(0), login_sent(false),
      throw_exception(false), exception_msg(), force_send(false),
      fhnd(0), running(true), reload_resources(true)
{
    conn = 0;
    get_now(last);
    update_text_fade_speed();

    /* start data receiver thread */
    if (!thread_start()) {
        throw ClientException("Starting client thread failed.");
    }

    /* login */
    GPlayerDescription player_desc;
    memset(&player_desc, 0, sizeof(GPlayerDescription));
    strncpy(player_desc.player_name, player_config.get_player_name().c_str(), NameLength - 1);
    strncpy(player_desc.characterset_name, player_config.get_player_skin().c_str(), NameLength - 1);
    {
        Scope<Mutex> lock(mtx);
        login(password, GPlayerDescriptionLen, &player_desc);
    }
    binding.extract_from_config(player_config);

    /* start music player */
    subsystem.start_music_player(resources, *this, config.get_string("external_music").c_str());
}
示例#24
0
Client::Client(const std::string& config_file)
  : m_id(UNKNOWN_ID), m_name(""), m_email(""), m_auth_token(""), m_channel(0), m_dest_id(UNKNOWN_ID)
  , m_is_connected(false), m_is_stopped(false), m_private_secure_chat(false)
  , m_socket(-1), m_ip_address(""), m_port("http") {
  if (!readConfiguration(config_file)) {
    throw ClientException();
  }
}
示例#25
0
Client::Client(std::string const& port, std::string const& ip) :
  ANetwork(port), _ip(ip)  {
  int err;
  struct sockaddr_in s_in;
  struct addrinfo hints;
  struct addrinfo *ai;

  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((err = getaddrinfo(ip.data(), port.data(), &hints, &ai)))
    throw ClientException(std::string("getaddrinfo : ") + gai_strerror(err));
  if ((_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1)
    throw ClientException(std::string("socket : ") + strerror(errno));
  if (connect(_socket, reinterpret_cast<struct sockaddr *>(&s_in), sizeof(s_in)) == -1) {
    close(_socket);
    throw ClientException(std::string("connect : ") + strerror(errno));
  }
  freeaddrinfo(ai);
}
示例#26
0
文件: wc.cpp 项目: RapidSVN/RapidSVN
  void
  Wc::setAdmDir(const char * dir)
  {
    Pool pool;

    svn_error_t * error =
      svn_wc_set_adm_dir(dir, pool);

    if (error != NULL)
      throw ClientException(error);
  }
示例#27
0
bool Client_impl::RepoHasCapability(const Path &repository, Capability capability)
{
    svn_error_t *error = 0;
    Pool pool;

    svn_ra_session_t *session = 0;
    // todo svn 1.8: svn_client_open_ra_session2
    error = svn_client_open_ra_session(&session,
                                       repository.cstr(),
                                       *m_context,
                                       pool);
    if (error != 0) {
        throw ClientException(error);
    }
    if (!session) {
        return false;
    }
    const char *capa = 0;
    switch (capability) {
    case CapabilityMergeinfo:
        capa = SVN_RA_CAPABILITY_MERGEINFO;
        break;
    case CapabilityDepth:
        capa = SVN_RA_CAPABILITY_DEPTH;
        break;
    case CapabilityCommitRevProps:
        capa = SVN_RA_CAPABILITY_COMMIT_REVPROPS;
        break;
    case CapabilityLogRevProps:
        capa = SVN_RA_CAPABILITY_LOG_REVPROPS;
        break;
    default:
        return false;
    }
    svn_boolean_t has = 0;
    error = svn_ra_has_capability(session, &has, capa, pool);
    if (error != 0) {
        throw ClientException(error);
    }
    return has;
}
示例#28
0
  void
  Client::cleanup(const Path & path) throw(ClientException)
  {
    Pool subPool;
    apr_pool_t * apr_pool = subPool.pool();

    svn_error_t * error =
      svn_client_cleanup(path.c_str(), *m_context, apr_pool);

    if (error != NULL)
      throw ClientException(error);
  }
示例#29
0
// ----------------------------------------------------------------------------
void SecureClient::init() {
  SSL_load_error_strings();
  ERR_load_BIO_strings();
  OpenSSL_add_all_algorithms();

  m_ssl_context = SSL_CTX_new(SSLv23_client_method());

  // loading the Trust Store
  if(!SSL_CTX_load_verify_locations(m_ssl_context, "../client/certs/TrustStore.pem", nullptr)) {
    ERR("Failed to load the Trust Store of certificates: %s", ERR_reason_error_string(ERR_get_error()));
    throw ClientException();
  }

  m_bio = BIO_new_ssl_connect(m_ssl_context);
  if (m_bio == nullptr) {
    ERR("Failed to prepare new secure connection: %s", ERR_reason_error_string(ERR_get_error()));
    throw ClientException();
  }
  BIO_get_ssl(m_bio, &m_ssl);
  SSL_set_mode(m_ssl, SSL_MODE_AUTO_RETRY);  // retry handshake transparently if Server suddenly wants

  // establish secure connection
  BIO_set_conn_hostname(m_bio, m_ip_address.c_str());
  BIO_set_conn_port(m_bio, m_port.c_str());
  if (BIO_do_connect(m_bio) <= 0) {
    ERR("Failed to securely connect to [%s:%s]: %s", m_ip_address.c_str(), m_port.c_str(), ERR_reason_error_string(ERR_get_error()));
    m_is_connected = false;
  } else {
    m_is_connected = true;
  }

  // checking certificate from Server
  if (SSL_get_verify_result(m_ssl) != X509_V_OK) {
    WRN("Certificate verification has failed: %s", ERR_reason_error_string(ERR_get_error()));
    // TODO: probably, proceed further
  }

  INF("Secure connection has been established");
  m_api_impl = new SecureClientApiImpl(m_bio, m_ip_address, m_port);
}
示例#30
0
  void
  Client::unlock(const Targets & targets, bool force) throw(ClientException)
  {
    Pool pool;

    svn_error_t * error =
      svn_client_unlock(const_cast<apr_array_header_t*>(targets.array(pool)),
                        force,
                        *m_context,
                        pool);
    if (error != NULL)
      throw ClientException(error);
  }