Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature service configuration rest #2732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.kapua.commons.configuration;

import javax.validation.constraints.NotNull;

import org.eclipse.kapua.KapuaEntityNotFoundException;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.commons.jpa.EntityManagerFactory;
Expand Down Expand Up @@ -176,7 +178,7 @@ private static Properties toProperties(Map<String, Object> values) {
* @return
* @throws KapuaException
*/
protected static Map<String, Object> toValues(KapuaTocd ocd, Properties props) throws KapuaException {
protected static Map<String, Object> toValues(@NotNull KapuaTocd ocd, Properties props) throws KapuaException {
List<KapuaTad> ads = ocd.getAD();
Map<String, Object> values = new HashMap<>();
for (KapuaTad ad : ads) {
Expand Down Expand Up @@ -277,7 +279,7 @@ public Map<String, Object> getConfigValues(KapuaId scopeId)
}

KapuaTocd ocd = getConfigMetadata(scopeId);
return toValues(ocd, properties);
return ocd == null ? null : toValues(ocd, properties);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.commons.configuration;

import java.util.Map;

import org.eclipse.kapua.service.config.ServiceComponentConfiguration;
import org.eclipse.kapua.commons.configuration.metatype.TocdImpl;
import org.eclipse.kapua.model.config.metatype.KapuaTocd;

/**
* Service component configuration entity implementation.
*
* @since 1.0
*/
public class ServiceComponentConfigurationImpl implements ServiceComponentConfiguration {

private String id;
private String name;
private TocdImpl definition;
private Map<String, Object> properties;

/**
* Constructor
*/
public ServiceComponentConfigurationImpl() {
}

/**
* Constructor
*
* @param id
*/
public ServiceComponentConfigurationImpl(String id) {
this.id = id;
}

@Override
public String getId() {
return id;
}

@Override
public void setId(String id) {
this.id = id;
}

@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}

@Override
public void setDefinition(KapuaTocd definition) {
this.definition = (TocdImpl) definition;
}

@Override
public KapuaTocd getDefinition() {
return definition;
}

@Override
public Map<String, Object> getProperties() {
return properties;
}

@Override
public void setProperties(Map<String, Object> properties) {
this.properties = properties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.commons.configuration;

import org.eclipse.kapua.service.config.ServiceComponentConfiguration;
import org.eclipse.kapua.service.config.ServiceConfiguration;
import org.eclipse.kapua.service.config.ServiceConfigurationFactory;
import org.eclipse.kapua.locator.KapuaProvider;

/**
* Service configuration entity service factory implementation.
*
* @since 1.0
*/
@KapuaProvider
public class ServiceConfigurationFactoryImpl implements ServiceConfigurationFactory {

@Override
public ServiceComponentConfiguration newComponentConfigurationInstance(String componentConfigurationId) {
return new ServiceComponentConfigurationImpl(componentConfigurationId);
}

@Override
public ServiceConfiguration newConfigurationInstance() {
return new ServiceConfigurationImpl();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.commons.configuration;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.kapua.service.config.ServiceComponentConfiguration;
import org.eclipse.kapua.service.config.ServiceConfiguration;

/**
* Service configuration entity implementation.
*
* @since 1.0
*/
public class ServiceConfigurationImpl implements ServiceConfiguration {

private static final long serialVersionUID = -2167999497954676423L;

private List<ServiceComponentConfiguration> configurations;

public ServiceConfigurationImpl() {
configurations = new ArrayList<>();
}

@Override
public List<ServiceComponentConfiguration> getComponentConfigurations() {
return configurations;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Eurotech and/or its affiliates and others
* Copyright (c) 2019 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -9,12 +9,11 @@
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.service.certificate.internal;
package org.eclipse.kapua.commons.configuration.metatype;

import org.eclipse.kapua.model.config.metatype.KapuaTad;
import org.eclipse.kapua.model.config.metatype.KapuaTicon;
import org.eclipse.kapua.model.config.metatype.KapuaTocd;
import org.eclipse.kapua.service.certificate.CertificateService;

import javax.xml.namespace.QName;
import java.util.Collections;
Expand All @@ -23,13 +22,15 @@

public class EmptyTocd implements KapuaTocd {

private static final EmptyTocd INSTANCE = new EmptyTocd();
private String id;
private String name;

public static EmptyTocd getInstance() {
return INSTANCE;
public EmptyTocd() {
}

private EmptyTocd() {
public EmptyTocd(String id, String name) {
this.id = id;
this.name = name;
}

@Override
Expand All @@ -38,13 +39,13 @@ public void setOtherAttributes(Map<QName, String> otherAttributes) {
}

@Override
public void setName(String value) {
// No OP implementation
public void setName(String name) {
this.name = name;
}

@Override
public void setId(String value) {
// No OP implementation
public void setId(String id) {
this.id = id;
}

@Override
Expand Down Expand Up @@ -74,12 +75,12 @@ public Map<QName, String> getOtherAttributes() {

@Override
public String getName() {
return CertificateService.class.getSimpleName();
return name;
}

@Override
public String getId() {
return CertificateService.class.getName();
return id;
}

@Override
Expand Down
Loading