Skip to content

Commit

Permalink
EmptyTocd moved from kapua-certificate-internal to kapua-commons
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
  • Loading branch information
Claudio Mezzasalma committed Nov 13, 2019
1 parent d456937 commit 0e2afc5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
@@ -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
Expand Up @@ -14,13 +14,12 @@
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.commons.configuration.metatype.EmptyTocd;
import org.eclipse.kapua.commons.security.KapuaSecurityUtils;
import org.eclipse.kapua.commons.util.ArgumentValidator;
import org.eclipse.kapua.commons.util.KapuaFileUtils;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.locator.KapuaProvider;
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.model.domain.Actions;
import org.eclipse.kapua.model.id.KapuaId;
Expand All @@ -45,7 +44,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.namespace.QName;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand All @@ -66,6 +64,8 @@ public class CertificateServiceImpl implements CertificateService {
private String certificate;
private String privateKey;

private KapuaTocd emptyTocd;

/**
* Constructor
*/
Expand All @@ -84,6 +84,9 @@ public CertificateServiceImpl() throws KapuaException {
privateKey = CertificateUtils.readPrivateKeyAsString(KapuaFileUtils.getAsFile(privateKeyPath));
}
});

emptyTocd = new EmptyTocd(CertificateService.class.getName(), CertificateService.class.getSimpleName());

}

@Override
Expand Down Expand Up @@ -163,7 +166,7 @@ public List<Certificate> findAncestorsCertificates(KapuaId scopeId, CertificateU

@Override
public KapuaTocd getConfigMetadata(KapuaId scopeId) throws KapuaException {
return EmptyTocd.getInstance();
return emptyTocd;
}

@Override
Expand Down

0 comments on commit 0e2afc5

Please sign in to comment.