Search in sources :

Example 11 with SystemService

use of org.eclipse.kura.system.SystemService in project kura by eclipse.

the class ThreadGroupComparator method findDeviceConfiguration.

@Override
public ArrayList<GwtGroupedNVPair> findDeviceConfiguration(GwtXSRFToken xsrfToken) throws GwtKuraException {
    checkXSRFToken(xsrfToken);
    List<GwtGroupedNVPair> pairs = new ArrayList<GwtGroupedNVPair>();
    SystemService systemService = ServiceLocator.getInstance().getService(SystemService.class);
    SystemAdminService systemAdminService = ServiceLocator.getInstance().getService(SystemAdminService.class);
    try {
        Properties systemProperties = systemService.getProperties();
        pairs.add(new GwtGroupedNVPair("devInfo", "devKuraVersion", systemService.getKuraVersion()));
        pairs.add(new GwtGroupedNVPair("devInfo", "devClientId", systemService.getPrimaryMacAddress() != null ? systemService.getPrimaryMacAddress() : UNKNOWN));
        pairs.add(new GwtGroupedNVPair("devInfo", "devDisplayName", systemService.getDeviceName()));
        pairs.add(new GwtGroupedNVPair("devInfo", "devUptime", formatUptime(Long.parseLong(systemAdminService.getUptime()))));
        pairs.add(new GwtGroupedNVPair("devInfo", "devLastWifiChannel", String.valueOf(systemService.getKuraWifiTopChannel())));
        pairs.add(new GwtGroupedNVPair("devHw", "devModelName", systemService.getModelName()));
        pairs.add(new GwtGroupedNVPair("devHw", "devModelId", systemService.getModelId()));
        pairs.add(new GwtGroupedNVPair("devHw", "devPartNumber", systemService.getPartNumber()));
        pairs.add(new GwtGroupedNVPair("devHw", "devSerialNumber", systemService.getSerialNumber()));
        pairs.add(new GwtGroupedNVPair("devSw", "devFirmwareVersion", systemService.getFirmwareVersion()));
        pairs.add(new GwtGroupedNVPair("devSw", "devBiosVersion", systemService.getBiosVersion()));
        pairs.add(new GwtGroupedNVPair("devSw", "devOsVersion", systemService.getOsVersion()));
        pairs.add(new GwtGroupedNVPair("devSw", "devOs", systemService.getOsName()));
        pairs.add(new GwtGroupedNVPair("devSw", "devOsArch", systemService.getOsArch()));
        pairs.add(new GwtGroupedNVPair("devJava", "devJvmName", systemProperties.getProperty(SystemService.KEY_JAVA_VM_NAME)));
        pairs.add(new GwtGroupedNVPair("devJava", "devJvmVersion", systemProperties.getProperty(SystemService.KEY_JAVA_VM_VERSION)));
        pairs.add(new GwtGroupedNVPair("devJava", "devJvmProfile", systemService.getJavaVendor() + " " + systemService.getJavaVersion()));
        pairs.add(new GwtGroupedNVPair("devJava", "devOsgiFramework", systemProperties.getProperty(SystemService.KEY_OSGI_FW_NAME)));
        pairs.add(new GwtGroupedNVPair("devJava", "devOsgiFrameworkVersion", systemProperties.getProperty(SystemService.KEY_OSGI_FW_VERSION)));
        if (systemService.getNumberOfProcessors() != -1) {
            pairs.add(new GwtGroupedNVPair("devJava", "devNumProc", String.valueOf(systemService.getNumberOfProcessors())));
        }
        pairs.add(new GwtGroupedNVPair("devJava", "devRamTot", String.valueOf(systemService.getTotalMemory()) + " kB"));
        pairs.add(new GwtGroupedNVPair("devJava", "devRamFree", String.valueOf(systemService.getFreeMemory()) + " kB"));
    // TODO: Add cloud status information in the Denali Device Profile
    // deviceConfig.deviceStatus
    // deviceConfig.setAcceptEncoding(null);
    // deviceConfig.setApplicationIdentifiers(null);
    // deviceConfig.setLastEventOn(new Date());
    // deviceConfig.setLastEventType("UNKNOWN");
    } catch (Exception e) {
        throw new GwtKuraException(GwtKuraErrorCode.INTERNAL_ERROR, e);
    }
    return new ArrayList<GwtGroupedNVPair>(pairs);
}
Also used : GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) SystemService(org.eclipse.kura.system.SystemService) ArrayList(java.util.ArrayList) Properties(java.util.Properties) GwtGroupedNVPair(org.eclipse.kura.web.shared.model.GwtGroupedNVPair) SystemAdminService(org.eclipse.kura.system.SystemAdminService) KuraException(org.eclipse.kura.KuraException) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) BundleException(org.osgi.framework.BundleException)

