org.alfresco.service.cmr.search.SearchService Java Examples

The following examples show how to use org.alfresco.service.cmr.search.SearchService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Search.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Execute a Lucene search (sorted)
 * 
 * @param store    Store reference to search against i.e. workspace://SpacesStore
 * @param search   Lucene search string to execute
 * @param sortColumn  column to sort on
 * @param asc      true => ascending sort
 * 
 * @return JavaScript array of Node results from the search - can be empty but not null
 */
public Scriptable luceneSearch(String store, String search, String sortColumn, boolean asc, int max)
{
    if (search == null || search.length() == 0)
    {
        return Context.getCurrentContext().newArray(getScope(), 0);
    }
    
    SortColumn[] sort = null;
    if (sortColumn != null && sortColumn.length() != 0)
    {
        sort = new SortColumn[1];
        sort[0] = new SortColumn(sortColumn, asc);
    }
    Object[] results = query(store, search, sort, SearchService.LANGUAGE_LUCENE, max, 0);
    return Context.getCurrentContext().newArray(getScope(), results);
}
 
Example #2
Source File: SolrStatsService.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public StatsResultSet query(StatsParameters searchParameters)
{
    searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    
    LuceneQueryLanguageSPI language = searcher.getQueryLanguages().get(searchParameters.getLanguage().toLowerCase());
    if (language != null && SearchService.LANGUAGE_SOLR_FTS_ALFRESCO.equals(language.getName()))
    {
        SolrQueryLanguage solr = (SolrQueryLanguage) language;
        return solr.executeStatsQuery(searchParameters);
    }
    else
    {
        throw new SearcherException("Unknown stats query language: " + searchParameters.getLanguage());
    }
}
 
Example #3
Source File: InviteModeratedSenderTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @return ServiceRegistry
 */
private ServiceRegistry mockServices()
{
    ActionService mockActionService = mockActionService();
    NodeService mockNodeService = mockNodeService();
    PersonService mockPersonService = mockPersonService();
    SearchService mockSearchService = mockSearchService();
    SiteService mockSiteService = mockSiteService();
    FileFolderService mockFileFolderService = mockFileFolderService();

    ServiceRegistry services = mock(ServiceRegistry.class);
    when(services.getActionService()).thenReturn(mockActionService);
    when(services.getNodeService()).thenReturn(mockNodeService);
    when(services.getPersonService()).thenReturn(mockPersonService);
    when(services.getSearchService()).thenReturn(mockSearchService);
    when(services.getSiteService()).thenReturn(mockSiteService);
    when(services.getFileFolderService()).thenReturn(mockFileFolderService);
    return services;
}
 
Example #4
Source File: QueryBuilder.java    From alfresco-mvc with Apache License 2.0 6 votes vote down vote up
public static String escape(final String language, final String string) {
	if (!SearchService.LANGUAGE_LUCENE.equals(language)) {
		return string;
	}

	final int numOfCharsToAdd = 4;

	StringBuilder builder = new StringBuilder(string.length() + numOfCharsToAdd);
	for (int i = 0; i < string.length(); i++) {
		char character = string.charAt(i);
		if ((character == '{') || (character == '}') || (character == ':') || (character == '-')) {
			builder.append('\\');
		}

		builder.append(character);
	}
	return builder.toString();
}
 
Example #5
Source File: WebDAVMethodTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void setUpApplicationContext()
{
    ApplicationContext appContext = ApplicationContextHelper.getApplicationContext(new String[]
            {
                    "classpath:alfresco/application-context.xml", "classpath:alfresco/web-scripts-application-context.xml",
                    "classpath:alfresco/remote-api-context.xml"
            });

    this.nodeService = (NodeService) appContext.getBean("NodeService");
    this.searchService = (SearchService) appContext.getBean("SearchService");
    this.namespaceService = (NamespaceService) appContext.getBean("NamespaceService");
    this.tenantService = (TenantService) appContext.getBean("tenantService");
    this.transactionService = (TransactionService) appContext.getBean("transactionService");
    this.webDAVHelper = (WebDAVHelper) appContext.getBean("webDAVHelper");
    this.tenantAdminService = (TenantAdminService) appContext.getBean("tenantAdminService");

    // Authenticate as system to create initial test data set
    AuthenticationComponent authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent");
    authenticationComponent.setSystemUserAsCurrentUser();
}
 
