Search in sources :

Example 1 with OpenStackImageProvider

use of org.ovirt.engine.api.model.OpenStackImageProvider in project ovirt-engine by oVirt.

the class BackendOpenStackImageResource method addParents.

@Override
protected OpenStackImage addParents(OpenStackImage image) {
    OpenStackImageProvider provider = new OpenStackImageProvider();
    provider.setId(providerId);
    image.setOpenstackImageProvider(provider);
    return super.addParents(image);
}
Also used : OpenStackImageProvider(org.ovirt.engine.api.model.OpenStackImageProvider)

Example 2 with OpenStackImageProvider

use of org.ovirt.engine.api.model.OpenStackImageProvider in project ovirt-engine by oVirt.

the class V3OpenStackImageProviderInAdapter method adapt.

@Override
public OpenStackImageProvider adapt(V3OpenStackImageProvider from) {
    OpenStackImageProvider to = new OpenStackImageProvider();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetAuthenticationUrl()) {
        to.setAuthenticationUrl(from.getAuthenticationUrl());
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetPassword()) {
        to.setPassword(from.getPassword());
    }
    if (from.isSetProperties()) {
        to.setProperties(new Properties());
        to.getProperties().getProperties().addAll(adaptIn(from.getProperties().getProperties()));
    }
    if (from.isSetRequiresAuthentication()) {
        to.setRequiresAuthentication(from.isRequiresAuthentication());
    }
    if (from.isSetTenantName()) {
        to.setTenantName(from.getTenantName());
    }
    if (from.isSetUrl()) {
        to.setUrl(from.getUrl());
    }
    if (from.isSetUsername()) {
        to.setUsername(from.getUsername());
    }
    return to;
}
Also used : V3OpenStackImageProvider(org.ovirt.engine.api.v3.types.V3OpenStackImageProvider) OpenStackImageProvider(org.ovirt.engine.api.model.OpenStackImageProvider) Properties(org.ovirt.engine.api.model.Properties)

Example 3 with OpenStackImageProvider

use of org.ovirt.engine.api.model.OpenStackImageProvider in project ovirt-engine by oVirt.

the class BackendOpenStackImageProviderResourceTest method testConflictedUpdate.

@Test
public void testConflictedUpdate() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpGetEntityExpectations(1);
    OpenStackImageProvider model = getModel(1);
    model.setId(GUIDS[1].toString());
    try {
        resource.update(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyImmutabilityConstraint(wae);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) OpenStackImageProvider(org.ovirt.engine.api.model.OpenStackImageProvider) Test(org.junit.Test) AbstractBackendSubResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)

Example 4 with OpenStackImageProvider

use of org.ovirt.engine.api.model.OpenStackImageProvider in project ovirt-engine by oVirt.

the class OpenStackImageProviderMapper method map.

@Mapping(from = Provider.class, to = OpenStackImageProvider.class)
public static OpenStackImageProvider map(Provider<OpenStackImageProviderProperties> entity, OpenStackImageProvider template) {
    OpenStackImageProvider model = template != null ? template : new OpenStackImageProvider();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    if (entity.getDescription() != null) {
        model.setDescription(entity.getDescription());
    }
    if (entity.getUrl() != null) {
        model.setUrl(entity.getUrl());
    }
    if (entity.getAuthUrl() != null) {
        model.setAuthenticationUrl(entity.getAuthUrl());
    }
    model.setRequiresAuthentication(entity.isRequiringAuthentication());
    if (entity.getUsername() != null) {
        model.setUsername(entity.getUsername());
    }
    // The password isn't mapped for security reasons.
    // if (entity.getPassword() != null) {
    // model.setPassword(entity.getPassword());
    // }
    Map<String, String> customProperties = entity.getCustomProperties();
    if (customProperties != null) {
        Properties properties = new Properties();
        for (Map.Entry<String, String> entry : customProperties.entrySet()) {
            Property property = new Property();
            property.setName(entry.getKey());
            property.setValue(entry.getValue());
            properties.getProperties().add(property);
        }
        model.setProperties(properties);
    }
    OpenStackImageProviderProperties additionalProperties = entity.getAdditionalProperties();
    if (additionalProperties != null) {
        if (additionalProperties.getTenantName() != null) {
            model.setTenantName(additionalProperties.getTenantName());
        }
    }
    return model;
}
Also used : OpenStackImageProvider(org.ovirt.engine.api.model.OpenStackImageProvider) Properties(org.ovirt.engine.api.model.Properties) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.ovirt.engine.api.model.Property) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 5 with OpenStackImageProvider

use of org.ovirt.engine.api.model.OpenStackImageProvider in project ovirt-engine by oVirt.

the class BackendOpenStackImageProviderResourceTest method getModel.

private OpenStackImageProvider getModel(int index) {
    OpenStackImageProvider model = new OpenStackImageProvider();
    model.setName(NAMES[index]);
    model.setDescription(DESCRIPTIONS[index]);
    return model;
}
Also used : OpenStackImageProvider(org.ovirt.engine.api.model.OpenStackImageProvider)

Aggregations

OpenStackImageProvider (org.ovirt.engine.api.model.OpenStackImageProvider)6 Properties (org.ovirt.engine.api.model.Properties)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Test (org.junit.Test)1 Property (org.ovirt.engine.api.model.Property)1 AbstractBackendSubResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)1 Mapping (org.ovirt.engine.api.restapi.types.Mapping)1 V3OpenStackImageProvider (org.ovirt.engine.api.v3.types.V3OpenStackImageProvider)1 OpenStackImageProviderProperties (org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties)1