Skip to content

Commit

Permalink
Merge pull request #623 from Arnei/make-work-search-service-rewrite
Browse files Browse the repository at this point in the history
Make tool work with Solr removal
  • Loading branch information
JulianKniephoff authored Jun 25, 2024
2 parents b154c7b + c8567d4 commit d59890f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion frontend/js/integrations/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ define([
data: "id=" + mediaPackageId + "&limit=1",
dataType: "json"
}).then(function (data) {
return data["search-results"].result;
return data.result[0];
});
var mediaPackage = searchResult.then(function (result) {
return result.mediapackage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
import org.opencastproject.db.DBSession;
import org.opencastproject.db.DBSessionFactory;
import org.opencastproject.mediapackage.MediaPackage;
import org.opencastproject.search.api.SearchQuery;
import org.opencastproject.search.api.SearchResultItem;
import org.opencastproject.search.api.SearchService;
import org.opencastproject.security.api.AuthorizationService;
import org.opencastproject.security.api.SecurityConstants;
import org.opencastproject.security.api.SecurityService;
import org.opencastproject.security.api.UnauthorizedException;
import org.opencastproject.util.NotFoundException;
import org.opencastproject.util.data.Effect;
import org.opencastproject.util.data.Function;
import org.opencastproject.util.data.Function0;
Expand Down Expand Up @@ -1271,14 +1271,11 @@ public Boolean none() {

@Override
public Option<MediaPackage> findMediaPackage(String id) {
return head(searchService.getByQuery(new SearchQuery().withId(id)).getItems()).map(
new Function<>() {
@Override
public MediaPackage apply(SearchResultItem searchResultItem) {
return searchResultItem.getMediaPackage();
}
}
);
try {
return Option.some(searchService.get(id));
} catch (NotFoundException | UnauthorizedException e) {
return Option.none();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
import org.opencast.annotation.impl.persistence.ExtendedAnnotationServiceJpaImpl;

import org.opencastproject.mediapackage.MediaPackage;
import org.opencastproject.search.api.SearchQuery;
import org.opencastproject.search.api.SearchResult;
import org.opencastproject.search.api.SearchResultItem;
import org.opencastproject.search.api.SearchService;
import org.opencastproject.security.api.AuthorizationService;
import org.opencastproject.security.api.DefaultOrganization;
import org.opencastproject.security.api.SecurityService;
import org.opencastproject.security.api.UnauthorizedException;
import org.opencastproject.security.api.User;
import org.opencastproject.security.util.SecurityUtil;
import org.opencastproject.util.NotFoundException;

import org.easymock.EasyMock;
import org.junit.Ignore;
Expand Down Expand Up @@ -90,17 +89,12 @@ private static AuthorizationService getAuthorizationService() {
private static SearchService getSearchService() {
MediaPackage mediaPackage = EasyMock.createNiceMock(MediaPackage.class);

SearchResultItem searchResultItem = EasyMock.createNiceMock(SearchResultItem.class);
EasyMock.expect(searchResultItem.getMediaPackage()).andReturn(mediaPackage).anyTimes();
EasyMock.replay(searchResultItem);

SearchResult searchResult = EasyMock.createNiceMock(SearchResult.class);
EasyMock.expect(searchResult.getItems()).andReturn(new SearchResultItem[]{searchResultItem}).anyTimes();
EasyMock.replay(searchResult);

SearchService searchService = EasyMock.createNiceMock(SearchService.class);
EasyMock.expect(searchService.getByQuery(EasyMock.anyObject(SearchQuery.class)))
.andReturn(searchResult).anyTimes();
try {
EasyMock.expect(searchService.get(EasyMock.anyObject(String.class))).andReturn(mediaPackage).anyTimes();
} catch (UnauthorizedException | NotFoundException e) {
// Do nothing. We just have to pretend to handle checked exceptions somehow to appease the compiler.
}
EasyMock.replay(searchService);
return searchService;
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<opencast.build.version>14.0</opencast.build.version>
<opencast.deploy.version>;version="${opencast.build.version}"</opencast.deploy.version>
<opencast.build.version>16.0</opencast.build.version>
<opencast.deploy.version>;version=16.0</opencast.deploy.version>
</properties>

<build>
Expand Down

0 comments on commit d59890f

Please sign in to comment.