Example #6
Source File: RepoAdminServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();
    
    repoAdminService = (RepoAdminService) ctx.getBean("RepoAdminService");
    dictionaryService = (DictionaryService) ctx.getBean("DictionaryService");
    transactionService = (TransactionService) ctx.getBean("TransactionService");
    nodeService = (NodeService) ctx.getBean("NodeService");
    contentService = (ContentService) ctx.getBean("ContentService");
    searchService = (SearchService) ctx.getBean("SearchService");
    namespaceService = (NamespaceService) ctx.getBean("NamespaceService");
    behaviourFilter = (BehaviourFilter)ctx.getBean("policyBehaviourFilter");
    dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    
    DbNodeServiceImpl dbNodeService = (DbNodeServiceImpl)ctx.getBean("dbNodeService");
    dbNodeService.setEnableTimestampPropagation(false);
    
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
}
 
Example #7
Source File: Search.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Execute the query
 * 
 * Removes any duplicates that may be present (ID search can cause duplicates -
 * it is better to remove them here)
 * 
 * @param store         StoreRef to search against - null for default configured store
 * @param search        Lucene search to execute
 * @param sort          Columns to sort by
 * @param language      Search language to use e.g. SearchService.LANGUAGE_LUCENE
 * @param maxResults    Maximum results to return if > 0
 * @param skipResults   Results to skip in the result set
 * 
 * @return Array of Node objects
 */
protected Object[] query(String store, String search, SortColumn[] sort, String language, int maxResults, int skipResults)
{   
    SearchParameters sp = new SearchParameters();
    sp.addStore(store != null ? new StoreRef(store) : this.storeRef);
    sp.setLanguage(language != null ? language : SearchService.LANGUAGE_LUCENE);
    sp.setQuery(search);
    if (maxResults > 0)
    {
        sp.setLimit(maxResults);
        sp.setLimitBy(LimitBy.FINAL_SIZE);
    }
    if (skipResults > 0)
    {
        sp.setSkipCount(skipResults);
    }
    if (sort != null)
    {
        for (SortColumn sd : sort)
        {
            sp.addSort(sd.column, sd.asc);
        }
    }
    
    return query(sp, true);
}
 
Example #8
Source File: PropertyValueConstraint.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public SearchParameters applyDecorations(ActualEnvironment environment, SearchParameters searchParameters,
            VirtualQuery query) throws VirtualizationException
{
    // TODO: allow custom language and not only constraint appliers

    if (SearchService.LANGUAGE_FTS_ALFRESCO.equals(searchParameters.getLanguage()))
    {
        SearchParameters searchParametersCopy = searchParameters.copy();
        return applyFTS(searchParametersCopy);
    }
    else
    {
        throw new VirtualizationException("Unsupported constrating language " + searchParameters.getLanguage());
    }

}
 
