use of org.eclipse.kapua.commons.configuration.metatype.TmetadataImpl in project kapua by eclipse.
the class AbstractKapuaConfigurableService method readMetadata.
private static TmetadataImpl readMetadata(String pid) throws IOException, Exception, XMLStreamException, FactoryConfigurationError {
TmetadataImpl metaData = null;
StringBuilder sbMetatypeXmlName = new StringBuilder();
sbMetatypeXmlName.append("META-INF/metatypes/").append(pid).append(".xml");
String metatypeXmlName = sbMetatypeXmlName.toString();
URL metatypeXmlURL = ResourceUtils.getResource(metatypeXmlName);
String metatypeXml = ResourceUtils.readResource(metatypeXmlURL);
if (metatypeXml != null) {
metaData = XmlUtil.unmarshal(metatypeXml, TmetadataImpl.class);
}
return metaData;
}
use of org.eclipse.kapua.commons.configuration.metatype.TmetadataImpl in project kapua by eclipse.
the class AbstractKapuaConfigurableService method getConfigMetadata.
@Override
public KapuaTocd getConfigMetadata() throws KapuaException {
KapuaLocator locator = KapuaLocator.getInstance();
AuthorizationService authorizationService = locator.getService(AuthorizationService.class);
PermissionFactory permissionFactory = locator.getFactory(PermissionFactory.class);
KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId();
authorizationService.checkPermission(permissionFactory.newPermission(domain, Actions.read, scopeId));
try {
TmetadataImpl metadata = readMetadata(this.pid);
if (metadata.getOCD() != null && metadata.getOCD().size() > 0) {
for (KapuaTocd ocd : metadata.getOCD()) {
if (ocd.getId() != null && ocd.getId().equals(pid)) {
return ocd;
}
}
}
return null;
} catch (Exception e) {
throw KapuaConfigurationException.internalError(e);
}
}
Aggregations