Example #1
0
  /* (non-Javadoc)
   * @see org.alfresco.repo.tenant.TenantService#getName(org.alfresco.service.cmr.repository.StoreRef)
   */
  public StoreRef getName(StoreRef storeRef) {
    if (storeRef == null) {
      return null;
    }

    return new StoreRef(storeRef.getProtocol(), getName(storeRef.getIdentifier()));
  }
  /**
   * Constructor
   *
   * @param storeRef the store reference (e.g. 'workspace://SpacesStore' )
   * @param path the path (e.g. '/app:company_home/app:dictionary/app:models' )
   * @param queryLanguage the query language (e.g. 'xpath' or 'lucence')
   */
  public RepositoryLocation(StoreRef storeRef, String path, String queryLanguage) {
    this.storeProtocol = storeRef.getProtocol();
    this.storeId = storeRef.getIdentifier();
    this.path = path;

    setQueryLanguage(queryLanguage);
  }
 @Override
 protected List<StoreRef> getAllStores() {
   List<AVMStoreDescriptor> stores = avmService.getStores();
   List<StoreRef> storeRefs = new ArrayList<StoreRef>(stores.size());
   for (AVMStoreDescriptor storeDesc : stores) {
     StoreRef storeRef = AVMNodeConverter.ToStoreRef(storeDesc.getName());
     if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(storeRef.getIdentifier())
         == IndexMode.UNINDEXED) {
       // ALF-5722 fix
       continue;
     }
     storeRefs.add(storeRef);
   }
   return storeRefs;
 }
Example #4
0
  /* (non-Javadoc)
   * @see org.alfresco.repo.tenant.TenantService#getName(java.lang.String, org.alfresco.service.cmr.repository.StoreRef)
   */
  public StoreRef getName(String username, StoreRef storeRef) {
    if (storeRef == null) {
      return null;
    }

    if (username != null) {
      int idx = username.lastIndexOf(SEPARATOR);
      if ((idx > 0) && (idx < (username.length() - 1))) {
        String tenantDomain = username.substring(idx + 1);
        return new StoreRef(
            storeRef.getProtocol(), getName(storeRef.getIdentifier(), tenantDomain));
      }
    }

    return storeRef;
  }
  /**
   * Executes a solr query for statistics
   *
   * @param searchParameters StatsParameters
   * @return SolrStatsResult
   */
  public SolrStatsResult executeStatsQuery(final StatsParameters searchParameters) {
    if (repositoryState.isBootstrapping()) {
      throw new AlfrescoRuntimeException(
          "SOLR stats queries can not be executed while the repository is bootstrapping");
    }

    try {
      StoreRef store = extractStoreRef(searchParameters);
      SolrStoreMappingWrapper mapping = extractMapping(store);
      Locale locale = extractLocale(searchParameters);

      Pair<HttpClient, String> httpClientAndBaseUrl = mapping.getHttpClientAndBaseUrl();
      HttpClient httpClient = httpClientAndBaseUrl.getFirst();
      String url = buildStatsUrl(searchParameters, httpClientAndBaseUrl.getSecond(), locale);
      JSONObject body =
          buildStatsBody(searchParameters, tenantService.getCurrentUserDomain(), locale);

      if (httpClient == null) {
        throw new AlfrescoRuntimeException("No http client for store " + store.toString());
      }

      return (SolrStatsResult)
          postSolrQuery(
              httpClient,
              url,
              body,
              new SolrJsonProcessor<SolrStatsResult>() {

                @Override
                public SolrStatsResult getResult(JSONObject json) {
                  return new SolrStatsResult(json, searchParameters.isDateSearch());
                }
              });

    } catch (UnsupportedEncodingException e) {
      throw new LuceneQueryParserException("stats", e);
    } catch (HttpException e) {
      throw new LuceneQueryParserException("stats", e);
    } catch (IOException e) {
      throw new LuceneQueryParserException("stats", e);
    } catch (JSONException e) {
      throw new LuceneQueryParserException("stats", e);
    }
  }