Example #9
Source File: RepoTransferReceiverImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void before() throws Exception
{
    super.before();
    System.out.println("java.io.tmpdir == " + System.getProperty("java.io.tmpdir"));

    // Get the required services
    this.nodeService = (NodeService) this.applicationContext.getBean("nodeService");
    this.contentService = (ContentService) this.applicationContext.getBean("contentService");
    this.authenticationService = (MutableAuthenticationService) this.applicationContext
            .getBean("authenticationService");
    this.actionService = (ActionService) this.applicationContext.getBean("actionService");
    this.transactionService = (TransactionService) this.applicationContext.getBean("transactionComponent");
    this.authenticationComponent = (AuthenticationComponent) this.applicationContext
            .getBean("authenticationComponent");
    this.receiver = (RepoTransferReceiverImpl) this.applicationContext.getBean("transferReceiver");
    this.policyComponent = (PolicyComponent) this.applicationContext.getBean("policyComponent");
    this.searchService = (SearchService) this.applicationContext.getBean("searchService");
    this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper");
    this.namespaceService = (NamespaceService) this.applicationContext.getBean("namespaceService");
    this.dummyContent = "This is some dummy content.";        
    this.dummyContentBytes = dummyContent.getBytes("UTF-8");
    authenticationComponent.setSystemUserAsCurrentUser();

    guestHome = repositoryHelper.getGuestHome();
    TestTransaction.flagForCommit();
    TestTransaction.end();
}
 
Example #10
Source File: SolrFacetServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the {@link NodeRef} of the {@code srft:facets} folder, if it exists.
 * @return the {@link NodeRef} if it exists, else {@code null}.
 */
public NodeRef getFacetsRoot()
{
    NodeRef facetHomeRef = (NodeRef) singletonCache.get(KEY_FACETS_HOME_NODEREF);
    if (facetHomeRef == null)
    {
        facetHomeRef = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
        {
            public NodeRef doWork() throws Exception
            {
                return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
                {
                    public NodeRef execute() throws Exception
                    {
                        NodeRef result = null;

                        // Get the root 'facets' folder
                        NodeRef rootNodeRef = nodeService.getRootNode(FACET_STORE);
                        List<NodeRef> results = searchService.selectNodes(rootNodeRef, facetsRootXPath, null,
                                    namespaceService, false, SearchService.LANGUAGE_XPATH);
                        if (results.size() != 0)
                        {
                            result = results.get(0);
                        }

                        return result;
                    }
                }, true);
            }
        }, AuthenticationUtil.getSystemUserName());

        if (facetHomeRef != null) { singletonCache.put(KEY_FACETS_HOME_NODEREF, facetHomeRef); }
    }
    return facetHomeRef;
}
 
Example #11
Source File: CronScheduledQueryBasedTemplateActionDefinitionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Check the nodes to be indexed
 * 
 * @param nodes
 * @throws Exception
 */
private void checkNodes(List<FileInfo> nodes) throws Exception
{
    SearchService searchService = registry.getSearchService();
    
    boolean notFound = false;
    for (int i = 1; i <= 40; i++)
    {
        notFound = false;
        for (FileInfo fileInfo : nodes)
        {
            ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home//cm:" + TEST_FOLDER_NAME + "//cm:" + fileInfo.getName() + "\"");
            if (resultSet.length() == 0)
            {
                notFound = true;
                break;
            }
        }
        if (notFound)
        {
            Thread.sleep(500);
        }
        else
        {
            break;
        }
    }
    assertFalse("The content was not created or indexed correctly.", notFound);
}
 
Example #12
Source File: DeleteMethodTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void setUp() throws Exception
{
    transactionService = ctx.getBean("transactionService", TransactionService.class);
    searchService = ctx.getBean("SearchService", SearchService.class);
    nodeService = ctx.getBean("NodeService", NodeService.class);
    contentService = ctx.getBean("contentService", ContentService.class);
    webDAVHelper = ctx.getBean("webDAVHelper", WebDAVHelper.class);         
    repositoryHelper = (Repository)ctx.getBean("repositoryHelper");
    companyHomeNodeRef = repositoryHelper.getCompanyHome();
}
 
Example #13
Source File: CMMDownloadTestUtil.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CMMDownloadTestUtil(ApplicationContext ctx)
{
    this.transactionHelper = ctx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    this.contentService = ctx.getBean("contentService", ContentService.class);
    this.searchService = ctx.getBean("searchService", SearchService.class);
    this.nodeService = ctx.getBean("nodeService", NodeService.class);
    this.namespaceService = ctx.getBean("namespaceService", NamespaceService.class);
    this.downloadService = ctx.getBean("downloadService", DownloadService.class);
}
 
