Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
BZ1192831: User with no privileges for Repository can view and modify…
Browse files Browse the repository at this point in the history
… assets in that Repository

(cherry picked from commit db3df91)
  • Loading branch information
manstis authored and porcelli committed Dec 8, 2015
1 parent 21e2053 commit 2dcc471
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public List<KObject> searchByAttrs( final Map<String, ?> attrs,
final int pageSize,
final int startIndex,
final ClusterSegment... clusterSegments ) {
if ( clusterSegments == null || clusterSegments.length == 0 ) {
return emptyList();
}
if ( attrs == null || attrs.size() == 0 ) {
return emptyList();
}
Expand All @@ -79,12 +82,18 @@ public List<KObject> fullTextSearch( final String term,
final int pageSize,
final int startIndex,
final ClusterSegment... clusterSegments ) {
if ( clusterSegments == null || clusterSegments.length == 0 ) {
return emptyList();
}
return search( buildQuery( term, clusterSegments ), pageSize, startIndex, clusterSegments );
}

@Override
public int searchByAttrsHits( final Map<String, ?> attrs,
final ClusterSegment... clusterSegments ) {
if ( clusterSegments == null || clusterSegments.length == 0 ) {
return 0;
}
if ( attrs == null || attrs.size() == 0 ) {
return 0;
}
Expand All @@ -94,6 +103,9 @@ public int searchByAttrsHits( final Map<String, ?> attrs,
@Override
public int fullTextSearchHits( final String term,
final ClusterSegment... clusterSegments ) {
if ( clusterSegments == null || clusterSegments.length == 0 ) {
return 0;
}
return searchHits( buildQuery( term, clusterSegments ), clusterSegments );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.uberfire.ext.metadata.model.KObject;
import org.uberfire.ext.metadata.search.ClusterSegment;
import org.uberfire.java.nio.base.FileSystemId;
import org.uberfire.java.nio.base.SegmentedPath;
Expand Down Expand Up @@ -76,32 +78,110 @@ public String[] segmentIds() {
"*.txt" );
}};

//Attribute Search
{
final int hits = config.getSearchIndex().searchByAttrsHits( attributes );
assertEquals( 2,
final List<KObject> results = config.getSearchIndex().searchByAttrs( attributes,
10,
0 );
assertEquals( 0,
hits );
assertEquals( 0,
results.size() );
}

{
final int hits = config.getSearchIndex().searchByAttrsHits( attributes,
cs1 );
final List<KObject> results = config.getSearchIndex().searchByAttrs( attributes,
10,
0,
cs1 );
assertEquals( 1,
hits );
assertEquals( 1,
results.size() );
}

{
final int hits = config.getSearchIndex().searchByAttrsHits( attributes,
cs2 );
final List<KObject> results = config.getSearchIndex().searchByAttrs( attributes,
10,
0,
cs2 );
assertEquals( 1,
hits );
assertEquals( 1,
results.size() );
}

{
final int hits = config.getSearchIndex().searchByAttrsHits( attributes,
cs1,
cs2 );
final List<KObject> results = config.getSearchIndex().searchByAttrs( attributes,
10,
0,
cs1,
cs2 );
assertEquals( 2,
hits );
assertEquals( 2,
results.size() );
}

//Full Text Search
{
final int hits = config.getSearchIndex().fullTextSearchHits( "*indexed*" );
final List<KObject> results = config.getSearchIndex().fullTextSearch( "*indexed*",
10,
0 );
assertEquals( 0,
hits );
assertEquals( 0,
results.size() );
}

{
final int hits = config.getSearchIndex().fullTextSearchHits( "*indexed*",
cs1 );
final List<KObject> results = config.getSearchIndex().fullTextSearch( "*indexed*",
10,
0,
cs1 );
assertEquals( 1,
hits );
assertEquals( 1,
results.size() );
}

{
final int hits = config.getSearchIndex().fullTextSearchHits( "*indexed*",
cs2 );
final List<KObject> results = config.getSearchIndex().fullTextSearch( "*indexed*",
10,
0,
cs2 );
assertEquals( 1,
hits );
assertEquals( 1,
results.size() );
}

{
final int hits = config.getSearchIndex().fullTextSearchHits( "*indexed*",
cs1,
cs2 );
final List<KObject> results = config.getSearchIndex().fullTextSearch( "*indexed*",
10,
0,
cs1,
cs2 );
assertEquals( 2,
hits );
assertEquals( 2,
results.size() );
}
}

Expand Down

0 comments on commit 2dcc471

Please sign in to comment.