
package de.ivu.elect.presentation.system;

import java.io.Serializable;
import java.util.List;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.system.boundary.VirusScanAvailable;
import de.ivu.elect.presentation.View;

@RequestScoped
@Named(VirusScanTestView.COMPONENT_NAME)
@View(viewId = VirusScanTestView.VIEW_ID, useCase = UseCasePermission.KONFIGURATION_EDIT)
public class VirusScanTestView implements Serializable {

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "virusScanTestView";

  public static final String VIEW_ID = "/system/virus-scan-test.xhtml";

  @Inject
  private transient VirusScanAvailable virusScanAvailable;

  private List<String> messages;

  public boolean isVirusScanPossible() {
    return virusScanAvailable.isVirusScanPossible();
  }

  public boolean isVirusScanAvailable() {
    return virusScanAvailable.isVirusScanAvailable();
  }

  public boolean isVirusScannerWorking() {
    return getMessages().isEmpty();
  }

  public List<String> getMessages() {
    if (messages == null) {
      messages = virusScanAvailable.isVirusScannerWorking();
    }
    return messages;
  }

}
