Commit 5ad039ce authored by Marco Descher's avatar Marco Descher 🏔

[15349] Add base p2 rest

parent 5d951c09
Pipeline #10436 passed with stages
in 2 minutes and 23 seconds
......@@ -30,7 +30,7 @@ Service-Component: OSGI-INF/*.xml
Import-Package: io.swagger.annotations;version="1.5.18",
javax.servlet;version="3.1.0",
javax.servlet.http;version="2.4.0",
javax.ws.rs;version="1.1.1",
javax.ws.rs.core;version="2.0.1",
javax.ws.rs;version="2.0.0",
javax.ws.rs.core;version="2.0.0",
org.osgi.service.component.annotations;version="1.2.0",
org.slf4j
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" immediate="true" name="info.elexis.server.core.p2.console.ConsoleCommandProvider">
<implementation class="info.elexis.server.core.p2.console.ConsoleCommandProvider"/>
<service servicefactory="false">
<service>
<provide interface="org.eclipse.osgi.framework.console.CommandProvider"/>
</service>
<implementation class="info.elexis.server.core.p2.console.ConsoleCommandProvider"/>
</scr:component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0" immediate="true" name="info.elexis.server.core.p2.internal.HTTPService">
<implementation class="info.elexis.server.core.p2.internal.HTTPService"/>
<service servicefactory="false">
<provide interface="info.elexis.server.core.p2.internal.HTTPService"/>
</service>
</scr:component>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="info.elexis.server.core.p2.internal.HTTPService">
<service>
<provide interface="info.elexis.server.core.p2.internal.HTTPService"/>
</service>
<implementation class="info.elexis.server.core.p2.internal.HTTPService"/>
</scr:component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" immediate="true" name="info.elexis.server.core.p2.internal.Provisioner">
<implementation class="info.elexis.server.core.p2.internal.Provisioner"/>
<reference bind="setAgentProvider" cardinality="1..1" interface="org.eclipse.equinox.p2.core.IProvisioningAgentProvider" name="AgentProvider" policy="static" unbind="unsetAgentProvider"/>
<implementation class="info.elexis.server.core.p2.internal.Provisioner"/>
</scr:component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="info.elexis.server.core.p2.jaxrs.UpdateResource">
<service>
<provide interface="info.elexis.server.core.p2.jaxrs.UpdateResource"/>
</service>
<implementation class="info.elexis.server.core.p2.jaxrs.UpdateResource"/>
</scr:component>
\ No newline at end of file
package info.elexis.server.core.p2.jaxrs;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.eclipse.equinox.p2.operations.Update;
import org.osgi.service.component.annotations.Component;
import info.elexis.server.core.p2.internal.ProvisioningHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@Api(tags = { "p2" })
@Path("/p2")
@Component(service = UpdateResource.class, immediate = true)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public class UpdateResource {
@GET
@Path("updates/check")
@ApiOperation(nickname = "checkUpdates", value = "check for available updates")
public Response checkUpdates() {
List<String> resultList = new ArrayList<>();
Update[] possibleUpdates = ProvisioningHelper.getPossibleUpdates();
if (possibleUpdates != null) {
for (Update update : possibleUpdates) {
resultList.add(update.toString());
}
}
return Response.ok(resultList).build();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment