Search in sources :

Example 1 with Artifact

use of org.eclipse.kuksa.appstore.model.hawkbit.Artifact in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.

the class ArtifactFileEditor method fillGrids.

public void fillGrids(String softwareModuleId) {
    try {
        List<Artifact> artifactResultList = hawkbitFeignClient.getArtifactsBysoftwareModuleId(softwareModuleId);
        boolean permissionFileExists = false;
        for (Iterator iterator = artifactResultList.iterator(); iterator.hasNext(); ) {
            Artifact artifact = (Artifact) iterator.next();
            if (artifact.getProvidedFilename().equals(Utils.PERMISSION)) {
                permissionFileExists = true;
                break;
            }
        }
        if (permissionFileExists == false) {
            new Notification("There is no " + Utils.PERMISSION + " file.", " You should add " + Utils.PERMISSION + " file to specify permissions that are used on this application!", Notification.Type.ERROR_MESSAGE).show(Page.getCurrent());
        }
        artifactGrid.setItems(artifactResultList);
    } catch (Exception e) {
        new Notification("Hawkbit connection error. Check your Hawkbit's IP in the propreties file!", Notification.Type.ERROR_MESSAGE).show(Page.getCurrent());
    }
}
Also used : Iterator(java.util.Iterator) Artifact(org.eclipse.kuksa.appstore.model.hawkbit.Artifact) Notification(com.vaadin.ui.Notification) BadRequestException(org.eclipse.kuksa.appstore.exception.BadRequestException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with Artifact

use of org.eclipse.kuksa.appstore.model.hawkbit.Artifact in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.

the class AppService method downloadPermissionArtifactFile.

public String downloadPermissionArtifactFile(Long appId) throws BadRequestException, NotFoundException {
    App currentApp = appRepository.findById(appId);
    SoftwareModuleResult currentSoftwareModuleResult = hawkbitFeignClient.getSoftwaremoduleByName(Utils.createFIQLEqual("name", currentApp.getName()) + ";" + Utils.createFIQLEqual("version", currentApp.getVersion()));
    List<Artifact> listArtifact = hawkbitFeignClient.getArtifactsBysoftwareModuleId(currentSoftwareModuleResult.getContent().get(0).getId().toString());
    String artifactId = null;
    for (Artifact artifact : listArtifact) {
        if (artifact.getProvidedFilename().toUpperCase().equals(Utils.PERMISSION)) {
            artifactId = artifact.getId();
            break;
        }
    }
    if (artifactId == null) {
        return Utils.NOT_FOUND;
    }
    String responseDownloadArtifactFile = hawkbitFeignClient.downloadArtifactFile(currentSoftwareModuleResult.getContent().get(0).getId().toString(), artifactId);
    return responseDownloadArtifactFile;
}
Also used : App(org.eclipse.kuksa.appstore.model.App) SoftwareModuleResult(org.eclipse.kuksa.appstore.model.hawkbit.SoftwareModuleResult) Artifact(org.eclipse.kuksa.appstore.model.hawkbit.Artifact)

Example 3 with Artifact

use of org.eclipse.kuksa.appstore.model.hawkbit.Artifact in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.

the class ArtifactFileEditor method addDeleteColumn.

private void addDeleteColumn(String caption) {
    ImageRenderer<Artifact> renderer = new ImageRenderer<>();
    renderer.addClickListener(e -> {
        try {
            deleteArtifact(e.getItem());
        } catch (NumberFormatException e2) {
            e2.printStackTrace();
        } catch (BadRequestException e2) {
            e2.printStackTrace();
        }
    });
    Grid.Column<Artifact, ThemeResource> iconColumn = artifactGrid.addColumn(i -> new ThemeResource("img/delete.png"), renderer);
    iconColumn.setCaption(caption);
    iconColumn.setMaximumWidth(100);
    artifactGrid.addItemClickListener(e -> {
        if (e.getColumn().equals(iconColumn)) {
            try {
                deleteArtifact(e.getItem());
            } catch (NumberFormatException e1) {
                e1.printStackTrace();
            } catch (BadRequestException e1) {
                e1.printStackTrace();
            }
        }
    });
}
Also used : ImageRenderer(com.vaadin.ui.renderers.ImageRenderer) Grid(com.vaadin.ui.Grid) BadRequestException(org.eclipse.kuksa.appstore.exception.BadRequestException) ThemeResource(com.vaadin.server.ThemeResource) Artifact(org.eclipse.kuksa.appstore.model.hawkbit.Artifact)

Aggregations

Artifact (org.eclipse.kuksa.appstore.model.hawkbit.Artifact)3 BadRequestException (org.eclipse.kuksa.appstore.exception.BadRequestException)2 ThemeResource (com.vaadin.server.ThemeResource)1 Grid (com.vaadin.ui.Grid)1 Notification (com.vaadin.ui.Notification)1 ImageRenderer (com.vaadin.ui.renderers.ImageRenderer)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 App (org.eclipse.kuksa.appstore.model.App)1 SoftwareModuleResult (org.eclipse.kuksa.appstore.model.hawkbit.SoftwareModuleResult)1