Search in sources :

Example 1 with User

use of nikita.common.model.noark5.v4.admin.User in project nikita-noark5-core by HiOA-ABI.

the class FondsCreatorHateoasController method getFondsCreatorTemplate.

// Create a suggested FondsCreator (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/arkivstruktur/arkiv/{systemID}/ny-arkivskaper
// GET [contextPath][api]/arkivstruktur/ny-arkivskaper
@ApiOperation(value = "Suggests the contents of a new FondsCreator", notes = "Returns a pre-filled FondsCreator" + " with values relevant for the logged-in user", response = FondsCreatorHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsCreatorHateoas.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 = { NEW_FONDS_CREATOR, FONDS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_FONDS_CREATOR })
public ResponseEntity<FondsCreatorHateoas> getFondsCreatorTemplate(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) throws NikitaException {
    FondsCreator suggestedFondsCreator = new FondsCreator();
    // TODO: This should be replaced with configurable data based on whoever is logged in
    //       Currently just returns the test values
    suggestedFondsCreator.setFondsCreatorId("123456789");
    suggestedFondsCreator.setFondsCreatorName("Eksempel kommune");
    suggestedFondsCreator.setDescription("Eksempel kommune ligger i eksempel fylke nord for nord");
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(suggestedFondsCreator);
    fondsHateoasHandler.addLinksOnNew(fondsCreatorHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsCreatorHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) FondsCreatorHateoas(nikita.model.noark5.v4.hateoas.FondsCreatorHateoas) FondsCreator(nikita.model.noark5.v4.FondsCreator) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with User

use of nikita.common.model.noark5.v4.admin.User in project nikita-noark5-core by HiOA-ABI.

the class FondsHateoasController method getFondsTemplate.

// Create a suggested Fonds (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/arkivstruktur/ny-arkiv
@ApiOperation(value = "Suggests the contents of a new Fonds object", notes = "Returns a pre-filled Fonds object" + " with values relevant for the logged-in user", response = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsHateoas.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 = { NEW_FONDS, FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_FONDS })
public ResponseEntity<FondsHateoas> getFondsTemplate(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) throws NikitaException {
    Fonds suggestedFonds = new Fonds();
    // TODO: This should be replaced with configurable data based on whoever is logged in
    //       Currently just returns the test values
    suggestedFonds.setTitle(TEST_TITLE);
    suggestedFonds.setDescription(TEST_DESCRIPTION);
    suggestedFonds.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    FondsHateoas fondsHateoas = new FondsHateoas(suggestedFonds);
    fondsHateoasHandler.addLinksOnNew(fondsHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsHateoas);
}
Also used : FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Fonds(nikita.model.noark5.v4.Fonds) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 3 with User

use of nikita.common.model.noark5.v4.admin.User 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("");
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.model.noark5.v4.metadata.CorrespondencePartType) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 4 with User

use of nikita.common.model.noark5.v4.admin.User in project nikita-noark5-core by HiOA-ABI.

the class FondsService method generateDefaultSeries.

/**
 * Generate a Default Fonds object that can be associated with the
 * identified Fonds.
 * <br>
 * Note. Ideally this method would be configurable based on the logged in
 * user and the business area they are working with. A generic Noark core
 * like this does not have scope for that kind of functionality.
 *
 * @param fondsSystemId The systemId of the Fonds object you wish to
 *                      generate a default Series for
 * @return the Series object wrapped as a SeriesHateoas object
 */
@Override
public SeriesHateoas generateDefaultSeries(@NotNull String fondsSystemId) {
    Series defaultSeries = new Series();
    defaultSeries.setSeriesStatus(STATUS_OPEN);
    defaultSeries.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    defaultSeries.setTitle("Default Series object generated by nikita " + "that can be associated with Fonds with systemID " + fondsSystemId);
    SeriesHateoas seriesHateoas = new SeriesHateoas(defaultSeries);
    seriesHateoasHandler.addLinksOnNew(seriesHateoas, new Authorisation());
    return seriesHateoas;
}
Also used : Series(nikita.common.model.noark5.v4.Series) Authorisation(nikita.webapp.security.Authorisation) SeriesHateoas(nikita.common.model.noark5.v4.hateoas.SeriesHateoas)

Example 5 with User

use of nikita.common.model.noark5.v4.admin.User in project nikita-noark5-core by HiOA-ABI.

the class FondsService method generateDefaultFonds.

/**
 * Generate a Default Fonds object that can be associated with the
 * identified Fonds. If fondsSystemId has a value, it is assumed you wish
 * to generate a sub-fonds.
 * <br>
 * Note. Ideally this method would be configurable based on the logged in
 * user and the business area they are working with. A generic Noark core
 * like this does not have scope for that kind of functionality.
 *
 * @param fondsSystemId The systemId of the Fonds object you wish to
 *                      generate a default sub-fonds. Null if the Fonds
 *                      is not a sub-fonds.
 * @return the Fonds object wrapped as a FondsHateoas object
 */
@Override
public FondsHateoas generateDefaultFonds(String fondsSystemId) {
    Fonds defaultFonds = new Fonds();
    defaultFonds.setTitle(TEST_TITLE);
    defaultFonds.setDescription(TEST_DESCRIPTION);
    defaultFonds.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    FondsHateoas fondsHateoas = new FondsHateoas(defaultFonds);
    fondsHateoasHandler.addLinksOnNew(fondsHateoas, new Authorisation());
    return fondsHateoas;
}
Also used : FondsHateoas(nikita.common.model.noark5.v4.hateoas.FondsHateoas) Authorisation(nikita.webapp.security.Authorisation) Fonds(nikita.common.model.noark5.v4.Fonds)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)9 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 Authorisation (nikita.webapp.security.Authorisation)6 Timed (com.codahale.metrics.annotation.Timed)5 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)5 CorrespondencePartType (nikita.common.model.noark5.v4.metadata.CorrespondencePartType)3 NikitaException (nikita.common.util.exceptions.NikitaException)3 Fonds (nikita.model.noark5.v4.Fonds)3 CorrespondencePartType (nikita.model.noark5.v4.metadata.CorrespondencePartType)3 NikitaException (nikita.util.exceptions.NikitaException)3 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2 Fonds (nikita.common.model.noark5.v4.Fonds)1 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)1 Series (nikita.common.model.noark5.v4.Series)1 User (nikita.common.model.noark5.v4.admin.User)1 FondsCreatorHateoas (nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas)1 FondsHateoas (nikita.common.model.noark5.v4.hateoas.FondsHateoas)1