Example #14
Source File: SolrIndexerAndSearcherFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public SearchService getSearcher(StoreRef storeRef, boolean searchDelta) throws SearcherException
{
     SolrSearchService searchService = new SolrSearchService();
     searchService.setDictionaryService(dictionaryService);
     searchService.setNamespacePrefixResolver(namespacePrefixResolver);
     searchService.setNodeService(nodeService);
     searchService.setQueryLanguages(getQueryLanguages());
     searchService.setQueryRegister(queryRegister);
     return searchService;
}
 
Example #15
Source File: VirtualQueryImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();

    query = new VirtualQueryImpl(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.toString(),
                                 SearchService.LANGUAGE_FTS_ALFRESCO,
                                 QUERY_TEST_STRING_QUERY);

    mockitoActualEnvironment = Mockito.mock(ActualEnvironment.class);
    Mockito.when(mockitoActualEnvironment.query(Mockito.any(SearchParameters.class)))
                    .thenReturn(new EmptyResultSet());

    mockitoPrefixResolver = Mockito.mock(NamespacePrefixResolver.class);
    Mockito.when(mockitoPrefixResolver.getNamespaceURI(TST_PREFIX)).thenReturn(TEST_URI);
    Mockito.when(mockitoPrefixResolver.getPrefixes(TEST_URI)).thenReturn(Arrays.asList(TST_PREFIX));

    Mockito.when(mockitoActualEnvironment.getNamespacePrefixResolver()).thenReturn(mockitoPrefixResolver);

    testQName1 = QName.createQName(TST_PREFIX,
                                   TEST_LOCAL_NAME_1,
                                   mockitoPrefixResolver);

    testQName2 = QName.createQName(TST_PREFIX,
                                   TEST_LOCAL_NAME_2,
                                   mockitoPrefixResolver);

    NodeRef n1 = new NodeRef("workspace://SpacesStore/17c8f11d-0936-4295-88a0-12b85764c76f");
    NodeRef n2 = new NodeRef("workspace://SpacesStore/27c8f11d-0936-4295-88a0-12b85764c76f");
    nodeOneReference = ((VirtualProtocol) Protocols.VIRTUAL.protocol).newReference(n1,
                                                                                   "/1",
                                                                                   n2);
}
 
Example #16
Source File: CustomModelServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private List<CompiledModel> getAllCustomM2Models(boolean onlyInactiveModels)
{
    List<CompiledModel> result = new ArrayList<>();

    StringBuilder builder = new StringBuilder(160);
    builder.append(repoModelsLocation.getPath()).append(RepoAdminServiceImpl.CRITERIA_ALL).append("[(")
                .append(RepoAdminServiceImpl.defaultSubtypeOfDictionaryModel).append(" and ").append(DEFAULT_CUSTOM_MODEL_ASPECT);
    if (onlyInactiveModels)
    {
        builder.append(" and @cm:modelActive='false'");
    }
    builder.append(")]");

    List<NodeRef> nodeRefs = searchService.selectNodes(getRootNode(), builder.toString(), null, namespaceDAO, false,
                SearchService.LANGUAGE_XPATH);

    if (nodeRefs.size() > 0)
    {
        for (NodeRef nodeRef : nodeRefs)
        {
            try
            {
                M2Model m2Model = getM2Model(nodeRef);
                if (m2Model == null)
                {
                    logger.warn("Couldn't construct M2Model from nodeRef:" + nodeRef);
                    continue;
                }
                result.add(compileModel(m2Model));
            }
            catch (Throwable t)
            {
                logger.warn("Skip model (" + t.getMessage() + ")");
            }
        }
    }

    return result;
}
 
