Skip to content

Commit

Permalink
Updated bundle name and structure. Only tests missing
Browse files Browse the repository at this point in the history
Signed-off-by: SimoneFiorani <[email protected]>
  • Loading branch information
sfiorani committed Sep 14, 2023
1 parent a904001 commit 8a17ffd
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion kura/distrib/config/kura.build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ org.eclipse.kura.rest.inventory.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.command.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.position.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.security.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.services.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.service.listing.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.system.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.request.handler.jaxrs.version=1.3.0-SNAPSHOT
org.eclipse.kura.rest.wire.provider.version=1.3.0-SNAPSHOT
Expand Down
8 changes: 4 additions & 4 deletions kura/distrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@
</artifactItem>
<artifactItem>
<groupId>org.eclipse.kura</groupId>
<artifactId>org.eclipse.kura.rest.services.provider</artifactId>
<version>${org.eclipse.kura.rest.services.provider.version}</version>
<artifactId>org.eclipse.kura.rest.service.listing.provider</artifactId>
<version>${org.eclipse.kura.rest.service.listing.provider.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.eclipse.kura</groupId>
Expand Down Expand Up @@ -822,7 +822,7 @@
<move file="target/plugins/org.eclipse.kura.rest.command.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.command.provider_${org.eclipse.kura.rest.command.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.position.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.security.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.services.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.services.provider_${org.eclipse.kura.rest.services.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.service.listing.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.system.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.request.handler.jaxrs.jar" tofile="target/plugins/org.eclipse.kura.request.handler.jaxrs_${org.eclipse.kura.request.handler.jaxrs.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.wire.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.wire.provider_${org.eclipse.kura.rest.wire.provider.version}.jar" />
Expand Down Expand Up @@ -2537,7 +2537,7 @@
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.command.provider_${org.eclipse.kura.rest.command.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.services.provider_${org.eclipse.kura.rest.services.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.asset.provider_${org.eclipse.kura.rest.asset.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<!-- Add Artemis bundles-->
Expand Down
4 changes: 2 additions & 2 deletions kura/distrib/src/main/ant/build_equinox_distrib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ fi]]>
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.services.provider_${org.eclipse.kura.rest.services.provider.version}.jar@4:start" />
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
Expand Down Expand Up @@ -1422,7 +1422,7 @@ fi]]>
file="${project.build.directory}/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.services.provider_${org.eclipse.kura.rest.services.provider.version}.jar"
file="${project.build.directory}/plugins/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Services REST Service
Bundle-SymbolicName: org.eclipse.kura.rest.services.provider;singleton:=true
Bundle-SymbolicName: org.eclipse.kura.rest.service.listing.provider;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/*.xml
Import-Package: org.slf4j;version="1.7.25",
javax.ws.rs;version="2.0.1",
javax.ws.rs.core;version="2.0.1",
javax.annotation.security;version="1.2.0",
org.osgi.framework;version="1.8.0",
org.eclipse.kura;version="[1.3,2.0)",
org.eclipse.kura.cloudconnection.request;version="[1.0,2.0)",
org.eclipse.kura.request.handler.jaxrs;version="[1.0,2.0)",
org.eclipse.kura.request.handler.jaxrs.annotation;version="[1.0,2.0)",
javax.ws.rs;version="2.0.1",
javax.ws.rs.core;version="2.0.1",
org.osgi.service.useradmin;version="1.1.0";resolution:=optional
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
Eurotech
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.kura.internal.rest.services.provider.RestServicesProvider">
<implementation class="org.eclipse.kura.internal.rest.services.provider.RestServicesProvider"/>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.kura.internal.rest.service.listing.provider.RestServiceListingProviderstingProvider">
<implementation class="org.eclipse.kura.internal.rest.service.listing.provider.RestServiceListingProvider"/>

<property name="kura.service.pid" type="String" value="org.eclipse.kura.internal.rest.services.provider.RestServicesProvider"/>
<property name="kura.service.pid" type="String" value="org.eclipse.kura.internal.rest.service.listing.provider.RestServiceListingProvider"/>

<reference interface="org.eclipse.kura.cloudconnection.request.RequestHandlerRegistry"
bind="bindRequestHandlerRegistry"
Expand All @@ -32,7 +32,7 @@
policy="static"/>

<service>
<provide interface="org.eclipse.kura.internal.rest.services.provider.RestServicesProvider"/>
<provide interface="org.eclipse.kura.internal.rest.service.listing.provider.RestServiceListingProvider"/>
</service>

<property name="service.pid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
${project.basedir}/../test/*/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>

