Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion devicehive-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>devicehive-server</artifactId>
<groupId>com.devicehive</groupId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ protected void configure(HttpSecurity http) throws Exception {
.authenticationEntryPoint(unauthorizedEntryPoint());

http
.addFilterBefore(new HttpAuthenticationFilter(authenticationManager()), BasicAuthenticationFilter.class)
.addFilterAfter(new SimpleCORSFilter(), HttpAuthenticationFilter.class);
.addFilterBefore(new SimpleCORSFilter(), BasicAuthenticationFilter.class)
.addFilterAfter(new HttpAuthenticationFilter(authenticationManager()), SimpleCORSFilter.class);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion devicehive-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>devicehive-server</artifactId>
<groupId>com.devicehive</groupId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion devicehive-common-dao/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.devicehive</groupId>
<artifactId>devicehive-server</artifactId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<artifactId>devicehive-common-dao</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion devicehive-common-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>devicehive-server</artifactId>
<groupId>com.devicehive</groupId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion devicehive-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.devicehive</groupId>
<artifactId>devicehive-server</artifactId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<artifactId>devicehive-common</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ public static HiveAction fromString(String text) {
return null;
}

public static HiveAction fromId(Integer id) {
if (id != null) {
for (HiveAction b : HiveAction.values()) {
if (id.equals(b.id)) {
return b;
}
}
}
return null;
}

public static Set<HiveAction> getAllHiveActions() {
return KNOWN_ACTIONS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public Portable create(int classId) {
return new Filter();
} else if (Subscriber.CLASS_ID == classId) {
return new Subscriber();
} else if (HazelcastEntityComparator.CLASS_ID == classId) {
return new HazelcastEntityComparator();
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,36 @@
* #L%
*/

import com.hazelcast.nio.serialization.Portable;
import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Date;
import java.util.Map;

public class HazelcastEntityComparator implements Comparator<Map.Entry<String, HazelcastEntity>>, Serializable {

public class HazelcastEntityComparator implements Comparator<Map.Entry<String, HazelcastEntity>>, Serializable, Portable {
private static final long serialVersionUID = 5413354955792888308L;
public static final int FACTORY_ID = 1;
public static final int CLASS_ID = 7;

@Override
public int getFactoryId() {
return FACTORY_ID;
}

@Override
public int getClassId() {
return CLASS_ID;
}

@Override
public void writePortable(PortableWriter out) {}

@Override
public void readPortable(PortableReader in) {}

@Override
public int compare(Map.Entry<String, HazelcastEntity> o1, Map.Entry<String, HazelcastEntity> o2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import javax.ws.rs.BadRequestException;
import java.util.Date;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -36,7 +37,7 @@

import static com.devicehive.auth.HiveAction.NONE;

public class JwtUserPayloadView implements HiveEntity {
public class JwtUserPayloadView<T> implements HiveEntity {

private static final long serialVersionUID = 9015868660504625526L;

Expand All @@ -54,7 +55,7 @@ public class JwtUserPayloadView implements HiveEntity {

@JsonProperty(ACTIONS)
@SerializedName(ACTIONS)
private Set<String> actions;
private Set<T> actions;

@JsonProperty(NETWORK_IDS)
@SerializedName(NETWORK_IDS)
Expand All @@ -72,7 +73,7 @@ public class JwtUserPayloadView implements HiveEntity {
@SerializedName(TOKEN_TYPE)
private TokenType tokenType;

public JwtUserPayloadView(Long userId, Set<String> actions, Set<String> networkIds,
public JwtUserPayloadView(Long userId, Set<T> actions, Set<String> networkIds,
Set<String> deviceTypeIds, Date expiration, TokenType tokenType) {
this.userId = userId;
this.actions = actions;
Expand All @@ -90,11 +91,11 @@ public void setUserId(Long userId) {
this.userId = userId;
}

public Set<String> getActions() {
public Set<T> getActions() {
return actions;
}

public void setActions(Set<String> actions) {
public void setActions(Set<T> actions) {
this.actions = actions;
}

Expand Down Expand Up @@ -134,7 +135,13 @@ public JwtUserPayload convertTo() {
Set<Integer> actionIds = Optional.ofNullable(actions)
.map(value -> value.stream()
//Here the compatibility with old behavior is provided to ignore not valid actions
.map(action -> HiveAction.fromString(action))
.map(action -> {
if (action instanceof String) {
return HiveAction.fromString((String) action);
} else if (action instanceof Number && ((Double) action - ((Double) action).intValue() == 0)) {
return HiveAction.fromId(((Double) action).intValue());
} else throw new BadRequestException("Actions list should contain only Strings or Integers");
})
.filter(Objects::nonNull)
.mapToInt(HiveAction::getId)
.boxed()
Expand All @@ -148,15 +155,15 @@ public static Builder newBuilder() {
return new Builder();
}

public static class Builder {
public static class Builder<T> {
private Long userId;
private Set<String> actions;
private Set<T> actions;
private Set<String> networkIds;
private Set<String> deviceTypeIds;
private Date expiration;
private TokenType tokenType;

public Builder withPublicClaims(Long userId, Set<String> actions,
public Builder withPublicClaims(Long userId, Set<T> actions,
Set<String> networkIds, Set<String> deviceTypeIds) {
this.userId = userId;
this.actions = actions;
Expand All @@ -165,7 +172,7 @@ public Builder withPublicClaims(Long userId, Set<String> actions,
return this;
}

public Builder withPayload(JwtUserPayloadView payload) {
public Builder withPayload(JwtUserPayloadView<T> payload) {
this.userId = payload.getUserId();
this.actions = payload.getActions();
this.networkIds = payload.getNetworkIds();
Expand All @@ -179,7 +186,7 @@ public Builder withUserId(Long userId) {
return this;
}

public Builder withActions(Set<String> actions) {
public Builder withActions(Set<T> actions) {
this.actions = actions;
return this;
}
Expand All @@ -204,8 +211,8 @@ public Builder withExpirationDate(Date expiration) {
return this;
}

public JwtUserPayloadView buildPayload() {
return new JwtUserPayloadView(userId, actions, networkIds, deviceTypeIds, expiration, tokenType);
public JwtUserPayloadView<T> buildPayload() {
return new JwtUserPayloadView<T>(userId, actions, networkIds, deviceTypeIds, expiration, tokenType);
}
}
}
2 changes: 1 addition & 1 deletion devicehive-frontend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>devicehive-server</artifactId>
<groupId>com.devicehive</groupId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ protected void configure(HttpSecurity http) throws Exception {
.authenticationEntryPoint(unauthorizedEntryPoint());

http
.addFilterBefore(new HttpAuthenticationFilter(authenticationManager()), BasicAuthenticationFilter.class)
.addFilterAfter(new SimpleCORSFilter(), HttpAuthenticationFilter.class);
.addFilterBefore(new SimpleCORSFilter(), BasicAuthenticationFilter.class)
.addFilterAfter(new HttpAuthenticationFilter(authenticationManager()), SimpleCORSFilter.class);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion devicehive-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>devicehive-server</artifactId>
<groupId>com.devicehive</groupId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ protected void configure(HttpSecurity http) throws Exception {
.authenticationEntryPoint(unauthorizedEntryPoint());

http
.addFilterBefore(new HttpAuthenticationFilter(authenticationManager()), BasicAuthenticationFilter.class)
.addFilterAfter(new SimpleCORSFilter(), HttpAuthenticationFilter.class);
.addFilterBefore(new SimpleCORSFilter(), BasicAuthenticationFilter.class)
.addFilterAfter(new HttpAuthenticationFilter(authenticationManager()), SimpleCORSFilter.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ public PluginRegisterService(
public CompletableFuture<Response> register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate,
String authorization) {
validateSubscription(pluginReqisterQuery);
PluginVO existingPlugin = pluginService.findByName(pluginUpdate.getName());
if (existingPlugin != null) {
logger.error("Plugin with name {} already exists", pluginUpdate.getName());
throw new HiveException(String.format(Messages.PLUGIN_ALREADY_EXISTS, pluginUpdate.getName()), BAD_REQUEST.getStatusCode());
}

checkAuthServiceAvailable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ auth.base.url=http://localhost:8090/dh/rest

#proxy link
proxy.connect=localhost:3000
proxy.plugin.connect=localhost:3001
proxy.plugin.connect=ws://localhost:3001
2 changes: 1 addition & 1 deletion devicehive-proxy-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.devicehive</groupId>
<artifactId>devicehive-server</artifactId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<artifactId>devicehive-proxy-api</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion devicehive-proxy-ws-kafka-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.devicehive</groupId>
<artifactId>devicehive-server</artifactId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<artifactId>devicehive-proxy-ws-kafka-impl</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion devicehive-rdbms-dao/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.devicehive</groupId>
<artifactId>devicehive-server</artifactId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<artifactId>devicehive-rdbms-dao</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ spring.datasource.username=postgres
spring.datasource.password=12345
# JPA
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=false
spring.jpa.show-sql=true
hibernate.show_sq=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
spring.jpa.properties.hibernate.format_sql=true
spring.data.jpa.repositories.enabled=false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
-- #%L
-- DeviceHive Dao RDBMS Implementation
-- %%
-- Copyright (C) 2016 DataArt
-- %%
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- #L%
---

ALTER TABLE plugin DROP CONSTRAINT plugin_name_unique;
2 changes: 1 addition & 1 deletion devicehive-shim-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.devicehive</groupId>
<artifactId>devicehive-server</artifactId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<artifactId>devicehive-shim-api</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion devicehive-shim-kafka-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>devicehive-server</artifactId>
<groupId>com.devicehive</groupId>
<version>3.4.4</version>
<version>3.4.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion devicehive-test-utils/pom.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8"?><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"> <parent> <artifactId>devicehive-server</artifactId> <groupId>com.devicehive</groupId> <version>3.4.4</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>devicehive-test-utils</artifactId> <name>DeviceHive Test Utils</name> <properties> <project.rootdir>${project.parent.basedir}</project.rootdir> </properties> <dependencies> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>${hsqldb.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate-version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-clients</artifactId> <version>${kafka.version}</version> <classifier>test</classifier> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_${scala-binaries.version}</artifactId> <version>${kafka.version}</version> <exclusions> <exclusion> <artifactId>slf4j-log4j12</artifactId> <groupId>org.slf4j</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_${scala-binaries.version}</artifactId> <version>${kafka.version}</version> <classifier>test</classifier> <exclusions> <exclusion> <artifactId>slf4j-log4j12</artifactId> <groupId>org.slf4j</groupId> </exclusion> </exclusions> </dependency> </dependencies></project>
<?xml version="1.0" encoding="UTF-8"?><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"> <parent> <artifactId>devicehive-server</artifactId> <groupId>com.devicehive</groupId> <version>3.4.5</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>devicehive-test-utils</artifactId> <name>DeviceHive Test Utils</name> <properties> <project.rootdir>${project.parent.basedir}</project.rootdir> </properties> <dependencies> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>${hsqldb.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate-version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-clients</artifactId> <version>${kafka.version}</version> <classifier>test</classifier> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_${scala-binaries.version}</artifactId> <version>${kafka.version}</version> <exclusions> <exclusion> <artifactId>slf4j-log4j12</artifactId> <groupId>org.slf4j</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_${scala-binaries.version}</artifactId> <version>${kafka.version}</version> <classifier>test</classifier> <exclusions> <exclusion> <artifactId>slf4j-log4j12</artifactId> <groupId>org.slf4j</groupId> </exclusion> </exclusions> </dependency> </dependencies></project>
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/devicehive-auth.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM openjdk:8u151-jre-slim

MAINTAINER devicehive

ENV DH_VERSION="3.4.4"
ENV DH_VERSION="3.4.5"

LABEL org.label-schema.url="https://devicehive.com" \
org.label-schema.vendor="DeviceHive" \
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/devicehive-backend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM openjdk:8u151-jre-slim

MAINTAINER devicehive

ENV DH_VERSION="3.4.4"
ENV DH_VERSION="3.4.5"

LABEL org.label-schema.url="https://devicehive.com" \
org.label-schema.vendor="DeviceHive" \
Expand Down
Loading