Example #17
Source File: Search.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Execute a Lucene search
 * 
 * @param store         Store reference to search against i.e. workspace://SpacesStore
 * @param search        Lucene search string to execute
 * 
 * @return JavaScript array of Node results from the search - can be empty but not null
 */
public Scriptable luceneSearch(String store, String search)
{
    if (search != null && search.length() != 0)
    {
        Object[] results = query(store, search, null, SearchService.LANGUAGE_LUCENE);
        return Context.getCurrentContext().newArray(getScope(), results);
    }
    else
    {
        return Context.getCurrentContext().newArray(getScope(), 0);
    }
}
 
Example #18
Source File: SolrSearchService.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public List<Serializable> selectProperties(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
        boolean followAllParentLinks) throws InvalidNodeRefException, XPathException
{
    return selectProperties(contextNodeRef, xpath, parameters, namespacePrefixResolver, followAllParentLinks, SearchService.LANGUAGE_XPATH);

}
 
Example #19
Source File: SolrQueryHTTPClientTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private StatsParameters getParameters()
{

    StringBuilder luceneQuery = new StringBuilder();
    luceneQuery.append(" +TYPE:\"" + ContentModel.TYPE_CONTENT + "\"");
    String filterQuery = "ANCESTOR:\"workspace://SpacesStore/a1c1a0a1-9d68-4912-b853-b3b277f31288\"";
    StatsParameters params = new StatsParameters(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO, luceneQuery.toString(), filterQuery, false);
    params.addSort(new SortDefinition(SortDefinition.SortType.FIELD, "contentsize", false));
    params.addStatsParameter(StatsParameters.PARAM_FIELD, "contentsize");
    params.addStatsParameter(StatsParameters.PARAM_FACET, StatsParameters.FACET_PREFIX + ContentModel.PROP_CREATED.toString());
    params.addStatsParameter("Test1", StatsParameters.FACET_PREFIX + "author. .u");
    params.addStatsParameter("Test2", StatsParameters.FACET_PREFIX + "creator. .u");
    return params;
}
 
Example #20
Source File: TestEnterpriseAtomPubTCK.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void setup() throws Exception
{
	JettyComponent jetty = getTestFixture().getJettyComponent();
	
	final SearchService searchService = (SearchService)jetty.getApplicationContext().getBean("searchService");;
	final NodeService nodeService = (NodeService)jetty.getApplicationContext().getBean("nodeService");
	final FileFolderService fileFolderService = (FileFolderService)jetty.getApplicationContext().getBean("fileFolderService");
	final NamespaceService namespaceService = (NamespaceService)jetty.getApplicationContext().getBean("namespaceService");
	final TransactionService transactionService = (TransactionService)jetty.getApplicationContext().getBean("transactionService");
	final String name = "abc" + System.currentTimeMillis();

	transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
	{
		@Override
		public Void execute() throws Throwable
		{
			AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

               Repository repositoryHelper = (Repository)jetty.getApplicationContext().getBean("repositoryHelper");
			NodeRef companyHome = repositoryHelper.getCompanyHome();
			fileFolderService.create(companyHome, name, ContentModel.TYPE_FOLDER).getNodeRef();

			return null;
		}
	}, false, true);

   	int port = jetty.getPort();
   	Map<String, String> cmisParameters = new HashMap<String, String>();
   	cmisParameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE, "R:cm:replaces");
   	cmisParameters.put(TestParameters.DEFAULT_TEST_FOLDER_PARENT, "/" + name);
   	clientContext = new OpenCMISClientContext(BindingType.ATOMPUB,
   			MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco"), "admin", "admin", cmisParameters, jetty.getApplicationContext());

       overrideVersionableAspectProperties(jetty.getApplicationContext());
}
 
Example #21
Source File: SolrXPathQueryLanguage.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ResultSet executeQuery(SearchParameters searchParameters)
{
    String query = "PATH:\""+searchParameters.getQuery()+"\"";
    SearchParameters sp = searchParameters.copy();
    sp.setLanguage(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO);
    sp.setQuery(query);
    return solrQueryLanguage.executeQuery(sp);
}
 
