use of nikita.util.exceptions.NikitaException in project nikita-noark5-core by HiOA-ABI.
the class CaseFileImportService method save.
@Override
public CaseFile save(CaseFile caseFile) {
String username = SecurityContextHolder.getContext().getAuthentication().getName();
if (username == null) {
throw new NikitaException("Security context problem. username is null! Cannot continue with " + "this request!");
}
if (caseFile.getCreatedDate() == null) {
caseFile.setCreatedDate(new Date());
}
if (caseFile.getCreatedBy() == null) {
caseFile.setCreatedBy(username);
}
if (caseFile.getOwnedBy() == null) {
caseFile.setOwnedBy(username);
}
caseFile.setDeleted(false);
return caseFileRepository.save(caseFile);
}
use of nikita.util.exceptions.NikitaException in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionImportService method save.
// All CREATE operations
public DocumentDescription save(DocumentDescription documentDescription) {
String username = SecurityContextHolder.getContext().getAuthentication().getName();
if (username == null) {
throw new NikitaException("Security context problem. username is null! Cannot continue with " + "this request!");
}
if (documentDescription.getCreatedDate() == null) {
documentDescription.setCreatedDate(new Date());
}
if (documentDescription.getCreatedBy() == null) {
documentDescription.setCreatedBy(username);
}
if (documentDescription.getOwnedBy() == null) {
documentDescription.setOwnedBy(username);
}
documentDescription.setDeleted(false);
return documentDescriptionRepository.save(documentDescription);
}
use of nikita.util.exceptions.NikitaException in project nikita-noark5-core by HiOA-ABI.
the class FondsImportService method createNewFonds.
// All CREATE operations
/**
* Persists a new fonds object to the database. It's assumed the caller has a valid fonds object. Minimal error
* checking occurs here.
*
* @param fonds fonds object with some values set
* @return the newly persisted fonds object
*/
@Override
public Fonds createNewFonds(Fonds fonds) {
String username = SecurityContextHolder.getContext().getAuthentication().getName();
if (username == null) {
throw new NikitaException("Security context problem. username is null! Cannot continue with " + "this request!");
}
if (fonds.getCreatedDate() == null) {
fonds.setCreatedDate(new Date());
}
if (fonds.getCreatedBy() == null) {
fonds.setCreatedBy(username);
}
if (fonds.getOwnedBy() == null) {
fonds.setOwnedBy(username);
}
fonds.setDeleted(false);
return fondsRepository.save(fonds);
}
use of nikita.util.exceptions.NikitaException in project nikita-noark5-core by HiOA-ABI.
the class RecordImportService method save.
// All CREATE operations
public Record save(Record record) {
String username = SecurityContextHolder.getContext().getAuthentication().getName();
if (username == null) {
throw new NikitaException("Security context problem. username is null! Cannot continue with " + "this request!");
}
if (record.getCreatedDate() == null) {
record.setCreatedDate(new Date());
}
if (record.getCreatedBy() == null) {
record.setCreatedBy(username);
}
if (record.getOwnedBy() == null) {
record.setOwnedBy(username);
}
record.setDeleted(false);
return recordRepository.save(record);
}
use of nikita.util.exceptions.NikitaException in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method getCorrespondencePartInternalTemplate.
// Create a suggested CorrespondencePartInternal (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartintern
@ApiOperation(value = "Suggests the contents of a new CorrespondencePartInternal object", notes = "Returns a pre-filled CorrespondencePartInternal object" + " with values relevant for the logged-in user", response = CorrespondencePartInternalHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartInternalHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = { SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CORRESPONDENCE_PART_INTERNAL })
public ResponseEntity<String> getCorrespondencePartInternalTemplate(HttpServletRequest request) throws NikitaException {
CorrespondencePartInternal suggestedCorrespondencePart = new CorrespondencePartInternal();
CorrespondencePartType correspondencePartType = correspondencePartTypeService.findByCode(CORRESPONDENCE_PART_CODE_EA);
if (correspondencePartType == null) {
throw new NikitaException("Internal error, metadata missing. [" + CORRESPONDENCE_PART_CODE_EA + "] returns no value");
}
suggestedCorrespondencePart.setCorrespondencePartType(correspondencePartType);
// The reason this is not implemented is that we are missing AdministrativeUnit and multiple users
CorrespondencePartInternalHateoas correspondencePartHateoas = new CorrespondencePartInternalHateoas(suggestedCorrespondencePart);
correspondencePartHateoasHandler.addLinksOnTemplate(correspondencePartHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("");
}
Aggregations