This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit f668128b authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Various Sonar

parent 4d4d13a7
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
......@@ -71,7 +71,7 @@ public class MetaDataRepository {
private static final long AUTOCOMPLETION_RECHECK_TIMEOUT = 5 * 60 * 1000L; // every 5 Minutes
private Timer autocompletionReloadTimer = new Timer("AutocompletionReloadTimer");
public final static String EXERCISE_BY_ID_CACHE = "at.ac.uibk.gitsearch.repository.search.MetaDataRepository.ExerciseByIdCache";
public static final String EXERCISE_BY_ID_CACHE = "at.ac.uibk.gitsearch.repository.search.MetaDataRepository.ExerciseByIdCache";
@Value("${application.search.highlight-pre}")
private String preTags;
......@@ -180,7 +180,7 @@ public class MetaDataRepository {
* @throws JsonMappingException
*/
private List<AutoCompleteEntry> getFieldAutoCompletion(String prefix, final String metaDataField, int maxCount)
throws IOException, JsonProcessingException, JsonMappingException {
throws IOException {
fillAutoCompletion();
String lcKeyWordPrefix = prefix.toLowerCase();
......@@ -232,13 +232,13 @@ public class MetaDataRepository {
autocompletionReloadTimer.cancel();
}
private synchronized void fillAutoCompletion() throws IOException, JsonProcessingException, JsonMappingException {
private synchronized void fillAutoCompletion() throws IOException {
if (cachedCompletions == null) {
updateAutocompletionCache();
}
}
private void updateAutocompletionCache() throws IOException, JsonProcessingException, JsonMappingException {
private void updateAutocompletionCache() throws IOException {
Map<String, Map<String, Map<String, Integer>>> reloadedCachedCompletions = new HashMap<>();
reloadedCachedCompletions.put(SearchRepositoryConstants.METADATA_KEYWORDS, new TreeMap<>());
reloadedCachedCompletions.put(SearchRepositoryConstants.METADATA_CREATOR, new TreeMap<>());
......@@ -366,24 +366,13 @@ public class MetaDataRepository {
.filter(auth -> !auth.getAuthority().startsWith("ROLE"))
.filter(auth -> !auth.getAuthority().startsWith("SCOPE"))
.map(auth -> QueryBuilders.prefixQuery(SearchRepositoryConstants.PROJECT_NAMESPACE, auth.getAuthority()));
prefixAuthQueries.forEach(pq -> authQuery.should(pq) );
prefixAuthQueries.forEach(authQuery::should);
if(authQuery.hasClauses())
queryBuilder.must(QueryBuilders.boolQuery().should(authQuery).should(publicQuery));
else
queryBuilder.must(publicQuery);
}
// SearchRequest searchRequest = new SearchRequest(SearchRepositoryConstants.INDEX_METADATA);
// BoolQueryBuilder emailQuery = QueryBuilders.boolQuery();
// emailQuery
// .must(QueryBuilders.prefixQuery(SearchRepositoryConstants.METADATA_CREATOR_EMAIL, email));
//addAuthorizationQuery(user, emailQuery);
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(queryBuilder).size(pageSize)
.from(0);
......@@ -455,14 +444,6 @@ public class MetaDataRepository {
if (authorBuilder.hasClauses())
queryBuilder.must(authorBuilder);
// if (searchInputDTO.getMetadata().getTypes() != null && !searchInputDTO.getMetadata().getTypes().isEmpty()) {
// BoolQueryBuilder typeBuilder = QueryBuilders.boolQuery();
// searchInputDTO.getMetadata().getTypes().forEach(type -> typeBuilder
// .should(QueryBuilders.termQuery(SearchRepositoryConstants.METADATA_TYPE, type.getExternalName())));
// if (typeBuilder.hasClauses())
// queryBuilder.must(typeBuilder);
// }
//
if (searchInputDTO.getMetadata().getNaturalLanguage() != null
&& !searchInputDTO.getMetadata().getNaturalLanguage().isEmpty()) {
BoolQueryBuilder nlBuilder = QueryBuilders.boolQuery();
......@@ -504,7 +485,6 @@ public class MetaDataRepository {
* this adds extra authorization requirements.
* It currently supports directly the group membership in the hierarchy
* and the new access management by shared groups and explicit members.
* TODO: reduce the old group concept via name spaces.
* @param user
* @param queryBuilder
*/
......@@ -519,7 +499,7 @@ public class MetaDataRepository {
final Collection<GrantedAuthority> authorities = user.get().getAuthorities();
final BoolQueryBuilder authQuery = QueryBuilders.boolQuery().boost(0.0f);
// TODO old membership management
// old membership management (can be eliminated some day)
final Stream<QueryBuilder> prefixAuthQueries = authorities.stream()
.filter(auth -> !Authority.isStandardRole(auth.getAuthority()))
.filter(auth -> !auth.getAuthority().startsWith("SCOPE")).map(
......@@ -533,7 +513,7 @@ public class MetaDataRepository {
.filter(auth -> !auth.getAuthority().startsWith("SCOPE")).map(
auth -> QueryBuilders
.termQuery(SearchRepositoryConstants.PROJECT_GROUPS, auth.getAuthority()));
prefixAuthQueries2.forEach(pq -> authQuery.should(pq));
prefixAuthQueries2.forEach(authQuery::should);
final String email = user.get().getUsername().toLowerCase();
if(StringUtils.isNotEmpty(email)) {
authQuery.should(QueryBuilders
......
......@@ -2,22 +2,19 @@ package at.ac.uibk.gitsearch.repository.search;
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
import at.ac.uibk.gitsearch.domain.SavedSearches;
import java.util.List;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import at.ac.uibk.gitsearch.domain.SavedSearches;
/**
* Spring Data Elasticsearch repository for the {@link SavedSearches} entity.
*/
......
......@@ -198,7 +198,10 @@ public class ExerciseService {
File artemisMetadataFile = new File(jsonMetadataFile.getParent(), "artemis.yaml");
if (!artemisMetadataFile.exists()) {
artemisMetadataFile.createNewFile();
boolean success = artemisMetadataFile.createNewFile();
if(!success) {
log.warn("Cannot create file");
}
}
mapper.writeValue(artemisMetadataFile, artemisExerciseInfo.getArtemisInfoOnly());
}
......
......@@ -32,8 +32,7 @@ public class LikesService {
*/
public Likes save(Likes likes) {
log.debug("Request to save Likes : {}", likes);
Likes result = likesRepository.save(likes);
return result;
return likesRepository.save(likes);
}
/**
......
......@@ -16,7 +16,8 @@ import org.mapstruct.*;
public interface SavedSearchesMapper extends EntityMapper<SavedSearchesDTO, SavedSearches> {
default Set<Authority> stringToAuths(Set<String> auths) {
if(auths==null) return Collections.emptySet();
return auths.stream().map(s -> new Authority(s)).collect(Collectors.toSet());
if(auths==null) {return Collections.emptySet();}
else
return auths.stream().map(Authority::new).collect(Collectors.toSet());
}
}
......@@ -57,7 +57,6 @@
<td>
<a [routerLink]="['/likes', likes.id, 'view']">{{ likes.id }}</a>
</td>
<!-- <td>{{ likes.date | date:'mediumDate' }}</td> -->
<td>{{ likes.userID }}</td>
<td>{{ likes.exerciseID }}</td>
<td class="text-right">
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment