@@ -310,345 +310,6 @@ private static DoiReservation getReservedDoi() {
310310 }
311311 }
312312
313- /**
314- * Clean string values.
315- *
316- * @return a clean string or null
317- */
318- private String cleanStr (String input ) {
319- if (StringUtils .isBlank (input ))
320- return input ;
321-
322- return Jsoup .clean (input , Safelist .basic ());
323- }
324-
325- /**
326- * Clean String List values.
327- *
328- * @return a clean List or null
329- */
330- private List <String > cleanStrList (List <String > input ) {
331- if (input == null || input .isEmpty ())
332- return input ;
333-
334- int cnt = input .size ();
335- for (int i = 0 ; i < cnt ; i ++) {
336- input .set (i , cleanStr (input .get (i )));
337- }
338-
339- return input ;
340- }
341-
342- /**
343- * Clean Developer values.
344- *
345- * @return a clean Developer or null
346- */
347- private Developer cleanDev (Developer dev ) {
348- if (dev == null )
349- return dev ;
350-
351- dev .setEmail (cleanStr (dev .getEmail ()));
352- dev .setOrcid (cleanStr (dev .getOrcid ()));
353- dev .setFirstName (cleanStr (dev .getFirstName ()));
354- dev .setMiddleName (cleanStr (dev .getMiddleName ()));
355- dev .setLastName (cleanStr (dev .getLastName ()));
356- dev .setAffiliations (cleanStrList (dev .getAffiliations ()));
357-
358- return dev ;
359- }
360-
361- /**
362- * Clean Developer List values.
363- *
364- * @return a clean List or null
365- */
366- private List <Developer > cleanDevList (List <Developer > input ) {
367- if (input == null || input .isEmpty ())
368- return input ;
369-
370- int cnt = input .size ();
371- for (int i = 0 ; i < cnt ; i ++) {
372- input .set (i , cleanDev (input .get (i )));
373- }
374-
375- return input ;
376- }
377-
378- /**
379- * Clean Contributor values.
380- *
381- * @return a clean Contributor or null
382- */
383- private Contributor cleanCon (Contributor con ) {
384- if (con == null )
385- return con ;
386-
387- con .setEmail (cleanStr (con .getEmail ()));
388- con .setOrcid (cleanStr (con .getOrcid ()));
389- con .setFirstName (cleanStr (con .getFirstName ()));
390- con .setMiddleName (cleanStr (con .getMiddleName ()));
391- con .setLastName (cleanStr (con .getLastName ()));
392- con .setAffiliations (cleanStrList (con .getAffiliations ()));
393-
394- return con ;
395- }
396-
397- /**
398- * Clean Contributor List values.
399- *
400- * @return a clean List or null
401- */
402- private List <Contributor > cleanConList (List <Contributor > input ) {
403- if (input == null || input .isEmpty ())
404- return input ;
405-
406- int cnt = input .size ();
407- for (int i = 0 ; i < cnt ; i ++) {
408- input .set (i , cleanCon (input .get (i )));
409- }
410-
411- return input ;
412- }
413-
414- /**
415- * Clean ContributingOrganization values.
416- *
417- * @return a clean ContributorOrg or null
418- */
419- private ContributingOrganization cleanConOrg (ContributingOrganization con ) {
420- if (con == null )
421- return con ;
422-
423- con .setOrganizationName (cleanStr (con .getOrganizationName ()));
424-
425- return con ;
426- }
427-
428- /**
429- * Clean ContributingOrganization List values.
430- *
431- * @return a clean List or null
432- */
433- private List <ContributingOrganization > cleanConOrgList (List <ContributingOrganization > input ) {
434- if (input == null || input .isEmpty ())
435- return input ;
436-
437- int cnt = input .size ();
438- for (int i = 0 ; i < cnt ; i ++) {
439- input .set (i , cleanConOrg (input .get (i )));
440- }
441-
442- return input ;
443- }
444-
445- /**
446- * Clean FundingIdentifier values.
447- *
448- * @return a clean FundingIdentifier or null
449- */
450- private FundingIdentifier cleanFundIdent (FundingIdentifier fi ) {
451- if (fi == null )
452- return fi ;
453-
454- fi .setIdentifierValue (cleanStr (fi .getIdentifierValue ()));
455-
456- return fi ;
457- }
458-
459- /**
460- * Clean FundingIdentifier List values.
461- *
462- * @return a clean List or null
463- */
464- private List <FundingIdentifier > cleanFundIdentList (List <FundingIdentifier > input ) {
465- if (input == null || input .isEmpty ())
466- return input ;
467-
468- int cnt = input .size ();
469- for (int i = 0 ; i < cnt ; i ++) {
470- input .set (i , cleanFundIdent (input .get (i )));
471- }
472-
473- return input ;
474- }
475-
476- /**
477- * Clean SponsoringOrganization values.
478- *
479- * @return a clean SponsoringOrganization or null
480- */
481- private SponsoringOrganization cleanSponOrg (SponsoringOrganization con ) {
482- if (con == null )
483- return con ;
484-
485- con .setOrganizationName (cleanStr (con .getOrganizationName ()));
486- con .setFundingIdentifiers (cleanFundIdentList (con .getFundingIdentifiers ()));
487- con .setPrimaryAward (cleanStr (con .getPrimaryAward ()));
488-
489- return con ;
490- }
491-
492- /**
493- * Clean SponsoringOrganization List values.
494- *
495- * @return a clean List or null
496- */
497- private List <SponsoringOrganization > cleanSponOrgList (List <SponsoringOrganization > input ) {
498- if (input == null || input .isEmpty ())
499- return input ;
500-
501- int cnt = input .size ();
502- for (int i = 0 ; i < cnt ; i ++) {
503- input .set (i , cleanSponOrg (input .get (i )));
504- }
505-
506- return input ;
507- }
508-
509- /**
510- * Clean ResearchOrganization values.
511- *
512- * @return a clean ResearchOrganization or null
513- */
514- private ResearchOrganization cleanResOrg (ResearchOrganization con ) {
515- if (con == null )
516- return con ;
517-
518- con .setOrganizationName (cleanStr (con .getOrganizationName ()));
519-
520- return con ;
521- }
522-
523- /**
524- * Clean ResearchOrganization List values.
525- *
526- * @return a clean List or null
527- */
528- private List <ResearchOrganization > cleanResOrgList (List <ResearchOrganization > input ) {
529- if (input == null || input .isEmpty ())
530- return input ;
531-
532- int cnt = input .size ();
533- for (int i = 0 ; i < cnt ; i ++) {
534- input .set (i , cleanResOrg (input .get (i )));
535- }
536-
537- return input ;
538- }
539-
540- /**
541- * Clean RelatedIdentifier values.
542- *
543- * @return a clean RelatedIdentifier or null
544- */
545- private RelatedIdentifier cleanRelIdent (RelatedIdentifier ri ) {
546- if (ri == null )
547- return ri ;
548-
549- ri .setIdentifierValue (cleanStr (ri .getIdentifierValue ()));
550-
551- return ri ;
552- }
553-
554- /**
555- * Clean RelatedIdentifier List values.
556- *
557- * @return a clean List or null
558- */
559- private List <RelatedIdentifier > cleanRelIdentList (List <RelatedIdentifier > input ) {
560- if (input == null || input .isEmpty ())
561- return input ;
562-
563- int cnt = input .size ();
564- for (int i = 0 ; i < cnt ; i ++) {
565- input .set (i , cleanRelIdent (input .get (i )));
566- }
567-
568- return input ;
569- }
570-
571- /**
572- * Clean Award values.
573- *
574- * @return a clean Award or null
575- */
576- private Award cleanAward (Award a ) {
577- if (a == null )
578- return a ;
579-
580- a .setAwardDoi (cleanStr (a .getAwardDoi ()));
581- a .setFunderName (cleanStr (a .getFunderName ()));
582-
583- return a ;
584- }
585-
586- /**
587- * Clean Award List values.
588- *
589- * @return a clean List or null
590- */
591- private List <Award > cleanAwardList (List <Award > input ) {
592- if (input == null || input .isEmpty ())
593- return input ;
594-
595- int cnt = input .size ();
596- for (int i = 0 ; i < cnt ; i ++) {
597- input .set (i , cleanAward (input .get (i )));
598- }
599-
600- return input ;
601- }
602-
603- /**
604- * Clean metadata object values.
605- */
606- private void cleanMetadataObject (DOECodeMetadata md ) {
607- md .setSiteOwnershipCode (cleanStr (md .getSiteOwnershipCode ()));
608- md .setRepositoryLink (cleanStr (md .getRepositoryLink ()));
609- md .setLandingPage (cleanStr (md .getLandingPage ()));
610- md .setAccessLimitations (cleanStrList (md .getAccessLimitations ()));
611- // clean OfficialUseOnly
612- OfficialUseOnly ouo = md .getOfficialUseOnly ();
613- if (ouo != null ) {
614- ouo .setExemptionNumber (cleanStr (ouo .getExemptionNumber ()));
615- ouo .setProtectionOther (cleanStr (ouo .getProtectionOther ()));
616- ouo .setProgramOffice (cleanStr (ouo .getProgramOffice ()));
617- ouo .setProtectionReason (cleanStr (ouo .getProtectionReason ()));
618- }
619- md .setDevelopers (cleanDevList (md .getDevelopers ()));
620- md .setContributors (cleanConList (md .getContributors ()));
621- md .setContributingOrganizations (cleanConOrgList (md .getContributingOrganizations ()));
622- md .setSponsoringOrganizations (cleanSponOrgList (md .getSponsoringOrganizations ()));
623- md .setResearchOrganizations (cleanResOrgList (md .getResearchOrganizations ()));
624- md .setRelatedIdentifiers (cleanRelIdentList (md .getRelatedIdentifiers ()));
625- md .setAwardDois (cleanAwardList (md .getAwardDois ()));
626- md .setSoftwareTitle (cleanStr (md .getSoftwareTitle ()));
627- md .setAcronym (cleanStr (md .getAcronym ()));
628- md .setDoi (cleanStr (md .getDoi ()));
629- md .setDescription (cleanStr (md .getDescription ()));
630- md .setProgrammingLanguages (cleanStrList (md .getProgrammingLanguages ()));
631- md .setVersionNumber (cleanStr (md .getVersionNumber ()));
632- md .setDocumentationUrl (cleanStr (md .getDocumentationUrl ()));
633- md .setCountryOfOrigin (cleanStr (md .getCountryOfOrigin ()));
634- md .setKeywords (cleanStr (md .getKeywords ()));
635- md .setProjectKeywords (cleanStrList (md .getProjectKeywords ()));
636- md .setDisclaimers (cleanStr (md .getDisclaimers ()));
637- md .setLicenses (cleanStrList (md .getLicenses ()));
638- md .setProprietaryUrl (cleanStr (md .getProprietaryUrl ()));
639- md .setLicenseContactEmail (cleanStr (md .getLicenseContactEmail ()));
640- md .setRecipientName (cleanStr (md .getRecipientName ()));
641- md .setRecipientEmail (cleanStr (md .getRecipientEmail ()));
642- md .setRecipientPhone (cleanStr (md .getRecipientPhone ()));
643- md .setRecipientOrg (cleanStr (md .getRecipientOrg ()));
644- md .setSiteAccessionNumber (cleanStr (md .getSiteAccessionNumber ()));
645- md .setOtherSpecialRequirements (cleanStr (md .getOtherSpecialRequirements ()));
646- md .setOwner (cleanStr (md .getOwner ()));
647- md .setFileName (cleanStr (md .getFileName ()));
648- md .setContainerName (cleanStr (md .getContainerName ()));
649- md .setLastEditor (cleanStr (md .getLastEditor ()));
650- }
651-
652313 /**
653314 * Acquire a unique DOI reservation value. Requires authentication.
654315 *
@@ -732,8 +393,6 @@ public Response getSingleRecord(@PathParam("codeId") Long codeId, @QueryParam("f
732393 if (!user .hasRole ("RecordAdmin" ))
733394 md .setChangeLog (null );
734395
735- cleanMetadataObject (md );
736-
737396 // if YAML is requested, return that; otherwise, default to JSON
738397 try {
739398 if ("yaml" .equals (format )) {
0 commit comments