Search in sources :

Example 1 with SoftwareConfiguration

use of org.dcm4chee.arc.event.SoftwareConfiguration in project dcm4chee-arc-light by dcm4che.

the class ConfigurationRS method createDevice.

@POST
@Path("/devices/{DeviceName}")
@Consumes("application/json")
public void createDevice(@PathParam("DeviceName") String deviceName, Reader content) {
    logRequest();
    Device device = toDevice(deviceName, content);
    try {
        ConfigurationChanges diffs = conf.persist(device, options());
        softwareConfigurationEvent.fire(new SoftwareConfiguration(request, deviceName, diffs));
    } catch (IllegalStateException | ConfigurationNotFoundException e) {
        throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.NOT_FOUND));
    } catch (IllegalArgumentException e) {
        throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.BAD_REQUEST));
    } catch (ConfigurationException e) {
        throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.CONFLICT));
    } catch (Exception e) {
        throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
    }
}
Also used : SoftwareConfiguration(org.dcm4chee.arc.event.SoftwareConfiguration) JsonParsingException(javax.json.stream.JsonParsingException)

Example 2 with SoftwareConfiguration

use of org.dcm4chee.arc.event.SoftwareConfiguration in project dcm4chee-arc-light by dcm4che.

the class ConfigurationRS method deleteDevice.

@DELETE
@Path("/devices/{DeviceName}")
public void deleteDevice(@PathParam("DeviceName") String deviceName) {
    logRequest();
    try {
        ConfigurationChanges diffs = conf.removeDevice(deviceName, options());
        softwareConfigurationEvent.fire(new SoftwareConfiguration(request, deviceName, diffs));
    } catch (IllegalStateException | ConfigurationNotFoundException e) {
        throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.NOT_FOUND));
    } catch (ConfigurationException e) {
        throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.CONFLICT));
    } catch (Exception e) {
        throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
    }
}
Also used : SoftwareConfiguration(org.dcm4chee.arc.event.SoftwareConfiguration) JsonParsingException(javax.json.stream.JsonParsingException)

Example 3 with SoftwareConfiguration

use of org.dcm4chee.arc.event.SoftwareConfiguration in project dcm4chee-arc-light by dcm4che.

the class ArchiveServiceImpl method mergeSoftwareVersions.

private void mergeSoftwareVersions() {
    Properties gitProps = new Properties();
    InputStream in = ArchiveService.class.getResourceAsStream("git.properties");
    if (in == null) {
        LOG.warn("Missing git.properties");
        return;
    }
    try {
        gitProps.load(in);
    } catch (IOException e) {
        LOG.warn("Failed to read git.properties", e);
        return;
    }
    String[] versions = { "master".equals(gitProps.getProperty("git.branch")) ? gitProps.getProperty("git.build.version") : gitProps.getProperty("git.build.version") + '-' + gitProps.getProperty("git.branch"), gitProps.getProperty("git.commit.id.abbrev"), gitProps.getProperty("git.commit.time") };
    if (!LdapUtils.equals(device.getSoftwareVersions(), versions)) {
        try {
            LOG.info("Update Software Version in LDAP to: {}", Arrays.toString(versions));
            device.setSoftwareVersions(versions);
            ConfigurationChanges diffs = conf.merge(device, EnumSet.of(DicomConfiguration.Option.PRESERVE_VENDOR_DATA, DicomConfiguration.Option.PRESERVE_CERTIFICATE, DicomConfiguration.Option.CONFIGURATION_CHANGES));
            softwareConfigurationEvent.fire(new SoftwareConfiguration(null, device.getDeviceName(), diffs));
        } catch (ConfigurationException e) {
            LOG.warn("Failed to update Software Version in LDAP:\n", e);
        }
    }
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) SoftwareConfiguration(org.dcm4chee.arc.event.SoftwareConfiguration) Properties(java.util.Properties)

Example 4 with SoftwareConfiguration

use of org.dcm4chee.arc.event.SoftwareConfiguration in project dcm4chee-arc-light by dcm4che.

the class UpdateMetadataScheduler method updateDeviceConfiguration.

private void updateDeviceConfiguration(ArchiveDeviceExtension arcDev) {
    try {
        LOG.info("Update Storage configuration of Device: {}:\n", device.getDeviceName());
        ConfigurationChanges diffs = conf.merge(device, EnumSet.of(DicomConfiguration.Option.PRESERVE_VENDOR_DATA, DicomConfiguration.Option.PRESERVE_CERTIFICATE, arcDev.isAuditSoftwareConfigurationVerbose() ? DicomConfiguration.Option.CONFIGURATION_CHANGES_VERBOSE : DicomConfiguration.Option.CONFIGURATION_CHANGES));
        softwareConfigurationEvent.fire(new SoftwareConfiguration(null, device.getDeviceName(), diffs));
    } catch (ConfigurationException e) {
        LOG.warn("Failed to update Storage configuration of Device: {}:\n", device.getDeviceName(), e);
    }
}
Also used : ConfigurationChanges(org.dcm4che3.conf.api.ConfigurationChanges) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) SoftwareConfiguration(org.dcm4chee.arc.event.SoftwareConfiguration)

Example 5 with SoftwareConfiguration

use of org.dcm4chee.arc.event.SoftwareConfiguration in project dcm4chee-arc-light by dcm4che.

the class StoreServiceImpl method updateDeviceConfiguration.

private void updateDeviceConfiguration(ArchiveDeviceExtension arcDev) {
    Device device = arcDev.getDevice();
    try {
        LOG.info("Update Storage configuration of Device: {}", device.getDeviceName());
        ConfigurationChanges diffs = conf.merge(device, EnumSet.of(DicomConfiguration.Option.PRESERVE_VENDOR_DATA, DicomConfiguration.Option.PRESERVE_CERTIFICATE, arcDev.isAuditSoftwareConfigurationVerbose() ? DicomConfiguration.Option.CONFIGURATION_CHANGES_VERBOSE : DicomConfiguration.Option.CONFIGURATION_CHANGES));
        softwareConfigurationEvent.fire(new SoftwareConfiguration(null, device.getDeviceName(), diffs));
    } catch (ConfigurationException e) {
        LOG.warn("Failed to update Storage configuration of Device: {}:\n", device.getDeviceName(), e);
    }
}
Also used : ConfigurationChanges(org.dcm4che3.conf.api.ConfigurationChanges) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) SoftwareConfiguration(org.dcm4chee.arc.event.SoftwareConfiguration)

Aggregations

SoftwareConfiguration (org.dcm4chee.arc.event.SoftwareConfiguration)5 JsonParsingException (javax.json.stream.JsonParsingException)2 ConfigurationChanges (org.dcm4che3.conf.api.ConfigurationChanges)2 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1