Example 12 with SystemService

use of org.eclipse.kura.system.SystemService in project kura by eclipse.

the class GwtSnapshotServiceImpl method rollbackDeviceSnapshot.

@Override
public void rollbackDeviceSnapshot(GwtXSRFToken xsrfToken, GwtSnapshot snapshot) throws GwtKuraException {
    checkXSRFToken(xsrfToken);
    try {
        ServiceLocator locator = ServiceLocator.getInstance();
        ConfigurationService cs = locator.getService(ConfigurationService.class);
        cs.rollback(snapshot.getSnapshotId());
        // 
        // Add an additional delay after the configuration update
        // to give the time to the device to apply the received
        // configuration
        SystemService ss = locator.getService(SystemService.class);
        long delay = Long.parseLong(ss.getProperties().getProperty("console.updateConfigDelay", "5000"));
        if (delay > 0) {
            Thread.sleep(delay);
        }
    } catch (Throwable t) {
        KuraExceptionHandler.handle(t);
    }
}
Also used : ServiceLocator(org.eclipse.kura.web.server.util.ServiceLocator) SystemService(org.eclipse.kura.system.SystemService) ConfigurationService(org.eclipse.kura.configuration.ConfigurationService)

Example 13 with SystemService

use of org.eclipse.kura.system.SystemService in project kura by eclipse.

the class LifeCyclePayloadBuilder method buildDisconnectPayload.

public KuraDisconnectPayload buildDisconnectPayload() {
    SystemService systemService = this.m_cloudServiceImpl.getSystemService();
    SystemAdminService sysAdminService = this.m_cloudServiceImpl.getSystemAdminService();
    CloudServiceOptions cloudOptions = this.m_cloudServiceImpl.getCloudServiceOptions();
    // build device name
    String deviceName = cloudOptions.getDeviceDisplayName();
    if (deviceName == null) {
        deviceName = systemService.getDeviceName();
    }
    // build payload
    KuraDisconnectPayload payload = new KuraDisconnectPayload(sysAdminService.getUptime(), deviceName);
    return payload;
}
Also used : SystemService(org.eclipse.kura.system.SystemService) KuraDisconnectPayload(org.eclipse.kura.core.message.KuraDisconnectPayload) SystemAdminService(org.eclipse.kura.system.SystemAdminService)

Example 14 with SystemService

use of org.eclipse.kura.system.SystemService in project kura by eclipse.

the class UploadRequest method getZipUploadSizeMax.

private void getZipUploadSizeMax() {
    ServiceLocator locator = ServiceLocator.getInstance();
    try {
        SystemService systemService = locator.getService(SystemService.class);
        int sizeInMB = systemService.getFileCommandZipMaxUploadSize();
        int sizeInBytes = sizeInMB * 1024 * 1024;
        tooBig = sizeInBytes;
    } catch (GwtKuraException e) {
        s_logger.error("Error locating SystemService", e);
    }
}
Also used : ServiceLocator(org.eclipse.kura.web.server.util.ServiceLocator) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) SystemService(org.eclipse.kura.system.SystemService)

Example 15 with SystemService

use of org.eclipse.kura.system.SystemService in project kura by eclipse.

the class UploadRequest method getZipUploadCountMax.

private void getZipUploadCountMax() {
    ServiceLocator locator = ServiceLocator.getInstance();
    try {
        SystemService systemService = locator.getService(SystemService.class);
        tooMany = systemService.getFileCommandZipMaxUploadNumber();
    } catch (GwtKuraException e) {
        s_logger.error("Error locating SystemService", e);
    }
}
Also used : ServiceLocator(org.eclipse.kura.web.server.util.ServiceLocator) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) SystemService(org.eclipse.kura.system.SystemService)

Aggregations

SystemService (org.eclipse.kura.system.SystemService)18 GwtKuraException (org.eclipse.kura.web.shared.GwtKuraException)8 ServiceLocator (org.eclipse.kura.web.server.util.ServiceLocator)6 ArrayList (java.util.ArrayList)5 File (java.io.File)3 IOException (java.io.IOException)3 Properties (java.util.Properties)3 ServletException (javax.servlet.ServletException)3 SystemAdminService (org.eclipse.kura.system.SystemAdminService)3 GwtGroupedNVPair (org.eclipse.kura.web.shared.model.GwtGroupedNVPair)3 Bundle (org.osgi.framework.Bundle)3 BundleException (org.osgi.framework.BundleException)3 ConfigurationService (org.eclipse.kura.configuration.ConfigurationService)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Iterator (java.util.Iterator)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1