Skip to content

Commit 796b3e8

Browse files
v-rudkovskiyViacheslav Rudkovskyi
andauthored
NLIC-2417: return licensee custom properties in the offline validation results (#43)
* add licensee custom properties to validation result * add licensee custom properties to validation result * changes * revert --------- Co-authored-by: Viacheslav Rudkovskyi <[email protected]>
1 parent abc09fc commit 796b3e8

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/vo/ValidationResult.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,38 @@
1919
import java.util.TimeZone;
2020

2121
import com.labs64.netlicensing.domain.Constants;
22+
import com.labs64.netlicensing.domain.entity.Licensee;
23+
import com.labs64.netlicensing.domain.entity.impl.LicenseeImpl;
2224

2325
public class ValidationResult implements Serializable {
2426

2527
private static final long serialVersionUID = -4160421171524379008L;
2628

27-
private String licenseeNumber;
2829
private Calendar ttl;
2930
private Map<String, Composition> validations;
3031

32+
private Licensee licensee;
33+
34+
public void setLicensee(final Licensee licensee) {
35+
this.licensee = licensee;
36+
}
37+
38+
public Licensee getLicensee() {
39+
return this.licensee;
40+
}
41+
42+
@Deprecated
3143
public void setLicenseeNumber(final String licenseeNumber) {
32-
this.licenseeNumber = licenseeNumber;
44+
if (this.licensee == null) {
45+
this.licensee = new LicenseeImpl();
46+
}
47+
48+
this.licensee.setNumber(licenseeNumber);
3349
}
3450

51+
@Deprecated
3552
public String getLicenseeNumber() {
36-
return licenseeNumber;
53+
return (this.licensee != null) ? this.licensee.getNumber() : null;
3754
}
3855

3956
public void setTtl(final Calendar ttl) {
@@ -52,7 +69,6 @@ public Map<String, Composition> getValidations() {
5269
}
5370

5471
public ValidationResult() {
55-
licenseeNumber = null;
5672
ttl = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
5773
ttl.add(Calendar.MINUTE, Constants.ValidationResult.DEFAULT_TTL_MINUTES);
5874
}
@@ -74,8 +90,8 @@ public void put(final String productModuleNumber, final String key, final String
7490
public String toString() {
7591
final StringBuilder builder = new StringBuilder();
7692
builder.append("ValidationResult");
77-
if (licenseeNumber != null) {
78-
builder.append("(").append(licenseeNumber).append(")");
93+
if (licensee != null && licensee.getNumber() != null) {
94+
builder.append("(").append(licensee.getNumber()).append(")");
7995
}
8096
builder.append(" [");
8197
boolean first = true;

NetLicensingClient/src/main/java/com/labs64/netlicensing/schema/converter/ItemsToValidationResultConverter.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.labs64.netlicensing.domain.Constants;
44
import com.labs64.netlicensing.domain.Constants.Licensee;
5+
import com.labs64.netlicensing.domain.entity.impl.LicenseeImpl;
56
import com.labs64.netlicensing.domain.vo.Composition;
67
import com.labs64.netlicensing.domain.vo.ValidationResult;
78
import com.labs64.netlicensing.exception.ConversionException;
@@ -32,15 +33,20 @@ public ValidationResult convert(final Netlicensing source) throws ConversionExce
3233
return target;
3334
}
3435

35-
String licenseeNumber = null;
3636
for (final Item item : source.getItems().getItem()) {
3737
if (Licensee.class.getSimpleName().equals(item.getType())) {
38+
LicenseeImpl licensee = new LicenseeImpl();
39+
3840
for (final Property property : item.getProperty()) {
3941
if (Constants.Licensee.LICENSEE_NUMBER.equals(property.getName())) {
40-
licenseeNumber = property.getValue();
41-
break;
42+
licensee.setNumber(property.getValue());
43+
continue;
4244
}
45+
46+
licensee.getProperties().put(property.getName(), property.getValue());
4347
}
48+
49+
target.setLicensee(licensee);
4450
continue;
4551
}
4652

@@ -74,7 +80,6 @@ public ValidationResult convert(final Netlicensing source) throws ConversionExce
7480

7581
target.setProductModuleValidation(productModuleNumber, composition);
7682
}
77-
target.setLicenseeNumber(licenseeNumber);
7883
return target;
7984
}
8085

0 commit comments

Comments
 (0)