Search in sources :

Example 1 with AppStatus

use of org.hisp.dhis.appmanager.AppStatus in project dhis2-core by dhis2.

the class AppController method installApp.

@RequestMapping(method = RequestMethod.POST)
@PreAuthorize("hasRole('ALL') or hasRole('M_dhis-web-app-management')")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void installApp(@RequestParam("file") MultipartFile file) throws IOException, WebMessageException {
    File tempFile = File.createTempFile("IMPORT_", "_ZIP");
    file.transferTo(tempFile);
    AppStatus status = appManager.installApp(tempFile, file.getOriginalFilename());
    if (!status.ok()) {
        String message = i18nManager.getI18n().getString(status.getMessage());
        throw new WebMessageException(WebMessageUtils.conflict(message));
    }
}
Also used : AppStatus(org.hisp.dhis.appmanager.AppStatus) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

File (java.io.File)1 AppStatus (org.hisp.dhis.appmanager.AppStatus)1 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1