use of nikita.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.
the class FileService method updateFileSetFinalized.
public File updateFileSetFinalized(Long id) {
File file = fileRepository.findById(id);
if (file == null) {
// TODO throw Object not find
}
String username = SecurityContextHolder.getContext().getAuthentication().getName();
file.setFinalisedDate(new Date());
file.setFinalisedBy(username);
return fileRepository.save(file);
}
use of nikita.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.
the class FileService method getFileOrThrow.
// All HELPER operations
/**
* Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
* If you call this, be aware that you will only ever get a valid File back. If there is no valid
* File, an exception is thrown
*
* @param fileSystemId
* @return
*/
protected File getFileOrThrow(@NotNull String fileSystemId) {
File file = fileRepository.findBySystemIdOrderBySystemId(fileSystemId);
if (file == null) {
String info = INFO_CANNOT_FIND_OBJECT + " File, using systemId " + fileSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return file;
}
use of nikita.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.
the class FileService method deleteEntity.
// All DELETE operations
@Override
public void deleteEntity(@NotNull String fileSystemId) {
File file = getFileOrThrow(fileSystemId);
fileRepository.delete(file);
}
use of nikita.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.
the class FileService method handleUpdate.
// All UPDATE operations
@Override
public File handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull File incomingFile) {
File existingFile = getFileOrThrow(systemId);
// Here copy all the values you are allowed to copy ....
if (null != existingFile.getDescription()) {
existingFile.setDescription(incomingFile.getDescription());
}
if (null != existingFile.getTitle()) {
existingFile.setTitle(incomingFile.getTitle());
}
if (null != existingFile.getDocumentMedium()) {
existingFile.setDocumentMedium(existingFile.getDocumentMedium());
}
existingFile.setVersion(version);
fileRepository.save(existingFile);
return existingFile;
}
use of nikita.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.
the class SeriesService method createFileAssociatedWithSeries.
@Override
public File createFileAssociatedWithSeries(String seriesSystemId, File file) {
File persistedFile = null;
Series series = seriesRepository.findBySystemIdOrderBySystemId(seriesSystemId);
if (series == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Series, using seriesSystemId " + seriesSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else if (series.getSeriesStatus() != null && series.getSeriesStatus().equals(STATUS_CLOSED)) {
String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Series with seriesSystemId " + seriesSystemId + "has status " + STATUS_CLOSED;
logger.info(info);
throw new NoarkEntityEditWhenClosedException(info);
} else {
file.setReferenceSeries(series);
persistedFile = fileService.createFile(file);
}
return persistedFile;
}
Aggregations