Esempio n. 1
0
  @Command
  public void onNewIndex()
      throws SearchLibException, InterruptedException, IOException, NamingException {
    String msg = null;
    if (indexName == null) msg = "Please enter a valid name for the new index";
    else if (indexName.length() == 0) msg = "Please enter a valid name for the new index";
    else if (ClientCatalog.exists(getLoggedUser(), indexName)) msg = "The name already exists";

    if (msg != null) {
      new AlertController(msg);
      return;
    }
    ClientCatalog.createIndex(getLoggedUser(), indexName, indexTemplate.getTemplate(), null);
    setClient(ClientCatalog.getClient(indexName));
  }
Esempio n. 2
0
 public void setClientName(ClientCatalogItem item) throws SearchLibException, NamingException {
   if (item == null) return;
   Client client = ClientCatalog.getClient(item.getIndexName());
   if (client == null) return;
   setClient(client);
   selectedClientCatalogItem = item;
 }
 public Client getClient() {
   try {
     return ClientCatalog.getClient(indexName);
   } catch (SearchLibException e) {
     Logging.error(e);
     return null;
   }
 }
Esempio n. 4
0
 @Override
 @NotifyChange("#indexList")
 protected void onYes() throws SearchLibException {
   try {
     ClientCatalog.eraseIndex(getLoggedUser(), indexName);
     setClient(null);
   } catch (NamingException e) {
     throw new SearchLibException(e);
   } catch (IOException e) {
     throw new SearchLibException(e);
   }
 }
  @Override
  protected void doRequest(ServletTransaction transaction) throws ServletException {
    try {

      User user = transaction.getLoggedUser();
      if (user != null && !user.isAdmin()) throw new SearchLibException("Not permitted");

      Client client = transaction.getClient();

      String cmd = transaction.getParameterString("cmd");
      if (CALL_XML_CMD_INIT.equals(cmd)) {
        transaction.addXmlResponse(CALL_XML_KEY_CMD, CALL_XML_CMD_INIT);
        ClientCatalog.receive_init(client);
        transaction.addXmlResponse(XML_CALL_KEY_STATUS, XML_CALL_KEY_STATUS_OK);
        return;
      }
      if (CALL_XML_CMD_SWITCH.equals(cmd)) {
        transaction.addXmlResponse(CALL_XML_KEY_CMD, CALL_XML_CMD_SWITCH);
        ClientCatalog.receive_switch(transaction.getWebApp(), client);
        transaction.addXmlResponse(XML_CALL_KEY_STATUS, XML_CALL_KEY_STATUS_OK);
        return;
      }
      if (CALL_XML_CMD_MERGE.equals(cmd)) {
        transaction.addXmlResponse(CALL_XML_KEY_CMD, CALL_XML_CMD_MERGE);
        ClientCatalog.receive_merge(transaction.getWebApp(), client);
        transaction.addXmlResponse(XML_CALL_KEY_STATUS, XML_CALL_KEY_STATUS_OK);
        return;
      }
      if (CALL_XML_CMD_ABORT.equals(cmd)) {
        transaction.addXmlResponse(CALL_XML_KEY_CMD, CALL_XML_CMD_ABORT);
        ClientCatalog.receive_abort(client);
        transaction.addXmlResponse(XML_CALL_KEY_STATUS, XML_CALL_KEY_STATUS_OK);
        return;
      }
      String filePath = transaction.getParameterString(CALL_XML_CMD_FILEPATH);
      Long lastModified = transaction.getParameterLong("lastModified", 0L);
      Long length = transaction.getParameterLong("length", 0L);
      if (CALL_XML_CMD_EXISTS.equals(cmd)) {
        transaction.addXmlResponse(CALL_XML_KEY_CMD, CALL_XML_CMD_EXISTS);
        boolean exist = ClientCatalog.receive_file_exists(client, filePath, lastModified, length);
        transaction.addXmlResponse(CALL_XML_KEY_EXISTS, Boolean.toString(exist));
        transaction.addXmlResponse(XML_CALL_KEY_STATUS, XML_CALL_KEY_STATUS_OK);
        return;
      }
      transaction.addXmlResponse(CALL_XML_KEY_CMD, CALL_XML_CMD_FILEPATH);
      if (FilenameUtils.getName(filePath).startsWith(".")) {
        transaction.addXmlResponse(XML_CALL_KEY_STATUS, XML_CALL_KEY_STATUS_OK);
        return;
      }
      filePath = FileUtils.unixToSystemPath(filePath);
      if (transaction.getParameterBoolean("type", "dir", false))
        ClientCatalog.receive_dir(client, filePath);
      else ClientCatalog.receive_file(client, filePath, lastModified, transaction.getInputStream());
      transaction.addXmlResponse(XML_CALL_KEY_STATUS, XML_CALL_KEY_STATUS_OK);
    } catch (SearchLibException e) {
      throw new ServletException(e);
    } catch (NamingException e) {
      throw new ServletException(e);
    } catch (InterruptedException e) {
      throw new ServletException(e);
    } catch (IOException e) {
      throw new ServletException(e);
    }
  }
 public void computeInfos() throws SearchLibException {
   lastModifiedAndSize = ClientCatalog.getLastModifiedAndSize(indexName);
 }
Esempio n. 7
0
 public Set<ClientCatalogItem> getClientCatalog() throws SearchLibException {
   if (catalogItems != null) return catalogItems;
   catalogItems = ClientCatalog.getClientCatalog(getLoggedUser());
   return catalogItems;
 }