Skip to content

Commit

Permalink
Revert ":heavy_minus_sign: absorbed job-engine-app-core into job-engi…
Browse files Browse the repository at this point in the history
…ne-app-web as it was not generic, neither used anywhere else"

This reverts commit 3450f05.
  • Loading branch information
dseurotech committed May 20, 2024
1 parent 9b32ac0 commit a3dc144
Show file tree
Hide file tree
Showing 22 changed files with 258 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.commons.rest.model;

import org.eclipse.kapua.model.id.KapuaId;

import javax.xml.bind.annotation.XmlElementWrapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class IsJobRunningMultipleResponse {

private List<IsJobRunningResponse> list = new ArrayList<>();

public IsJobRunningMultipleResponse() {
}

public IsJobRunningMultipleResponse(Map<KapuaId, Boolean> map) {
map.forEach((key, value) -> list.add(new IsJobRunningResponse(key, value)));
}

@XmlElementWrapper
public List<IsJobRunningResponse> getList() {
return list;
}

public void setMap(List<IsJobRunningResponse> list) {
this.list = list;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.commons.rest.model;

import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.id.KapuaIdAdapter;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

public class IsJobRunningResponse {

private KapuaId jobId;
private Boolean isRunning;

public IsJobRunningResponse() {
}

public IsJobRunningResponse(KapuaId jobId, Boolean isRunning) {
this.jobId = jobId;
this.isRunning = isRunning;
}

@XmlJavaTypeAdapter(KapuaIdAdapter.class)
public KapuaId getJobId() {
return jobId;
}

public void setJobId(KapuaId jobId) {
this.jobId = jobId;
}

@XmlElement(name = "isRunning")
public Boolean isRunning() {
return isRunning;
}

public void setRunning(Boolean isRunning) {
this.isRunning = isRunning;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.commons.rest.model;

import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.id.KapuaIdAdapter;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.HashSet;
import java.util.Set;

public class MultipleJobIdRequest {

private Set<KapuaId> jobIds = new HashSet<>();

@XmlElementWrapper(name = "jobIds")
@XmlElement(name = "jobId")
@XmlJavaTypeAdapter(KapuaIdAdapter.class)
public Set<KapuaId> getJobIds() {
return jobIds;
}

public void setJobIds(Set<KapuaId> jobIds) {
this.jobIds = jobIds;
}

}
53 changes: 53 additions & 0 deletions job-engine/app/core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Eurotech - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>kapua-job-engine-app</artifactId>
<groupId>org.eclipse.kapua</groupId>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>kapua-job-engine-app-core</artifactId>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-job-engine-client</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-job-engine-jbatch</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-job-internal</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-rest-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-service-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.core.filter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.eclipse.kapua.app.api.core.auth.KapuaTokenAuthenticationFilter;
import org.eclipse.kapua.commons.security.KapuaSecurityUtils;
import org.eclipse.kapua.commons.security.KapuaSession;
import org.eclipse.kapua.job.engine.SessionInfoHttpHeaders;
import org.eclipse.kapua.job.engine.client.filter.SessionInfoHttpHeaders;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.id.KapuaIdFactory;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class RebuildSessionFilter extends KapuaTokenAuthenticationFilter {

private final KapuaIdFactory kapuaIdFactory = KapuaLocator.getInstance().getFactory(KapuaIdFactory.class);
Expand All @@ -33,14 +33,14 @@ protected boolean onAccessDenied(ServletRequest request, ServletResponse respons
HttpServletRequest httpRequest = (HttpServletRequest) request;
String authMode = httpRequest.getHeader(SessionInfoHttpHeaders.AUTH_MODE);
switch (authMode) {
case "trusted":
KapuaId scopeId = kapuaIdFactory.newKapuaId(httpRequest.getHeader(SessionInfoHttpHeaders.SCOPE_ID_HTTP_HEADER));
KapuaId userId = kapuaIdFactory.newKapuaId(httpRequest.getHeader(SessionInfoHttpHeaders.USER_ID_HTTP_HEADER));
KapuaSecurityUtils.setSession(KapuaSession.createFrom(scopeId, userId));
return true;
case "access_token":
default:
return super.onAccessDenied(request, response);
case "trusted":
KapuaId scopeId = kapuaIdFactory.newKapuaId(httpRequest.getHeader(SessionInfoHttpHeaders.SCOPE_ID_HTTP_HEADER));
KapuaId userId = kapuaIdFactory.newKapuaId(httpRequest.getHeader(SessionInfoHttpHeaders.USER_ID_HTTP_HEADER));
KapuaSecurityUtils.setSession(KapuaSession.createFrom(scopeId, userId));
return true;
case "access_token":
default:
return super.onAccessDenied(request, response);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.core.jackson;

import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

import org.eclipse.kapua.job.engine.IsJobRunningResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.kapua.commons.rest.model.IsJobRunningResponse;
import org.eclipse.kapua.job.engine.JobStartOptions;
import org.eclipse.kapua.job.engine.app.core.mixin.IsJobRunningResponseMixin;
import org.eclipse.kapua.job.engine.app.core.mixin.JobStartOptionsMixin;
import org.eclipse.kapua.job.engine.app.core.mixin.JobStepPropertyMixin;
import org.eclipse.kapua.job.engine.app.core.mixin.KapuaIdMixin;
import org.eclipse.kapua.job.engine.app.core.jackson.mixin.IsJobRunningResponseMixin;
import org.eclipse.kapua.job.engine.app.core.jackson.mixin.JobStartOptionsMixin;
import org.eclipse.kapua.job.engine.app.core.jackson.mixin.JobStepPropertyMixin;
import org.eclipse.kapua.job.engine.app.core.jackson.mixin.KapuaIdMixin;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.job.step.definition.JobStepProperty;

import com.fasterxml.jackson.databind.ObjectMapper;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

@Provider
public class ObjectMapperProvider implements ContextResolver<ObjectMapper> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.core.deserializer;

import java.io.IOException;

import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.id.KapuaIdFactory;
package org.eclipse.kapua.job.engine.app.core.jackson.deserializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.id.KapuaIdFactory;

import java.io.IOException;

public class KapuaIdDeserializer extends JsonDeserializer<KapuaId> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.core.mixin;
package org.eclipse.kapua.job.engine.app.core.jackson.mixin;

import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.core.mixin;
package org.eclipse.kapua.job.engine.app.core.jackson.mixin;

import org.eclipse.kapua.job.engine.jbatch.JobStartOptionsImpl;

Expand All @@ -19,6 +19,4 @@

@JsonDeserialize(as = JobStartOptionsImpl.class)
@JsonIgnoreProperties("type")
public interface JobStartOptionsMixin {

}
public interface JobStartOptionsMixin { }
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.core.mixin;

import org.eclipse.kapua.service.job.step.definition.internal.JobStepPropertyImpl;
package org.eclipse.kapua.job.engine.app.core.jackson.mixin;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.eclipse.kapua.service.job.step.definition.internal.JobStepPropertyImpl;

@JsonDeserialize(as = JobStepPropertyImpl.class)
@JsonIgnoreProperties("type")
public interface JobStepPropertyMixin {

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.core.mixin;
package org.eclipse.kapua.job.engine.app.core.jackson.mixin;

import org.eclipse.kapua.job.engine.app.core.deserializer.KapuaIdDeserializer;
import org.eclipse.kapua.job.engine.app.core.serializer.KapuaIdSerializer;
import org.eclipse.kapua.job.engine.app.core.jackson.deserializer.KapuaIdDeserializer;
import org.eclipse.kapua.job.engine.app.core.jackson.serializer.KapuaIdSerializer;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@JsonDeserialize(using = KapuaIdDeserializer.class)
@JsonSerialize(using = KapuaIdSerializer.class)
public interface KapuaIdMixin {

}
public interface KapuaIdMixin { }
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.core.serializer;
package org.eclipse.kapua.job.engine.app.core.jackson.serializer;

import java.io.IOException;

Expand Down
1 change: 1 addition & 0 deletions job-engine/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<packaging>pom</packaging>

<modules>
<module>core</module>
<module>resources</module>
<module>web</module>
</modules>
Expand Down
Loading

0 comments on commit a3dc144

Please sign in to comment.