Example #22
Source File: NoIndexIndexerAndSearcherFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public SearchService getSearcher(StoreRef storeRef, boolean searchDelta) throws SearcherException
{
     NoIndexSearchService searchService = new NoIndexSearchService();
     searchService.setDictionaryService(getDictionaryService());
     searchService.setNamespacePrefixResolver(getNamespacePrefixResolver());
     searchService.setNodeService(getNodeService());
     searchService.setQueryLanguages(getQueryLanguages());
     searchService.setQueryRegister(getQueryRegister());
     return searchService;
}
 
Example #23
Source File: QueriesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public CollectionWithPagingInfo<Person> findPeople(Parameters parameters)
{
    SearchService searchService = sr.getSearchService();
    return new AbstractQuery<Person>(nodeService, searchService)
    {
        @Override
        protected void buildQuery(StringBuilder query, String term, SearchParameters sp, String queryTemplateName)
        {
            sp.addQueryTemplate(queryTemplateName, "|%firstName OR |%lastName OR |%userName");
            sp.setExcludeTenantFilter(false);
            sp.setPermissionEvaluation(PermissionEvaluationMode.EAGER);

            query.append("TYPE:\"").append(ContentModel.TYPE_PERSON).append("\" AND (\"*");
            query.append(term);
            query.append("*\")");
        }

        @Override
        protected List<Person> newList(int capacity)
        {
            return new ArrayList<Person>(capacity);
        }

        @Override
        protected Person convert(NodeRef nodeRef, List<String> includeParam)
        {
            String personId = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME);
            Person person = people.getPerson(personId);
            return person;
        }
        
        // TODO Do the sort in the query on day. A comment in the code for the V0 API used for live people
        //      search says adding sort values for this query don't work - tried it and they really don't.
    }.find(parameters, PARAM_TERM, MIN_TERM_LENGTH_PEOPLE, "_PERSON",
        POST_QUERY_SORT, PEOPLE_SORT_PARAMS_TO_QNAMES,
        new SortColumn(PARAM_FIRSTNAME, true), new SortColumn(PARAM_LASTNAME, true));
}
 
Example #24
Source File: WebDAVonContentUpdateTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void setUp() throws Exception
{
    searchService = ctx.getBean("SearchService", SearchService.class);
    fileFolderService = ctx.getBean("FileFolderService", FileFolderService.class);
    nodeService = ctx.getBean("NodeService", NodeService.class);
    transactionService = ctx.getBean("transactionService", TransactionService.class);
    webDAVHelper = ctx.getBean("webDAVHelper", WebDAVHelper.class);
    lockService = ctx.getBean("LockService", LockService.class);
    policyComponent = ctx.getBean("policyComponent", PolicyComponent.class);
    namespaceService = ctx.getBean("namespaceService", NamespaceService.class);

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

    repositoryHelper = (Repository)ctx.getBean("repositoryHelper");
    companyHomeNodeRef = repositoryHelper.getCompanyHome();

    InputStream testDataIS = getClass().getClassLoader().getResourceAsStream(TEST_DATA_FILE_NAME);
    InputStream davLockInfoIS = getClass().getClassLoader().getResourceAsStream(DAV_LOCK_INFO_XML);
    testDataFile = IOUtils.toByteArray(testDataIS);
    davLockInfoFile = IOUtils.toByteArray(davLockInfoIS);
    testDataIS.close();
    davLockInfoIS.close();

    txn = transactionService.getUserTransaction();
    txn.begin();
}
 
