This repository was archived by the owner on Oct 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1313import java .io .File ;
1414import java .io .Reader ;
1515import java .util .List ;
16+ import java .util .Set ;
17+ import java .util .HashSet ;
1618
1719import gov .osti .entity .BiblioLink ;
1820import gov .osti .listeners .DoeServletContextListener ;
@@ -125,6 +127,13 @@ public enum License {
125127
126128 private final String label ;
127129 private final String value ;
130+
131+ private static final Set <String > values = new HashSet <String >(License .values ().length );
132+
133+ static {
134+ for (License f : License .values ())
135+ values .add (f .value ());
136+ }
128137
129138 private License (String label , String value ) {
130139 this .label =label ;
@@ -138,6 +147,10 @@ public String value() {
138147 public String label () {
139148 return this .label ;
140149 }
150+
151+ public static boolean contains (String value ){
152+ return values .contains (value );
153+ }
141154 }
142155
143156 /**
Original file line number Diff line number Diff line change 2828import gov .osti .entity .MetadataSnapshot ;
2929import gov .osti .entity .DOECodeMetadata ;
3030import gov .osti .entity .DOECodeMetadata .Accessibility ;
31+ import gov .osti .entity .DOECodeMetadata .License ;
3132import gov .osti .entity .DOECodeMetadata .Status ;
3233import gov .osti .entity .Developer ;
3334import gov .osti .entity .DoiReservation ;
@@ -2394,6 +2395,12 @@ protected static List<String> validateSubmit(DOECodeMetadata m) {
23942395 reasons .add ("A License is required." );
23952396 else if (hasLicense && m .getLicenses ().contains (DOECodeMetadata .License .Other .value ()) && StringUtils .isBlank (m .getProprietaryUrl ()))
23962397 reasons .add ("Proprietary License URL is required." );
2398+ if (hasLicense ) {
2399+ for (String l : licenseList ) {
2400+ if (!DOECodeMetadata .License .contains (l ))
2401+ reasons .add ("License not valid: [" + l +"]" );
2402+ }
2403+ }
23972404 if (licenseContactRequired && !hasLicenseContactEmail )
23982405 reasons .add ("A License Contact Email is required." );
23992406 if (null ==m .getDevelopers () || m .getDevelopers ().isEmpty ())
You can’t perform that action at this time.
0 commit comments