<artifactId>org.eclipse.kura.rest.services.provider</artifactId>
<artifactId>org.eclipse.kura.rest.service.listing.provider</artifactId>
<packaging>eclipse-plugin</packaging>
<version>1.0.0-SNAPSHOT</version>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.eclipse.kura.internal.rest.services.provider;
package org.eclipse.kura.internal.rest.service.listing.provider;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -16,8 +16,8 @@
import org.eclipse.kura.KuraException;
import org.eclipse.kura.cloudconnection.request.RequestHandler;
import org.eclipse.kura.cloudconnection.request.RequestHandlerRegistry;
import org.eclipse.kura.internal.rest.services.provider.dto.InterfacesIdsDTO;
import org.eclipse.kura.internal.rest.services.provider.dto.ServicesDTO;
import org.eclipse.kura.internal.rest.service.listing.provider.dto.InterfacesIdsDTO;
import org.eclipse.kura.internal.rest.service.listing.provider.dto.ServiceListDTO;
import org.eclipse.kura.request.handler.jaxrs.DefaultExceptionHandler;
import org.eclipse.kura.request.handler.jaxrs.JaxRsRequestHandlerProxy;
import org.osgi.framework.BundleContext;
Expand All @@ -29,14 +29,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Path("services/v1")
public class RestServicesProvider {
@Path("serviceListing/v1")
public class RestServiceListingProvider {

private static final Logger logger = LoggerFactory.getLogger(RestServicesProvider.class);
private static final Logger logger = LoggerFactory.getLogger(RestServiceListingProvider.class);
private static final String DEBUG_MESSSAGE = "Processing request for method '{}'";

private static final String MQTT_APP_ID = "SER-V1";
private static final String REST_ROLE_NAME = "services";
private static final String MQTT_APP_ID = "SERLIST-V1";
private static final String REST_ROLE_NAME = "serviceListing";
private static final String KURA_PERMISSION_REST_ROLE = "kura.permission.rest." + REST_ROLE_NAME;

private static final String KURA_SERVICE_PID_FILTER = "kura.service.pid";
Expand Down Expand Up @@ -73,28 +73,30 @@ public void unbindRequestHandlerRegistry(RequestHandlerRegistry registry) {
@RolesAllowed(REST_ROLE_NAME)
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public ServicesDTO getServicesList() {
public ServiceListDTO getServicesList() {
try {
logger.debug(DEBUG_MESSSAGE, "securityServices/v1/services");
logger.debug(DEBUG_MESSSAGE, "serviceListing/v1/list");

BundleContext context = FrameworkUtil.getBundle(RestServicesProvider.class).getBundleContext();
BundleContext context = FrameworkUtil.getBundle(RestServiceListingProvider.class).getBundleContext();
List<String> resultDTO = getAllServices(context);

return new ServicesDTO(resultDTO);
return new ServiceListDTO(resultDTO);
} catch (Exception e) {
throw DefaultExceptionHandler.toWebApplicationException(e);
}

}

@POST
@RolesAllowed("byAllInterfaces")
@RolesAllowed(REST_ROLE_NAME)
@Path("/list/byAllInterfaces")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public ServicesDTO getServicesByInterface(final InterfacesIdsDTO interfaceIds) {
public ServiceListDTO getServicesByInterface(final InterfacesIdsDTO interfaceIds) {
try {

logger.debug(DEBUG_MESSSAGE, "serviceListing/v1/list/byAllInterfaces");

InterfacesIdsDTO returnInterfaceIds;
if (interfaceIds == null) {
returnInterfaceIds = new InterfacesIdsDTO(null);
Expand All @@ -104,7 +106,7 @@ public ServicesDTO getServicesByInterface(final InterfacesIdsDTO interfaceIds) {
returnInterfaceIds = interfaceIds;
}

BundleContext context = FrameworkUtil.getBundle(RestServicesProvider.class).getBundleContext();
BundleContext context = FrameworkUtil.getBundle(RestServiceListingProvider.class).getBundleContext();

return generateResponseDTO(context, returnInterfaceIds);

Expand Down Expand Up @@ -164,10 +166,10 @@ private String generateFilterString(List<String> interfacesIds) {
return filterStringBuilder.toString();
}

private ServicesDTO generateResponseDTO(BundleContext context, InterfacesIdsDTO returnInterfaceIds)
private ServiceListDTO generateResponseDTO(BundleContext context, InterfacesIdsDTO returnInterfaceIds)
throws KuraException, InvalidSyntaxException {
try {
return new ServicesDTO(getStrictFilteredInterfaces(context, returnInterfaceIds.getInterfacesIds()));
return new ServiceListDTO(getStrictFilteredInterfaces(context, returnInterfaceIds.getInterfacesIds()));
} catch (NullPointerException ex) {
throw new KuraException(KuraErrorCode.BAD_REQUEST, "No result found for the passed interfaces");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.eclipse.kura.internal.rest.services.provider.dto;
package org.eclipse.kura.internal.rest.service.listing.provider.dto;

import java.util.List;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
* Eurotech
*******************************************************************************/

package org.eclipse.kura.internal.rest.services.provider.dto;
package org.eclipse.kura.internal.rest.service.listing.provider.dto;

import java.util.List;

public class ServicesDTO {
public class ServiceListDTO {

List<String> keystoreServices;

public ServicesDTO(List<String> entries) {
public ServiceListDTO(List<String> entries) {
this.keystoreServices = entries;
}

Expand Down
2 changes: 1 addition & 1 deletion kura/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<module>org.eclipse.kura.rest.command.provider</module>
<module>org.eclipse.kura.rest.position.provider</module>
<module>org.eclipse.kura.rest.security.provider</module>
<module>org.eclipse.kura.rest.services.provider</module>
<module>org.eclipse.kura.rest.service.listing.provider</module>
<module>org.eclipse.kura.rest.system.provider</module>
<module>org.eclipse.kura.request.handler.jaxrs</module>
<module>org.eclipse.kura.rest.wire.provider</module>
Expand Down

0 comments on commit 8a17ffd

Please sign in to comment.