Example #25
Source File: MultiTServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef)
{
    ParameterCheck.mandatory("NodeService", nodeService);
    ParameterCheck.mandatory("SearchService", searchService);
    ParameterCheck.mandatory("NamespaceService", namespaceService);
    ParameterCheck.mandatory("RootPath", rootPath);
    ParameterCheck.mandatory("RootNodeRef", rootNodeRef);

    // String username = AuthenticationUtil.getFullyAuthenticatedUser();
    StoreRef storeRef = rootNodeRef.getStoreRef();

    AuthenticationUtil.RunAsWork<NodeRef> action = new GetRootNode(nodeService, searchService, namespaceService, rootPath, rootNodeRef, storeRef);
    return getBaseName(AuthenticationUtil.runAs(action, AuthenticationUtil.getSystemUserName()));
}
 
Example #26
Source File: ViewXMLExporter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Construct
 * 
 * @param namespaceService  namespace service
 * @param nodeService  node service
 * @param contentHandler  content handler
 */
ViewXMLExporter(NamespaceService namespaceService, NodeService nodeService, SearchService searchService,
        DictionaryService dictionaryService, PermissionService permissionService, ContentHandler contentHandler)
{
    this.namespaceService = namespaceService;
    this.nodeService = nodeService;
    this.searchService = searchService;
    this.dictionaryService = dictionaryService;
    this.permissionService = permissionService;
    this.contentHandler = contentHandler;
    
    VIEW_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, VIEW_LOCALNAME, namespaceService);
    VALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, VALUE_LOCALNAME, namespaceService);
    VALUES_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, VALUES_LOCALNAME, namespaceService);
    CHILDNAME_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, CHILDNAME_LOCALNAME, namespaceService);
    ASPECTS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ASPECTS_LOCALNAME, namespaceService);
    PROPERTIES_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PROPERTIES_LOCALNAME, namespaceService);
    ASSOCIATIONS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ASSOCIATIONS_LOCALNAME, namespaceService);
    DATATYPE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, DATATYPE_LOCALNAME, namespaceService);
    ISNULL_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ISNULL_LOCALNAME, namespaceService);
    METADATA_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, METADATA_LOCALNAME, namespaceService);
    EXPORTEDBY_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTEDBY_LOCALNAME, namespaceService);
    EXPORTEDDATE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTEDDATE_LOCALNAME, namespaceService);
    EXPORTERVERSION_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTERVERSION_LOCALNAME, namespaceService);
    EXPORTOF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, namespaceService);
    ACL_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACL_LOCALNAME, namespaceService);
    ACE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACE_LOCALNAME, namespaceService);
    ACCESS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, ACCESS_LOCALNAME, namespaceService);
    AUTHORITY_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, AUTHORITY_LOCALNAME, namespaceService);
    PERMISSION_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PERMISSION_LOCALNAME, namespaceService);
    INHERITPERMISSIONS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, INHERITPERMISSIONS_LOCALNAME, namespaceService);
    REFERENCE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, REFERENCE_LOCALNAME, namespaceService);
    PATHREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PATHREF_LOCALNAME, namespaceService);
    NODEREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, NODEREF_LOCALNAME, namespaceService);
    LOCALE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, LOCALE_LOCALNAME, namespaceService);
    MLVALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, MLVALUE_LOCALNAME, namespaceService);

}
 
