Commit 2835eb9a authored by Matija Obreza's avatar Matija Obreza

Updates for Amphibian

parent 3677912b
......@@ -21,13 +21,11 @@ import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.genesys.amphibian.client.model.Document;
import org.genesys.amphibian.client.model.Preview;
import org.genesys.filerepository.NoSuchRepositoryFileException;
import org.genesys.filerepository.model.RepositoryFile;
import org.genesys.filerepository.service.RepositoryService;
import org.genesys2.server.api.ApiBaseController;
import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.service.AmphibianService;
import org.genesys2.server.service.AmphibianService.AmphibianException;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -84,7 +82,7 @@ public class AmphibianController {
@GetMapping(path = { "/preview/{uuid:\\w{8}\\-\\w{4}\\-.{22}}/{sheet}/{startRow}" })
@ApiOperation(value = "Get the overview of the parsed dataset", notes = "Use the same reference UUID as provided when ingesting a dataset")
public List<Document> getData(@ApiParam(value = "Your reference UUID", required = true) @PathVariable UUID uuid, // uuid
public List<Object> getData(@ApiParam(value = "Your reference UUID", required = true) @PathVariable UUID uuid, // uuid
@ApiParam(value = "Sheet index", required = true) @PathVariable long sheet, // sheet index
@ApiParam(value = "Index of the first row", required = true) @PathVariable long startRow, // start row
@ApiParam(value = "Number of rows to return", required = false) @RequestParam(name = "count", required = false, defaultValue = "50") Optional<Integer> count)
......@@ -92,12 +90,7 @@ public class AmphibianController {
repositoryService.getFile(uuid);
List<Document> data = amphibianService.getPreviewData(uuid, sheet, startRow, count.orElse(50));
if (data == null || data.isEmpty()) {
throw new NotFoundElement("No data in this dataset for sheet=" + sheet + " startRow=" + startRow);
} else {
return data;
}
return amphibianService.getPreviewData(uuid, sheet, startRow, count.orElse(50));
}
}
......@@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.List;
import java.util.UUID;
import org.genesys.amphibian.client.model.Document;
import org.genesys.amphibian.client.model.Preview;
import org.genesys2.server.exception.InvalidApiUsageException;
......@@ -79,6 +78,6 @@ public interface AmphibianService {
* @return the preview data
* @throws AmphibianException
*/
List<Document> getPreviewData(UUID uuid, long sheet, long startRow, int count) throws AmphibianException;
List<Object> getPreviewData(UUID uuid, long sheet, long startRow, int count) throws AmphibianException;
}
......@@ -26,7 +26,6 @@ import java.util.UUID;
import org.genesys.amphibian.client.api.InfoApi;
import org.genesys.amphibian.client.api.PreviewApi;
import org.genesys.amphibian.client.invoker.ApiClient;
import org.genesys.amphibian.client.model.Document;
import org.genesys.amphibian.client.model.Preview;
import org.genesys2.server.service.AmphibianService;
import org.slf4j.Logger;
......@@ -35,6 +34,8 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
@Service
public class AmphibianServiceImpl implements AmphibianService, InitializingBean {
public static final Logger LOG = LoggerFactory.getLogger(AmphibianServiceImpl.class);
......@@ -52,7 +53,7 @@ public class AmphibianServiceImpl implements AmphibianService, InitializingBean
previewApi = new PreviewApi(amphibianClient);
try {
LOG.info("Amphibian {} at {}", infoApi.versionUsingGET(), amphibianClient.getBasePath());
LOG.info("Amphibian {} at {}", infoApi.getVersion(), amphibianClient.getBasePath());
} catch (Throwable e) {
LOG.warn("Amphibian at {} not reachable: {}", amphibianClient.getBasePath(), e.getMessage());
}
......@@ -79,7 +80,7 @@ public class AmphibianServiceImpl implements AmphibianService, InitializingBean
}
try {
return previewApi.ingestUsingPOST(uuid, localFile, null, null, contentType);
return previewApi.ingest(uuid, localFile, contentType, null, null);
} catch (Throwable e) {
throw new AmphibianException("Error ingesting file", e);
} finally {
......@@ -92,16 +93,16 @@ public class AmphibianServiceImpl implements AmphibianService, InitializingBean
if (amphibianClient == null) {
throw new AmphibianNotAvailableException();
}
return previewApi.getUsingGET(uuid);
return previewApi.getPreview(uuid);
}
@Override
public List<Document> getPreviewData(UUID uuid, long sheet, long startRow, int count) throws AmphibianException {
public List<Object> getPreviewData(UUID uuid, long sheet, long startRow, int count) throws AmphibianException {
if (amphibianClient == null) {
throw new AmphibianNotAvailableException();
}
try {
return previewApi.getDataUsingGET(sheet, startRow, uuid, count);
return previewApi.getData(uuid, sheet, startRow, count, Lists.newArrayList());
} catch (Throwable e) {
throw new AmphibianException("Error getting preview data", e);
}
......
Markdown is supported
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