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
3 changes: 2 additions & 1 deletion .github/workflows/netlicesning-client-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ jobs:
# TODO(2K): This can be better solved by preparing a custom image for the container.
MAVEN_OPTS: -Duser.home=/github/home
strategy:
fail-fast: false
matrix:
java-version: [11, 17]
include:
- java-version: 11
jdk-suffix:
jdk-suffix: ""
- java-version: 17
jdk-suffix: -jdk17

Expand Down
18 changes: 13 additions & 5 deletions NetLicensingClient-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/**</exclude>
<exclude>LICENSE</exclude>
<exclude>NOTICE</exclude>
</excludes>
</filter>
</filters>
Expand Down Expand Up @@ -69,6 +69,11 @@
<artifactId>netlicensing-client</artifactId>
<version>${project.version}</version>
</dependency>
<!-- com.helger.ph-xmldsig is using slf4j, avoid warning for no provider -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand All @@ -77,9 +82,12 @@
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>

<!-- Testing framework dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.io.IOException;
import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;

import com.labs64.netlicensing.domain.vo.Context;
import com.labs64.netlicensing.domain.vo.MetaInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.labs64.netlicensing.examples;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class RunExamples {

Expand Down
68 changes: 31 additions & 37 deletions NetLicensingClient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency> <!-- from 2.16 on: https://jersey.java.net/documentation/latest/migration.html#mig-2.16 -->
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<groupId>com.helger</groupId>
<artifactId>ph-xmldsig</artifactId>
</dependency>
<dependency><!-- from 2.26 on: https://github.com/jersey/jersey/issues/3584 -->
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -35,44 +31,42 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>

<!-- Testing framework dependencies -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<scope>test</scope>
</dependency>
<!--Support JAXB in Java 9 +-->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.helger</groupId>
<artifactId>ph-xmldsig</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<scope>test</scope>
</dependency>

<!-- Testing framework dependencies -->
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
<!-- com.helger.ph-xmldsig is using slf4j, avoid warning for no provider -->
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -93,10 +87,10 @@
</instructions>
</configuration>
</plugin>
<!-- Maven JAXB2 Plugin Documentation : https://confluence.highsource.org/x/HgBJ -->
<!-- Maven JAXB2 Plugin Documentation : https://github.com/highsource/jaxb-tools/wiki/Using-JAXB2-Basics-Plugins -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin</artifactId>
<executions>
<execution>
<goals>
Expand All @@ -114,20 +108,20 @@
Please refer to the following link for more information:
https://github.com/highsource/maven-jaxb2-plugin/wiki/Catalogs-in-Strict-Mode -->
<strict>false</strict>
<!-- see also https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-89 -->
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingIncludes>
<bindingInclude>nlic-schema-bindings.xjb</bindingInclude>
</bindingIncludes>
<specVersion>2.1</specVersion>
<specVersion>3.0</specVersion>
<extension>true</extension>
<args>
<arg>-Xvalue-constructor</arg>
<arg>-Xnamespace-prefix</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-value-constructor</artifactId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-plugins</artifactId>
</plugin>
</plugins>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import java.io.Serializable;
import java.util.Map;

import javax.ws.rs.core.Form;

/**
* Defines properties common to all (or most) of other entities.
*/
Expand All @@ -39,13 +37,6 @@ public interface BaseEntity extends Serializable {
void addProperty(String property, String value);

void removeProperty(final String property);

/**
* Converts properties of the entity to the body of POST request
*
* @return object that represents HTML form data request encoded using the "application/x-www-form-urlencoded"
* content type
*/
Form asRequestForm();


Map<String, Object> asMap();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@
package com.labs64.netlicensing.domain.entity.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;

import com.labs64.netlicensing.domain.Constants;
import com.labs64.netlicensing.domain.entity.BaseEntity;
Expand Down Expand Up @@ -95,51 +89,35 @@ public void removeProperty(final String property) {

@Override
public String toString() {
return toString(asPropertiesMap());
return toString(asMap());
}

@Override
public Form asRequestForm() {
final Form form = new Form();
for (final Entry<String, List<Object>> prop : asPropertiesMap().entrySet()) {
for (final Object value : prop.getValue()) {
if (value != null) {
form.param(prop.getKey(), value.toString());
}
}
}
return form;
}

protected MultivaluedMap<String, Object> asPropertiesMap() {
final MultivaluedMap<String, Object> map = new MultivaluedHashMap<>();
map.add(Constants.NUMBER, getNumber());
map.add(Constants.ACTIVE, getActive());
public Map<String, Object> asMap() {
final Map<String, Object> map = new HashMap<>();
map.put(Constants.NUMBER, getNumber());
map.put(Constants.ACTIVE, getActive());
if (properties != null) {
for (final Map.Entry<String, String> lp : properties.entrySet()) {
map.add(lp.getKey(), lp.getValue());
map.put(lp.getKey(), lp.getValue());
}
}
return map;
}

protected String toString(final MultivaluedMap<String, Object> propMap) {
protected String toString(final Map<String, Object> propMap) {
final StringBuilder builder = new StringBuilder(this.getClass().getSimpleName());
builder.append(" [");
boolean firstProp = true;
for (final String propKey : propMap.keySet()) {
final Object propValue = propMap.get(propKey);
if ((propValue != null) && (!(propValue instanceof Collection<?>) || (((Collection<?>) propValue).size() > 0))) {
if (propValue != null) {
builder.append(firstProp ? "" : ", ");
firstProp = false;

builder.append(propKey).append("=");
if (propValue instanceof Collection<?>) {
builder.append(propValue.toString());
} else {
final String propValueStr = String.valueOf(propValue);
builder.append(propValueStr.length() > 50 ? propValueStr.substring(0, 50) : propValue);
}
final String propValueStr = String.valueOf(propValue);
builder.append(propValueStr.length() > 50 ? propValueStr.substring(0, 50) : propValue);
}
}
return builder.append("]").toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.core.MultivaluedMap;
import java.util.Map;

import com.labs64.netlicensing.domain.Constants;
import com.labs64.netlicensing.domain.entity.Bundle;
import com.labs64.netlicensing.domain.vo.Currency;

public class BundleImpl extends BaseEntityImpl implements Bundle {

private static final long serialVersionUID = -1666422065511383898L;

private String name;

private String description;
Expand Down Expand Up @@ -100,19 +102,19 @@ public static List<String> getReservedProps() {
}

@Override
protected MultivaluedMap<String, Object> asPropertiesMap() {
final MultivaluedMap<String, Object> map = super.asPropertiesMap();
map.add(Constants.NAME, getName());
public Map<String, Object> asMap() {
final Map<String, Object> map = super.asMap();
map.put(Constants.NAME, getName());

if (getDescription() != null) {
map.add(Constants.Bundle.DESCRIPTION, getDescription());
map.put(Constants.Bundle.DESCRIPTION, getDescription());
}

map.add(Constants.PRICE, getPrice());
map.add(Constants.CURRENCY, getCurrency());
map.put(Constants.PRICE, getPrice());
map.put(Constants.CURRENCY, getCurrency());

if (getLicenseTemplateNumbers() != null) {
map.add(Constants.Bundle.LICENSE_TEMPLATE_NUMBERS, String.join(",", getLicenseTemplateNumbers()));
map.put(Constants.Bundle.LICENSE_TEMPLATE_NUMBERS, String.join(",", getLicenseTemplateNumbers()));
}

return map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
package com.labs64.netlicensing.domain.entity.impl;

import java.math.BigDecimal;

import javax.ws.rs.core.MultivaluedMap;
import java.util.Map;

import com.labs64.netlicensing.domain.Constants;
import com.labs64.netlicensing.domain.entity.Country;
Expand Down Expand Up @@ -75,12 +74,12 @@ public boolean getIsEu() {
}

@Override
protected MultivaluedMap<String, Object> asPropertiesMap() {
final MultivaluedMap<String, Object> map = super.asPropertiesMap();
map.add(Constants.Country.CODE, getCode());
map.add(Constants.Country.NAME, getName());
map.add(Constants.Country.VAT_PERCENT, getVatPercent());
map.add(Constants.Country.IS_EU, getIsEu());
public Map<String, Object> asMap() {
final Map<String, Object> map = super.asMap();
map.put(Constants.Country.CODE, getCode());
map.put(Constants.Country.NAME, getName());
map.put(Constants.Country.VAT_PERCENT, getVatPercent());
map.put(Constants.Country.IS_EU, getIsEu());
return map;
}

Expand Down
Loading