Example #27
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void before()
{
    this.actionService = (ActionService)ctx.getBean("actionService");
    this.ruleService = (RuleService)ctx.getBean("ruleService");
	this.fileFolderService = (FileFolderService)ctx.getBean("FileFolderService");
	this.transactionService = (TransactionService)ctx.getBean("transactionService");
	this.nodeService = (NodeService)ctx.getBean("NodeService");
	this.contentService = (ContentService)ctx.getBean("ContentService");
    this.versionService = (VersionService) ctx.getBean("versionService");
    this.lockService = (LockService) ctx.getBean("lockService");
    this.taggingService = (TaggingService) ctx.getBean("TaggingService");
    this.namespaceService = (NamespaceService) ctx.getBean("namespaceService");
    this.repositoryHelper = (Repository)ctx.getBean("repositoryHelper");
	this.factory = (AlfrescoCmisServiceFactory)ctx.getBean("CMISServiceFactory");
    this.versionService = (VersionService) ctx.getBean("versionService");
	this.cmisConnector = (CMISConnector) ctx.getBean("CMISConnector");
    this.nodeDAO = (NodeDAO) ctx.getBean("nodeDAO");
    this.authorityService = (AuthorityService)ctx.getBean("AuthorityService");
    this.auditSubsystem = (AuditModelRegistryImpl) ctx.getBean("Audit");
    this.permissionService = (PermissionService) ctx.getBean("permissionService");
	this.dictionaryDAO = (DictionaryDAO)ctx.getBean("dictionaryDAO");
	this.cmisDictionaryService = (CMISDictionaryService)ctx.getBean("OpenCMISDictionaryService1.1");
    this.auditDAO = (AuditDAO) ctx.getBean("auditDAO");
    this.nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService");
    this.dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
    this.workflowService = (WorkflowService) ctx.getBean("WorkflowService");
    this.workflowAdminService = (WorkflowAdminService) ctx.getBean("workflowAdminService");
    this.authenticationContext = (AuthenticationContext) ctx.getBean("authenticationContext");
    this.tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService");
    this.tenantService = (TenantService) ctx.getBean("tenantService");
    this.searchService = (SearchService) ctx.getBean("SearchService");
    this.auditComponent = (AuditComponentImpl) ctx.getBean("auditComponent");

    this.globalProperties = (java.util.Properties) ctx.getBean("global-properties");
    this.globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "true");
}
 
Example #28
Source File: SearcherComponent.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ResultSet query(SearchParameters searchParameters)
{
    if(searchParameters.getStores().size() == 0)
    {
        throw new IllegalStateException("At least one store must be defined to search");
    }
    StoreRef storeRef = searchParameters.getStores().get(0);
    SearchService searcher = indexerAndSearcherFactory.getSearcher(storeRef, !searchParameters.excludeDataInTheCurrentTransaction());
    return searcher.query(searchParameters);
}
 
Example #29
Source File: AbstractSearcherComponent.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public List<NodeRef> selectNodes(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters,
        NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks)
        throws InvalidNodeRefException, XPathException
{
    return selectNodes(contextNodeRef, xpath, parameters, namespacePrefixResolver, followAllParentLinks,
            SearchService.LANGUAGE_XPATH);
}
 
Example #30
Source File: RepositoryFolderConfigBean.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private NodeRef getFolderPathImpl(
        NamespaceService namespaceService,
        NodeService nodeService,
        SearchService searchService,
        FileFolderService fileFolderService,
        boolean throwException)
{
    NodeRef pathStartNodeRef = super.resolveNodePath(namespaceService, nodeService, searchService);
    if (pathStartNodeRef == null)
    {
        return getNullOrThrowAlfrescoRuntimeExcpetion(
                "Folder path resolution requires an existing base path. \n" +
                "   Base path: " + getRootPath(), throwException);
    }
    // Just choose the root path if the folder path is empty
    if (folderPath.length() == 0)
    {
        return pathStartNodeRef;
    }
    else
    {
        List<NodeRef> nodeRefs = searchService.selectNodes(pathStartNodeRef, folderPath, null, namespaceService, true);
        if (nodeRefs.size() == 0)
        {
            return getNullOrThrowAlfrescoRuntimeExcpetion("Folder not found: " + this, throwException);
        }
        else
        {
            NodeRef nodeRef = nodeRefs.get(0);
            FileInfo folderInfo = fileFolderService.getFileInfo(nodeRef);
            if (!folderInfo.isFolder())
            {
                return getNullOrThrowAlfrescoRuntimeExcpetion("Not a folder: " + this, throwException);
            }
            return nodeRef;
        }
    }
    // Done
}