├── .github └── move.yml ├── .gitignore ├── LICENSE ├── NOTICE ├── README.md ├── client ├── perl │ ├── bulk-minting-dummy.sh │ ├── bulk-upload-dummy.sh │ └── mds-suite.pl ├── python │ ├── delete_metadata.py │ ├── get_doi.py │ ├── get_metadata.py │ ├── post_doi.py │ └── post_metadata.py ├── sample-doi1.txt ├── sample-doi2.txt ├── sample-doi3.txt └── sample-metadata.xml ├── pom.xml └── src ├── main ├── config │ └── checkstyle.xml ├── java │ └── org │ │ └── datacite │ │ └── mds │ │ ├── aspects │ │ └── LoggingAspect.java │ │ ├── domain │ │ ├── Allocator.java │ │ ├── AllocatorOrDatacentre.java │ │ ├── Allocator_Roo_Configurable.aj │ │ ├── Allocator_Roo_Entity.aj │ │ ├── Allocator_Roo_Finder.aj │ │ ├── Allocator_Roo_JavaBean.aj │ │ ├── Datacentre.java │ │ ├── Datacentre_Roo_Configurable.aj │ │ ├── Datacentre_Roo_Entity.aj │ │ ├── Datacentre_Roo_Finder.aj │ │ ├── Datacentre_Roo_JavaBean.aj │ │ ├── Dataset.java │ │ ├── Dataset_Roo_Configurable.aj │ │ ├── Dataset_Roo_Entity.aj │ │ ├── Dataset_Roo_Finder.aj │ │ ├── Dataset_Roo_JavaBean.aj │ │ ├── Media.java │ │ ├── Media_Roo_Configurable.aj │ │ ├── Media_Roo_Entity.aj │ │ ├── Media_Roo_JavaBean.aj │ │ ├── Metadata.java │ │ ├── Metadata_Roo_Configurable.aj │ │ ├── Metadata_Roo_Entity.aj │ │ ├── Metadata_Roo_JavaBean.aj │ │ ├── Prefix.java │ │ ├── Prefix_Roo_Configurable.aj │ │ ├── Prefix_Roo_Entity.aj │ │ ├── Prefix_Roo_Finder.aj │ │ └── Prefix_Roo_JavaBean.aj │ │ ├── mail │ │ ├── MailMessage.java │ │ └── MailMessageFactory.java │ │ ├── service │ │ ├── DoiService.java │ │ ├── HandleException.java │ │ ├── HandleService.java │ │ ├── MagicAuthStringService.java │ │ ├── MailService.java │ │ ├── PurgeTestPrefixService.java │ │ ├── SchemaService.java │ │ ├── SecurityException.java │ │ ├── impl │ │ │ ├── DoiServiceImpl.java │ │ │ ├── HandleServiceImpl.java │ │ │ ├── MagicAuthStringServiceImpl.java │ │ │ ├── MailServiceImpl.java │ │ │ ├── PasswordEncoderImpl.java │ │ │ ├── PurgeTestPrefixServiceImpl.java │ │ │ └── SchemaServiceImpl.java │ │ └── userdetails │ │ │ ├── AdminMasterUserDetailsServiceImpl.java │ │ │ ├── AllocatorMasterUserDetailsServiceImpl.java │ │ │ ├── BaseMasterUserDetailsService.java │ │ │ └── UserDetailsServiceImpl.java │ │ ├── tools │ │ ├── AbstractTool.java │ │ ├── AdminAccountCreator.java │ │ ├── ConsistencyChecker.java │ │ ├── DatasetCreator.java │ │ ├── conversion │ │ │ ├── BaseMetadataConvertor.java │ │ │ └── MetadataKernel20FixSchemaLocation.java │ │ └── migration │ │ │ └── NamespaceSetter.java │ │ ├── util │ │ ├── Constants.java │ │ ├── DomainUtils.java │ │ ├── FilterPredicates.java │ │ ├── SecurityUtils.java │ │ ├── Utils.java │ │ └── ValidationUtils.java │ │ ├── validation │ │ ├── ValidationHelper.java │ │ └── constraints │ │ │ ├── Doi.java │ │ │ ├── DoiPrefix.java │ │ │ ├── Email.java │ │ │ ├── ListOfDomains.java │ │ │ ├── MatchDoi.java │ │ │ ├── MatchDoiPrefix.java │ │ │ ├── MatchDomain.java │ │ │ ├── MatchPrefixes.java │ │ │ ├── MatchSymbolPrefix.java │ │ │ ├── MediaType.java │ │ │ ├── Symbol.java │ │ │ ├── URL.java │ │ │ ├── Unique.java │ │ │ ├── ValidXML.java │ │ │ └── impl │ │ │ ├── DoiOnCreateOnlyValidator.java │ │ │ ├── DoiValidator.java │ │ │ ├── EmailValidator.java │ │ │ ├── ListOfDomainsValidator.java │ │ │ ├── MatchDoiPrefixValidator.java │ │ │ ├── MatchDoiValidator.java │ │ │ ├── MatchDomainValidator.java │ │ │ ├── MatchDomainValidatorForDataset.java │ │ │ ├── MatchDomainValidatorForMedia.java │ │ │ ├── MatchPrefixesValidator.java │ │ │ ├── MatchSymbolPrefixValidator.java │ │ │ ├── MediaTypeValidator.java │ │ │ ├── SymbolValidator.java │ │ │ ├── UniqueValidator.java │ │ │ └── ValidXMLValidator.java │ │ └── web │ │ ├── ApplicationConversionServiceFactoryBean.java │ │ ├── BrowserCachingInterceptor.java │ │ ├── api │ │ ├── ApiAccessDeniedHandler.java │ │ ├── ApiBasicAuthenticationEntryPoint.java │ │ ├── ApiController.java │ │ ├── ApiHandlerExceptionResolver.java │ │ ├── ApiResponseWrapper.java │ │ ├── ApiUtils.java │ │ ├── DeletedException.java │ │ ├── NotFoundException.java │ │ ├── NullSecurityContextRepository.java │ │ └── controller │ │ │ ├── DatacentreApiController.java │ │ │ ├── DoiApiController.java │ │ │ ├── MediaApiController.java │ │ │ ├── MetadataApiController.java │ │ │ └── StatusController.java │ │ └── ui │ │ ├── SwitchUserEmptyDetailsChecker.java │ │ ├── SwitchUserFilter.java │ │ ├── UiController.java │ │ ├── UiHandlerExceptionResolver.java │ │ ├── UiUtils.java │ │ ├── UsernamePasswordAuthenticationRequireCookiesFilter.java │ │ ├── controller │ │ ├── AllocatorController.java │ │ ├── AllocatorController_Roo_Controller.aj │ │ ├── AllocatorController_Roo_Controller_Finder.aj │ │ ├── ChangePasswordController.java │ │ ├── ChangePasswordMailController.java │ │ ├── DatacentreController.java │ │ ├── DatacentreController_Roo_Controller.aj │ │ ├── DatacentreController_Roo_Controller_Finder.aj │ │ ├── DatasetController.java │ │ ├── DatasetController_Roo_Controller.aj │ │ ├── DatasetController_Roo_Controller_Finder.aj │ │ ├── LogoutOrExitController.java │ │ ├── MediaController.java │ │ ├── MediaController_Roo_Controller.aj │ │ ├── MediaController_Roo_Controller_Finder.aj │ │ ├── MetadataController.java │ │ ├── MetadataController_Roo_Controller.aj │ │ ├── PrefixController.java │ │ ├── PrefixController_Roo_Controller.aj │ │ ├── PrefixController_Roo_Controller_Finder.aj │ │ ├── UserInfoController.java │ │ └── WelcomeController.java │ │ └── model │ │ ├── ChangePasswordMailModel.java │ │ ├── ChangePasswordModel.java │ │ ├── CreateDatasetModel.java │ │ └── PrefixCreateModel.java ├── resources │ ├── META-INF │ │ ├── persistence.xml.template │ │ └── spring │ │ │ ├── applicationContext-security.xml │ │ │ ├── applicationContext.xml │ │ │ ├── database.properties.template │ │ │ ├── email.properties.template │ │ │ ├── handle.properties.template │ │ │ ├── salt.properties.template │ │ │ └── xml-validator.properties.template │ ├── ValidationMessages.properties │ ├── ValidationMessages_de.properties │ ├── ValidationMessages_fr.properties │ ├── conversion │ │ └── metadata-kernel-2.0_fix-schema-location.xslt │ ├── log4j.properties.template │ ├── log4j.xml.template │ └── template │ │ ├── ResetPasswordMail │ │ ├── WelcomeAllocatorMail │ │ └── WelcomeDatacentreMail └── webapp │ ├── WEB-INF │ ├── classes │ │ └── standard.properties │ ├── i18n │ │ ├── application.properties │ │ ├── application_de.properties │ │ ├── application_fr.properties │ │ ├── messages.properties │ │ ├── messages_de.properties │ │ └── messages_fr.properties │ ├── layouts │ │ ├── default.jspx │ │ └── layouts.xml │ ├── spring │ │ ├── link.properties.template │ │ └── webmvc-config.xml │ ├── tags │ │ ├── form │ │ │ ├── create.tagx │ │ │ ├── dependency.tagx │ │ │ ├── fields │ │ │ │ ├── checkbox.tagx │ │ │ │ ├── column.tagx │ │ │ │ ├── datetime.tagx │ │ │ │ ├── display.tagx │ │ │ │ ├── editor.tagx │ │ │ │ ├── input.tagx │ │ │ │ ├── reference.tagx │ │ │ │ ├── select.tagx │ │ │ │ ├── simple.tagx │ │ │ │ ├── table.tagx │ │ │ │ ├── textarea.tagx │ │ │ │ └── upload.tagx │ │ │ ├── find.tagx │ │ │ ├── list.tagx │ │ │ ├── show.tagx │ │ │ └── update.tagx │ │ ├── menu │ │ │ ├── category.tagx │ │ │ ├── item.tagx │ │ │ └── menu.tagx │ │ └── util │ │ │ ├── change-password.tagx │ │ │ ├── checkbox.tagx │ │ │ ├── comment-xml-upload.tagx │ │ │ ├── comment.tagx │ │ │ ├── crypt-mail-setup.tagx │ │ │ ├── hide.tagx │ │ │ ├── highlight.tagx │ │ │ ├── indent.tagx │ │ │ ├── language.tagx │ │ │ ├── list.tagx │ │ │ ├── load-scripts.tagx │ │ │ ├── pagination.tagx │ │ │ ├── panel.tagx │ │ │ ├── placeholder.tagx │ │ │ ├── tab.tagx │ │ │ ├── tabs.tagx │ │ │ ├── theme.tagx │ │ │ ├── toc.tagx │ │ │ └── tooltip.tagx │ ├── views │ │ ├── accessDenied.jspx │ │ ├── allocators │ │ │ ├── create.jspx │ │ │ ├── findAllocatorsByNameLike.jspx │ │ │ ├── findAllocatorsBySymbolEquals.jspx │ │ │ ├── list.jspx │ │ │ ├── show.jspx │ │ │ ├── update.jspx │ │ │ └── views.xml │ │ ├── dataAccessFailure.jspx │ │ ├── datacentres │ │ │ ├── create.jspx │ │ │ ├── findDatacentresByNameLike.jspx │ │ │ ├── findDatacentresBySymbolEquals.jspx │ │ │ ├── list.jspx │ │ │ ├── show.jspx │ │ │ ├── update.jspx │ │ │ └── views.xml │ │ ├── datasets │ │ │ ├── create.jspx │ │ │ ├── findDatasetsByDoiEquals.jspx │ │ │ ├── list.jspx │ │ │ ├── show.jspx │ │ │ ├── update.jspx │ │ │ └── views.xml │ │ ├── footer.jspx │ │ ├── header.jspx │ │ ├── index.jspx │ │ ├── login.jspx │ │ ├── medias │ │ │ ├── create.jspx │ │ │ ├── findMediasByDataset.jspx │ │ │ ├── list.jspx │ │ │ ├── show.jspx │ │ │ ├── update.jspx │ │ │ └── views.xml │ │ ├── menu.jspx │ │ ├── metadatas │ │ │ ├── create.jspx │ │ │ ├── list.jspx │ │ │ ├── show.jspx │ │ │ ├── update.jspx │ │ │ └── views.xml │ │ ├── password │ │ │ ├── change │ │ │ │ ├── change.jspx │ │ │ │ ├── expired.jspx │ │ │ │ ├── success.jspx │ │ │ │ └── views.xml │ │ │ └── mail │ │ │ │ ├── mail.jspx │ │ │ │ ├── success.jspx │ │ │ │ └── views.xml │ │ ├── prefixes │ │ │ ├── create.jspx │ │ │ ├── findPrefixesByPrefixLike.jspx │ │ │ ├── list.jspx │ │ │ ├── show.jspx │ │ │ ├── update.jspx │ │ │ └── views.xml │ │ ├── resourceNotFound.jspx │ │ ├── static │ │ │ ├── apidoc.jspx │ │ │ └── views.xml │ │ ├── uncaughtException.jspx │ │ ├── userinfo │ │ │ ├── show.jspx │ │ │ └── views.xml │ │ ├── views.xml │ │ └── welcome.jspx │ └── web.xml │ ├── images │ ├── add.png │ ├── banner-graphic.png │ ├── banner.gif │ ├── create.png │ ├── dc-logo.gif │ ├── delete.png │ ├── favicon.png │ ├── flags │ │ ├── de.png │ │ ├── en.png │ │ ├── flags-license.txt │ │ └── fr.png │ ├── list.png │ ├── page_go.png │ ├── resultset_first.png │ ├── resultset_last.png │ ├── resultset_next.png │ ├── resultset_previous.png │ ├── show.png │ ├── silk-icon-set-license.txt │ ├── springsource-logo.png │ └── update.png │ ├── js │ ├── autotoc.js │ ├── dojox.highlight.languages.pygments.xmlfix.js │ ├── jquery-1.5.1.min.js │ └── jquery.twosidedmultiselect.js │ ├── schemas │ └── datacite-metadata-2010-11-17.xml │ └── styles │ └── standard.css └── test ├── java └── org │ └── datacite │ └── mds │ ├── domain │ ├── AllocatorOrDatacentreTest.java │ ├── DatacentreTest.java │ ├── MetadataTest.java │ └── PrefixTest.java │ ├── mail │ └── MailMessageTest.java │ ├── service │ ├── impl │ │ ├── DoiServiceImplTest.java │ │ ├── HandleServiceImplTest.java │ │ ├── MagicAuthStringImplTest.java │ │ ├── MailServiceImplTest.java │ │ ├── PasswordEncoderImplTest.java │ │ ├── PurgeTestPrefixServiceImplTest.java │ │ └── SchemaServiceImplTest.java │ └── userdetails │ │ ├── AdminMasterUserDetailsServiceImplTest.java │ │ ├── AllocatorMasterUserDetailsServiceImplTest.java │ │ ├── BaseMasterUserDetailsServiceImplTest.java │ │ └── UserDetailsServiceImplTest.java │ ├── test │ └── TestUtils.java │ ├── tools │ └── conversion │ │ └── MetadataKernel20FixSchemaLocationTest.java │ ├── util │ ├── DomainUtilsTest.java │ ├── FilterPredicatesTest.java │ ├── SecurityUtilsTest.java │ ├── UtilsTest.java │ └── ValidationUtilsTest.java │ ├── validation │ └── constraints │ │ ├── AbstractContraintsTest.java │ │ ├── DoiPrefixTest.java │ │ ├── DoiTest.java │ │ ├── EmailTest.java │ │ ├── ListOfDomainsTest.java │ │ ├── MatchDoiPrefixTest.java │ │ ├── MatchDoiTest.java │ │ ├── MatchDomainTest.java │ │ ├── MatchPrefixesTest.java │ │ ├── MatchSymbolPrefixTest.java │ │ ├── MediaTypeTest.java │ │ ├── SymbolTest.java │ │ ├── URLTest.java │ │ ├── UniqueTest.java │ │ ├── UniqueTestEntity.java │ │ └── ValidXmlTest.java │ └── web │ ├── api │ └── controller │ │ ├── DatacentreApiControllerTest.java │ │ ├── DoiApiControllerTest.java │ │ ├── MediaApiControllerTest.java │ │ └── MetadataApiControllerTest.java │ └── ui │ ├── UiUtilsTest.java │ └── controller │ ├── ChangePasswordControllerTest.java │ ├── ChangePasswordMailControllerTest.java │ ├── DatasetControllerTest.java │ ├── LogoutOrExitControllerTest.java │ └── UserInfoControllerTest.java └── resources ├── META-INF ├── persistence.xml └── spring │ ├── database.properties.template │ ├── email.properties │ ├── handle.properties │ ├── salt.properties │ └── xml-validator.properties ├── conversion └── metadata-kernel-2.0_fix-schema-location │ ├── converted.xml │ ├── missing_no_namespace_schema_location.xml │ ├── wrong_no_namespace_schema_location.xml │ └── wrong_xsi_namespace.xml ├── datacite-metadata-sample-v2.0.xml ├── datacite-metadata-sample-v2.1.xml ├── datacite-metadata-sample-v3.1.xml ├── log4j.properties └── template └── TestMail /.github/move.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/.github/move.yml -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | src/test/resources/META-INF/spring/database.properties 2 | src/main/resources/META-INF/persistence.xml 3 | src/main/resources/META-INF/spring/*.properties 4 | src/main/resources/log4j.properties 5 | src/main/resources/log4j.xml 6 | src/main/webapp/WEB-INF/spring/*.properties 7 | *.log 8 | *.roo 9 | mds_*.zip 10 | target/ 11 | .classpath 12 | .project 13 | .settings 14 | .springBeans 15 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | DataCite Metadata Store 2 | Copyright 2010 DataCite 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). -------------------------------------------------------------------------------- /client/perl/bulk-minting-dummy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for I in `seq 1 $1`; do 3 | doi=10.5072/TEST_`date +%s-%N` 4 | echo `date` - $I/$1 - $doi 5 | ./mds-suite.pl -l doi post $doi 'http://example.com' 6 | done 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/perl/bulk-upload-dummy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | doi_xpath="//*[local-name() = 'identifier' and @identifierType='DOI']" 3 | number=$1 4 | shift 5 | for I in `seq 1 $number`; do 6 | doi=10.5072/TEST_`date +%s-%N` 7 | echo `date` - $I/$number - $doi 8 | for file in $@; do 9 | xmlstarlet ed -u "$doi_xpath" -v "$doi" $file | ./mds-suite.pl -l metadata put $doi 10 | done 11 | done 12 | 13 | 14 | -------------------------------------------------------------------------------- /client/python/delete_metadata.py: -------------------------------------------------------------------------------- 1 | import requests, sys 2 | 3 | #endpoint = 'https://mds.datacite.org/metadata' 4 | endpoint = 'https://mds.test.datacite.org/metadata' 5 | 6 | if (len(sys.argv) < 4): 7 | raise Exception('Please provide username, password and doi') 8 | 9 | username, password, doi = sys.argv[1:] 10 | 11 | response = requests.delete(endpoint + '/' + doi, 12 | auth = (username, password)) 13 | 14 | print str(response.status_code) + " " + response.text -------------------------------------------------------------------------------- /client/python/get_doi.py: -------------------------------------------------------------------------------- 1 | import requests, sys 2 | 3 | #endpoint = 'https://mds.datacite.org/doi' 4 | endpoint = 'https://mds.test.datacite.org/doi' 5 | 6 | if (len(sys.argv) < 4): 7 | raise Exception('Please provide username, password and doi') 8 | 9 | username, password, doi = sys.argv[1:] 10 | 11 | response = requests.get(endpoint + '/' + doi, 12 | auth = (username, password)) 13 | 14 | if (response.status_code != 200): 15 | print str(response.status_code) + " " + response.text 16 | else: 17 | print response.text 18 | -------------------------------------------------------------------------------- /client/python/get_metadata.py: -------------------------------------------------------------------------------- 1 | import requests, sys 2 | 3 | #endpoint = 'https://mds.datacite.org/metadata' 4 | endpoint = 'https://mds.test.datacite.org/metadata' 5 | 6 | if (len(sys.argv) < 4): 7 | raise Exception('Please provide username, password and doi') 8 | 9 | username, password, doi = sys.argv[1:] 10 | 11 | response = requests.get(endpoint + '/' + doi, 12 | auth = (username, password), 13 | headers = {'Accept':'application/xml'}) 14 | 15 | if (response.status_code != 200): 16 | print str(response.status_code) + " " + response.text 17 | else: 18 | print response.text 19 | -------------------------------------------------------------------------------- /client/python/post_doi.py: -------------------------------------------------------------------------------- 1 | import requests, sys, codecs 2 | 3 | #endpoint = 'https://mds.datacite.org/doi' 4 | endpoint = 'https://mds.test.datacite.org/doi' 5 | 6 | if (len(sys.argv) < 4): 7 | raise Exception('Please provide username, password, location of doi-url file') 8 | 9 | username, password, filename = sys.argv[1:] 10 | 11 | file = codecs.open(sys.argv[3], 'r', encoding='utf-8').read().strip() 12 | 13 | response = requests.post(endpoint, 14 | auth = (username, password), 15 | data = file.encode('utf-8'), 16 | headers = {'Content-Type':'text/plain;charset=UTF-8'}) 17 | 18 | print str(response.status_code) + " " + response.text -------------------------------------------------------------------------------- /client/python/post_metadata.py: -------------------------------------------------------------------------------- 1 | import requests, sys, codecs 2 | 3 | #endpoint = 'https://mds.datacite.org/metadata' 4 | endpoint = 'https://mds.test.datacite.org/metadata' 5 | 6 | if (len(sys.argv) < 4): 7 | raise Exception('Please provide username, password and location of metadata file') 8 | 9 | username, password, filename = sys.argv[1:] 10 | 11 | metadata = codecs.open(filename, 'r', encoding='utf-8').read() 12 | 13 | response = requests.post(endpoint, 14 | auth = (username, password), 15 | data = metadata.encode('utf-8'), 16 | headers = {'Content-Type':'application/xml;charset=UTF-8'}) 17 | 18 | print str(response.status_code) + " " + response.text 19 | -------------------------------------------------------------------------------- /client/sample-doi1.txt: -------------------------------------------------------------------------------- 1 | doi=10.5072/TEST-1 2 | url=http://www.bl.uk/datasets 3 | -------------------------------------------------------------------------------- /client/sample-doi2.txt: -------------------------------------------------------------------------------- 1 | doi=10.5072/TEST-2/StraßendgrößtenStädte 2 | url=http://www.google.de/#hl=de&source=hp&q=Stra%C3%9Fen+der+20+gr%C3%B6%C3%9Ften+St%C3%A4dte&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=3670b6c5c948a59c 3 | -------------------------------------------------------------------------------- /client/sample-doi3.txt: -------------------------------------------------------------------------------- 1 | doi=10.5072/TEST-3/παράδειγμα.δοκιμή/1 2 | url=http://παράδειγμα.δοκιμή 3 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/AllocatorOrDatacentre.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.domain; 2 | 3 | import java.util.Collection; 4 | import java.util.Set; 5 | 6 | public interface AllocatorOrDatacentre { 7 | 8 | AllocatorOrDatacentre merge(); 9 | 10 | void persist(); 11 | 12 | Boolean getIsActive(); 13 | 14 | String getRoleName(); 15 | 16 | String getSymbol(); 17 | 18 | String getContactName(); 19 | 20 | String getContactEmail(); 21 | 22 | void setContactEmail(String contactEmail); 23 | 24 | String getPassword(); 25 | 26 | Collection getExperiments(); 27 | 28 | void setPassword(String password); 29 | 30 | String getName(); 31 | 32 | void setName(String name); 33 | 34 | /** 35 | * calculate String to be used for magic auth key 36 | * 37 | * @return (unhashed) base part of the magic auth string 38 | */ 39 | String getBaseAuthString(); 40 | 41 | Set getPrefixes(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Allocator_Roo_Configurable.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import org.springframework.beans.factory.annotation.Configurable; 7 | 8 | privileged aspect Allocator_Roo_Configurable { 9 | 10 | declare @type: Allocator: @Configurable; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Allocator_Roo_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import java.lang.String; 7 | import javax.persistence.EntityManager; 8 | import javax.persistence.TypedQuery; 9 | import org.datacite.mds.domain.Allocator; 10 | 11 | privileged aspect Allocator_Roo_Finder { 12 | 13 | public static TypedQuery Allocator.findAllocatorsByNameLike(String name) { 14 | if (name == null || name.length() == 0) throw new IllegalArgumentException("The name argument is required"); 15 | name = name.replace('*', '%'); 16 | if (name.charAt(0) != '%') { 17 | name = "%" + name; 18 | } 19 | if (name.charAt(name.length() - 1) != '%') { 20 | name = name + "%"; 21 | } 22 | EntityManager em = Allocator.entityManager(); 23 | TypedQuery q = em.createQuery("SELECT o FROM Allocator AS o WHERE LOWER(o.name) LIKE LOWER(:name)", Allocator.class); 24 | q.setParameter("name", name); 25 | return q; 26 | } 27 | 28 | public static TypedQuery Allocator.findAllocatorsBySymbolEquals(String symbol) { 29 | if (symbol == null || symbol.length() == 0) throw new IllegalArgumentException("The symbol argument is required"); 30 | EntityManager em = Allocator.entityManager(); 31 | TypedQuery q = em.createQuery("SELECT o FROM Allocator AS o WHERE o.symbol = :symbol", Allocator.class); 32 | q.setParameter("symbol", symbol); 33 | return q; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Datacentre_Roo_Configurable.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import org.springframework.beans.factory.annotation.Configurable; 7 | 8 | privileged aspect Datacentre_Roo_Configurable { 9 | 10 | declare @type: Datacentre: @Configurable; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Datacentre_Roo_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import java.lang.String; 7 | import javax.persistence.EntityManager; 8 | import javax.persistence.TypedQuery; 9 | import org.datacite.mds.domain.Datacentre; 10 | 11 | privileged aspect Datacentre_Roo_Finder { 12 | 13 | public static TypedQuery Datacentre.findDatacentresByNameLike(String name) { 14 | if (name == null || name.length() == 0) throw new IllegalArgumentException("The name argument is required"); 15 | name = name.replace('*', '%'); 16 | if (name.charAt(0) != '%') { 17 | name = "%" + name; 18 | } 19 | if (name.charAt(name.length() - 1) != '%') { 20 | name = name + "%"; 21 | } 22 | EntityManager em = Datacentre.entityManager(); 23 | TypedQuery q = em.createQuery("SELECT o FROM Datacentre AS o WHERE LOWER(o.name) LIKE LOWER(:name)", Datacentre.class); 24 | q.setParameter("name", name); 25 | return q; 26 | } 27 | 28 | public static TypedQuery Datacentre.findDatacentresBySymbolEquals(String symbol) { 29 | if (symbol == null || symbol.length() == 0) throw new IllegalArgumentException("The symbol argument is required"); 30 | EntityManager em = Datacentre.entityManager(); 31 | TypedQuery q = em.createQuery("SELECT o FROM Datacentre AS o WHERE o.symbol = :symbol", Datacentre.class); 32 | q.setParameter("symbol", symbol); 33 | return q; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Dataset_Roo_Configurable.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import org.springframework.beans.factory.annotation.Configurable; 7 | 8 | privileged aspect Dataset_Roo_Configurable { 9 | 10 | declare @type: Dataset: @Configurable; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Dataset_Roo_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import java.lang.String; 7 | import javax.persistence.EntityManager; 8 | import javax.persistence.TypedQuery; 9 | import org.datacite.mds.domain.Dataset; 10 | 11 | privileged aspect Dataset_Roo_Finder { 12 | 13 | public static TypedQuery Dataset.findDatasetsByDoiEquals(String doi) { 14 | if (doi == null || doi.length() == 0) throw new IllegalArgumentException("The doi argument is required"); 15 | EntityManager em = Dataset.entityManager(); 16 | TypedQuery q = em.createQuery("SELECT o FROM Dataset AS o WHERE o.doi = :doi", Dataset.class); 17 | q.setParameter("doi", doi); 18 | return q; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Media_Roo_Configurable.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import org.springframework.beans.factory.annotation.Configurable; 7 | 8 | privileged aspect Media_Roo_Configurable { 9 | 10 | declare @type: Media: @Configurable; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Media_Roo_JavaBean.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import java.lang.String; 7 | import java.util.Date; 8 | import org.datacite.mds.domain.Dataset; 9 | 10 | privileged aspect Media_Roo_JavaBean { 11 | 12 | public Dataset Media.getDataset() { 13 | return this.dataset; 14 | } 15 | 16 | public void Media.setDataset(Dataset dataset) { 17 | this.dataset = dataset; 18 | } 19 | 20 | public String Media.getMediaType() { 21 | return this.mediaType; 22 | } 23 | 24 | public void Media.setMediaType(String mediaType) { 25 | this.mediaType = mediaType; 26 | } 27 | 28 | public String Media.getUrl() { 29 | return this.url; 30 | } 31 | 32 | public void Media.setUrl(String url) { 33 | this.url = url; 34 | } 35 | 36 | public Date Media.getCreated() { 37 | return this.created; 38 | } 39 | 40 | public void Media.setCreated(Date created) { 41 | this.created = created; 42 | } 43 | 44 | public Date Media.getUpdated() { 45 | return this.updated; 46 | } 47 | 48 | public void Media.setUpdated(Date updated) { 49 | this.updated = updated; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Metadata_Roo_Configurable.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import org.springframework.beans.factory.annotation.Configurable; 7 | 8 | privileged aspect Metadata_Roo_Configurable { 9 | 10 | declare @type: Metadata: @Configurable; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Metadata_Roo_JavaBean.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import java.lang.Integer; 7 | import java.util.Date; 8 | import javax.persistence.Query; 9 | import org.datacite.mds.domain.Dataset; 10 | import org.datacite.mds.service.SchemaService; 11 | 12 | privileged aspect Metadata_Roo_JavaBean { 13 | 14 | public SchemaService Metadata.getSchemaService() { 15 | return this.schemaService; 16 | } 17 | 18 | public void Metadata.setSchemaService(SchemaService schemaService) { 19 | this.schemaService = schemaService; 20 | } 21 | 22 | public byte[] Metadata.getXml() { 23 | return this.xml; 24 | } 25 | 26 | public Integer Metadata.getMetadataVersion() { 27 | return this.metadataVersion; 28 | } 29 | 30 | public void Metadata.setMetadataVersion(Integer metadataVersion) { 31 | this.metadataVersion = metadataVersion; 32 | } 33 | 34 | public Date Metadata.getCreated() { 35 | return this.created; 36 | } 37 | 38 | public void Metadata.setCreated(Date created) { 39 | this.created = created; 40 | } 41 | 42 | public Dataset Metadata.getDataset() { 43 | return this.dataset; 44 | } 45 | 46 | public void Metadata.setDataset(Dataset dataset) { 47 | this.dataset = dataset; 48 | } 49 | 50 | public Query Metadata.getMaxMetaVerQuery() { 51 | return this.maxMetaVerQuery; 52 | } 53 | 54 | public void Metadata.setMaxMetaVerQuery(Query maxMetaVerQuery) { 55 | this.maxMetaVerQuery = maxMetaVerQuery; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Prefix_Roo_Configurable.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import org.springframework.beans.factory.annotation.Configurable; 7 | 8 | privileged aspect Prefix_Roo_Configurable { 9 | 10 | declare @type: Prefix: @Configurable; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Prefix_Roo_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import java.lang.String; 7 | import javax.persistence.EntityManager; 8 | import javax.persistence.TypedQuery; 9 | import org.datacite.mds.domain.Prefix; 10 | 11 | privileged aspect Prefix_Roo_Finder { 12 | 13 | public static TypedQuery Prefix.findPrefixesByPrefixLike(String prefix) { 14 | if (prefix == null || prefix.length() == 0) throw new IllegalArgumentException("The prefix argument is required"); 15 | EntityManager em = Prefix.entityManager(); 16 | TypedQuery q = em.createQuery("SELECT o FROM Prefix AS o WHERE LOWER(o.prefix) LIKE LOWER(:prefix)", Prefix.class); 17 | q.setParameter("prefix", prefix); 18 | return q; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/domain/Prefix_Roo_JavaBean.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.domain; 5 | 6 | import java.lang.String; 7 | 8 | privileged aspect Prefix_Roo_JavaBean { 9 | 10 | public String Prefix.getPrefix() { 11 | return this.prefix; 12 | } 13 | 14 | public void Prefix.setPrefix(String prefix) { 15 | this.prefix = prefix; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/mail/MailMessage.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.mail; 2 | 3 | import java.io.IOException; 4 | import java.util.Arrays; 5 | 6 | import org.apache.commons.io.FileUtils; 7 | import org.datacite.mds.domain.AllocatorOrDatacentre; 8 | import org.springframework.core.io.Resource; 9 | import org.springframework.mail.SimpleMailMessage; 10 | import org.springframework.util.StringUtils; 11 | 12 | public class MailMessage extends SimpleMailMessage { 13 | 14 | AllocatorOrDatacentre user; 15 | 16 | public void loadTemplate(Resource resource) { 17 | String text; 18 | try { 19 | text = FileUtils.readFileToString(resource.getFile()); 20 | } catch (IOException e) { 21 | throw new RuntimeException(e); 22 | } 23 | loadTemplate(text); 24 | } 25 | 26 | public void loadTemplate(String template) { 27 | String[] split = template.split("\n", 2); 28 | setSubject(split[0]); 29 | setText(split[1]); 30 | } 31 | 32 | public String getTemplate() { 33 | return getSubject() + "\n" + getText(); 34 | } 35 | 36 | public void replacePlaceholder(String placeholder, String replacement) { 37 | String template = getTemplate(); 38 | template = StringUtils.replace(template, "%" + placeholder + "%", replacement); 39 | loadTemplate(template); 40 | } 41 | 42 | public AllocatorOrDatacentre getUser() { 43 | return user; 44 | } 45 | 46 | public void setUser(AllocatorOrDatacentre user) { 47 | this.user = user; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | if (user == null) { 53 | return Arrays.toString(getTo()) + ": " + getSubject(); 54 | } else { 55 | return user.getSymbol() + " (" + user.getContactName() + " <" 56 | + user.getContactEmail() + ">): " + getSubject(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/DoiService.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service; 2 | 3 | import javax.validation.ValidationException; 4 | 5 | import org.datacite.mds.domain.Dataset; 6 | import org.datacite.mds.web.api.NotFoundException; 7 | 8 | /** 9 | * An interface to create and update DOIs 10 | */ 11 | public interface DoiService { 12 | 13 | /** 14 | * Creates a new or use a existing Dataset object and mint or update DOI. 15 | * Checks if the following conditions are met: 16 | *
    17 | *
  1. A datacentre is logged in and active
  2. 18 | *
  3. DOI has prefix belonging to the Datacentre
  4. 19 | *
  5. URL is a valid URL
  6. 20 | *
  7. domain in URL is on Datacentre's allowed list
  8. 21 | *
22 | * 23 | * @param doi 24 | * handle to be created/updated 25 | * @param url 26 | * location to be resolved, if null or empty - no minting 27 | * @param testMode 28 | * if true, checks will be conducted but neither record in DB 29 | * will be created nor handle minted 30 | * @throws HandleException 31 | * exception from Handle Service 32 | * @throws SecurityException 33 | * when datacentre not logged in, not active or has exceeded quota 34 | * @throws ValidationException 35 | * when any of above conditions remaining not met 36 | */ 37 | Dataset createOrUpdate(String doi, String url, boolean testMode) throws HandleException, SecurityException, ValidationException; 38 | 39 | Dataset resolve(String doi) throws HandleException, NotFoundException, SecurityException; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/HandleException.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service; 2 | 3 | /** 4 | * Wrapper for exceptions from Handle Service 5 | */ 6 | public class HandleException extends Exception { 7 | 8 | private static final long serialVersionUID = 1L; 9 | 10 | public HandleException(String message, Throwable cause) { 11 | super(message, cause); 12 | } 13 | 14 | public HandleException(String message) { 15 | super(message); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/HandleService.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service; 2 | 3 | import org.datacite.mds.web.api.NotFoundException; 4 | 5 | /** 6 | * An interface to access Handle System 7 | */ 8 | public interface HandleService { 9 | 10 | /** 11 | * Resolve a DOI 12 | * @param doi name to be resolved 13 | * @return url of DOI 14 | * @throws NotFoundException if DOI does not exist or does not have a URL 15 | * @throws HandleException wraps exception from the server 16 | */ 17 | String resolve(String doi) throws HandleException, NotFoundException; 18 | 19 | /** 20 | * Mints a new DOI 21 | * @param doi name to be minted 22 | * @param url location to be resolved 23 | * @throws HandleException wraps exception from the server 24 | */ 25 | void create(String doi, String url) throws HandleException; 26 | 27 | /** 28 | * Updates an existing DOI 29 | * @param doi name to be updated 30 | * @param newUrl a new location to be resolved 31 | * @throws HandleException wraps exception from the server 32 | */ 33 | void update(String doi, String newUrl) throws HandleException; 34 | 35 | void ping() throws HandleException; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/MagicAuthStringService.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service; 2 | 3 | import java.util.Collection; 4 | 5 | import org.datacite.mds.domain.AllocatorOrDatacentre; 6 | 7 | public interface MagicAuthStringService { 8 | public Collection getValidAuthStrings(AllocatorOrDatacentre user); 9 | 10 | public String getCurrentAuthString(AllocatorOrDatacentre user); 11 | 12 | public boolean isValidAuthString(AllocatorOrDatacentre user, String auth); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/MailService.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | import org.datacite.mds.mail.MailMessage; 6 | 7 | public interface MailService { 8 | 9 | void send(MailMessage mail); 10 | 11 | Future sendAsync(MailMessage mail); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/PurgeTestPrefixService.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service; 2 | 3 | public interface PurgeTestPrefixService { 4 | void purgeAll(); 5 | void purgeOld(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/SchemaService.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service; 2 | 3 | import javax.validation.ValidationException; 4 | import javax.xml.validation.Validator; 5 | 6 | import org.xml.sax.SAXException; 7 | 8 | public interface SchemaService { 9 | 10 | String getNamespace(byte[] xml) throws ValidationException; 11 | 12 | String getSchemaLocation(byte[] xml) throws ValidationException; 13 | 14 | Validator getSchemaValidator(String schemaLocation) throws SAXException; 15 | 16 | String getDoi(byte[] xml); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/SecurityException.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service; 2 | 3 | /** 4 | * An exception representing lack of credentials or other 5 | * required attributes to complete a request e.g. quota 6 | */ 7 | public class SecurityException extends Exception { 8 | private static final long serialVersionUID = 1L; 9 | 10 | public SecurityException() { 11 | super(); 12 | } 13 | 14 | public SecurityException(String message) { 15 | super(message); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/impl/MailServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service.impl; 2 | 3 | import java.util.concurrent.Future; 4 | 5 | import org.apache.log4j.Logger; 6 | import org.datacite.mds.mail.MailMessage; 7 | import org.datacite.mds.service.MailService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.mail.MailException; 10 | import org.springframework.mail.MailSender; 11 | import org.springframework.scheduling.annotation.Async; 12 | import org.springframework.scheduling.annotation.AsyncResult; 13 | import org.springframework.stereotype.Service; 14 | 15 | @Service 16 | public class MailServiceImpl implements MailService { 17 | 18 | Logger log4j = Logger.getLogger(MailServiceImpl.class); 19 | 20 | @Autowired 21 | MailSender mailSender; 22 | 23 | public void send(MailMessage mail) { 24 | log4j.info("Sending mail: " + mail); 25 | try { 26 | mailSender.send(mail); 27 | } catch (MailException e) { 28 | log4j.warn(e.getMessage()); 29 | throw e; 30 | } 31 | } 32 | 33 | @Async 34 | public Future sendAsync(MailMessage mail) { 35 | send(mail); 36 | return new AsyncResult(null); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/impl/PasswordEncoderImpl.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service.impl; 2 | 3 | import org.apache.log4j.Logger; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.security.authentication.encoding.ShaPasswordEncoder; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class PasswordEncoderImpl extends ShaPasswordEncoder { 10 | 11 | Logger log4j = Logger.getLogger(PasswordEncoderImpl.class); 12 | 13 | @Value("${salt.password}") String salt; 14 | 15 | public PasswordEncoderImpl() { 16 | super(256); // SHA-256 17 | } 18 | 19 | @Override 20 | public String encodePassword(String rawPass, Object salt) { 21 | // use system-wide salt 22 | log4j.debug("encodePassword (salt=" + this.salt + ")"); 23 | return super.encodePassword(rawPass, this.salt); 24 | } 25 | 26 | @Override 27 | public boolean isPasswordValid(String encPass, String rawPass, Object salt) { 28 | // use system-wide salt 29 | return super.isPasswordValid(encPass, rawPass, this.salt); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/userdetails/AdminMasterUserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2010 DataCite 3 | * 4 | * All rights reserved. This program and the accompanying 5 | * materials are made available under the terms of the 6 | * Apache License, Version 2.0 which accompanies 7 | * this distribution, and is available at 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | *******************************************************************************/ 11 | 12 | package org.datacite.mds.service.userdetails; 13 | 14 | import org.datacite.mds.domain.Allocator; 15 | import org.datacite.mds.util.DomainUtils; 16 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 17 | 18 | /** 19 | * accept admin user as master user for all other accounts 20 | */ 21 | public class AdminMasterUserDetailsServiceImpl extends BaseMasterUserDetailsService { 22 | 23 | @Override 24 | public String getMasterUsername(String username) { 25 | Allocator admin = DomainUtils.getAdmin(); 26 | if (admin == null) { 27 | throw new UsernameNotFoundException("cannot find a admin user"); 28 | } 29 | String mastername = admin.getSymbol(); 30 | return mastername; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/service/userdetails/AllocatorMasterUserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2010 DataCite 3 | * 4 | * All rights reserved. This program and the accompanying 5 | * materials are made available under the terms of the 6 | * Apache License, Version 2.0 which accompanies 7 | * this distribution, and is available at 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | *******************************************************************************/ 11 | 12 | package org.datacite.mds.service.userdetails; 13 | 14 | import org.datacite.mds.util.Utils; 15 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 16 | 17 | /** 18 | * accept allocator of a datacentre as master user 19 | */ 20 | public class AllocatorMasterUserDetailsServiceImpl extends BaseMasterUserDetailsService { 21 | 22 | @Override 23 | public String getMasterUsername(String username) { 24 | String mastername = Utils.getAllocatorFromDatacentreSymbol(username); 25 | if (mastername == null) { 26 | throw new UsernameNotFoundException("cannot parse allocator symbol"); 27 | } 28 | return mastername; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/tools/AbstractTool.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.tools; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.support.AbstractApplicationContext; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Component 10 | public abstract class AbstractTool { 11 | 12 | private static final String APPLICATION_CONTEXT = "META-INF/spring/applicationContext.xml"; 13 | 14 | @Autowired 15 | private LocalContainerEntityManagerFactoryBean emFactory; 16 | 17 | protected void disableValidation() { 18 | emFactory.getJpaPropertyMap().put("javax.persistence.validation.mode", "ddl"); 19 | emFactory.afterPropertiesSet(); 20 | } 21 | 22 | @SuppressWarnings("unchecked") 23 | public static final void initAndRun(String[] args) { 24 | AbstractApplicationContext context = null; 25 | try { 26 | context = new ClassPathXmlApplicationContext(APPLICATION_CONTEXT); 27 | String callingClassName = Thread.currentThread().getStackTrace()[2].getClassName(); 28 | Class callingClass = (Class) Class.forName(callingClassName); 29 | AbstractTool tool = context.getBean(callingClass); 30 | tool.run(args); 31 | } catch (Exception e) { 32 | e.printStackTrace(); 33 | } finally { 34 | if (context != null) 35 | context.close(); 36 | } 37 | } 38 | 39 | public abstract void run(String[] args) throws Exception; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/tools/conversion/MetadataKernel20FixSchemaLocation.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.tools.conversion; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | import org.datacite.mds.domain.Metadata; 5 | import org.datacite.mds.service.SchemaService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Component 10 | public class MetadataKernel20FixSchemaLocation extends BaseMetadataConvertor { 11 | 12 | private static final String SCHEMA_LOCATION = "http://schema.datacite.org/meta/kernel-2.0/metadata.xsd"; 13 | 14 | @Autowired 15 | SchemaService schemaService; 16 | 17 | public MetadataKernel20FixSchemaLocation() { 18 | super("conversion/metadata-kernel-2.0_fix-schema-location.xslt", null); 19 | } 20 | 21 | @Override 22 | public boolean needsConversion(Metadata metadata) { 23 | if (StringUtils.isNotEmpty(metadata.getNamespace())) 24 | return false; 25 | 26 | byte[] xml = metadata.getXml(); 27 | String schemaLocation; 28 | try { 29 | schemaLocation = schemaService.getSchemaLocation(xml); 30 | return ! SCHEMA_LOCATION.equals(schemaLocation); 31 | } catch (Exception e) { 32 | return true; 33 | } 34 | } 35 | 36 | public static void main(String[] args) { 37 | initAndRun(args); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/util/Constants.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.util; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collection; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class Constants { 12 | public static final Collection EXPERIMENTS_AVAILABLE = Arrays.asList(); 13 | 14 | public static String TEST_PREFIX; 15 | 16 | /** 17 | * Hack to inject static variable needed by some static methods (finders, 18 | * counts, etc.) in our domain classes 19 | */ 20 | @Value("${handle.testPrefix}") 21 | @Autowired(required = true) 22 | public void setTestPrefix(String testPrefix) { 23 | TEST_PREFIX = testPrefix; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/util/DomainUtils.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.util; 2 | 3 | import java.util.SortedSet; 4 | import java.util.TreeSet; 5 | 6 | import org.datacite.mds.domain.Allocator; 7 | import org.datacite.mds.domain.AllocatorOrDatacentre; 8 | import org.datacite.mds.domain.Datacentre; 9 | 10 | public class DomainUtils { 11 | 12 | /** 13 | * @return joined list of allocator and datacentre symbols 14 | */ 15 | public static SortedSet getAllSymbols() { 16 | SortedSet symbols = new TreeSet(); 17 | for (Datacentre datacentre : Datacentre.findAllDatacentres()) { 18 | symbols.add(datacentre.getSymbol()); 19 | } 20 | for (Allocator allocator : Allocator.findAllAllocators()) { 21 | symbols.add(allocator.getSymbol()); 22 | } 23 | return symbols; 24 | } 25 | 26 | public static AllocatorOrDatacentre findAllocatorOrDatacentreBySymbol(String symbol) { 27 | AllocatorOrDatacentre user = Allocator.findAllocatorBySymbol(symbol); 28 | if (user == null) { 29 | user = Datacentre.findDatacentreBySymbol(symbol); 30 | } 31 | return user; 32 | } 33 | 34 | public static Allocator getAdmin() { 35 | for (Allocator allocator : Allocator.findAllAllocators()) { 36 | if (allocator.getRoleName().equals("ROLE_ADMIN")) { 37 | return allocator; 38 | } 39 | } 40 | return null; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/util/FilterPredicates.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.util; 2 | 3 | import org.apache.commons.collections.Predicate; 4 | import org.datacite.mds.domain.AllocatorOrDatacentre; 5 | import org.datacite.mds.domain.Prefix; 6 | 7 | public class FilterPredicates { 8 | 9 | public static Predicate getAllocatorOrDatacentreContainsPrefixPredicate(final Prefix prefix) { 10 | return new Predicate() { 11 | @Override 12 | public boolean evaluate(Object object) { 13 | AllocatorOrDatacentre user = (AllocatorOrDatacentre) object; 14 | return user.getPrefixes().contains(prefix); 15 | } 16 | }; 17 | } 18 | 19 | public static Predicate getAllocatorOrDatacentreIsInferiorOfPredicate(final AllocatorOrDatacentre superior) { 20 | return new Predicate() { 21 | @Override 22 | public boolean evaluate(Object object) { 23 | AllocatorOrDatacentre inferior = (AllocatorOrDatacentre) object; 24 | return SecurityUtils.isUserSuperiorTo(superior, inferior); 25 | } 26 | }; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/ValidationHelper.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import javax.validation.ConstraintViolation; 7 | import javax.validation.ConstraintViolationException; 8 | import javax.validation.Validator; 9 | 10 | import org.datacite.mds.util.ValidationUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | import org.springframework.validation.BindingResult; 14 | 15 | @Component 16 | public class ValidationHelper { 17 | 18 | @Autowired 19 | Validator validator; 20 | 21 | public void validate(Object... objects) throws ConstraintViolationException { 22 | Set> violations = new HashSet>(); 23 | for (Object object : objects) 24 | violations.addAll(validator.validate(object)); 25 | 26 | if (!violations.isEmpty()) { 27 | Set> castedViolations = new HashSet>(violations); 28 | throw new ConstraintViolationException(castedViolations); 29 | } 30 | } 31 | 32 | public void validateTo(BindingResult result, Object... objects) { 33 | try { 34 | validate(objects); 35 | } catch (ConstraintViolationException ex) { 36 | ValidationUtils.constraintViolationToBindingResult(ex, result); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/Doi.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | import org.datacite.mds.validation.constraints.impl.DoiOnCreateOnlyValidator; 13 | import org.datacite.mds.validation.constraints.impl.DoiValidator; 14 | 15 | /** 16 | * This annotation is used for a String containing a DOI. It checks if the DOI 17 | * is well-formed. Null is a valid DOI (use @NotNull annotation if you don't 18 | * want this). 19 | * 20 | * On type level of dataset class it checks the contained doi field only on 21 | * create and not update. 22 | */ 23 | @Documented 24 | @Constraint(validatedBy = {DoiValidator.class, DoiOnCreateOnlyValidator.class}) 25 | @Target( { ElementType.FIELD, ElementType.TYPE, ElementType.ANNOTATION_TYPE }) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface Doi { 28 | String message() default "{org.datacite.mds.validation.constraints.Doi.message}"; 29 | 30 | Class[] groups() default {}; 31 | 32 | Class[] payload() default {}; 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/DoiPrefix.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | import javax.validation.constraints.Pattern; 12 | import javax.validation.constraints.Size; 13 | 14 | /** 15 | * This annotation is used for a String containing a DOI prefix (e.g. 16 | * "10.5072"). It checks if the DOI is well-formed. 17 | */ 18 | @Documented 19 | @Constraint(validatedBy = {}) 20 | @Size(max = 80) 21 | @Pattern(regexp = "10\\.(\\d)+", message = "{org.datacite.mds.validation.constraints.DoiPrefix.message}") 22 | @Target( { ElementType.FIELD, ElementType.ANNOTATION_TYPE }) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | public @interface DoiPrefix { 25 | String message() default ""; 26 | 27 | Class[] groups() default {}; 28 | 29 | Class[] payload() default {}; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/Email.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | import javax.validation.ReportAsSingleViolation; 12 | 13 | import org.datacite.mds.validation.constraints.impl.EmailValidator; 14 | 15 | /** 16 | * This annotation is used for email addresses. It checks if the email address 17 | * is well-formed. 18 | */ 19 | @Documented 20 | @Constraint(validatedBy = {EmailValidator.class}) 21 | @ReportAsSingleViolation 22 | @Target( { ElementType.FIELD, ElementType.ANNOTATION_TYPE }) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | public @interface Email { 25 | String message() default "{org.hibernate.validator.constraints.Email.message}"; 26 | 27 | Class[] groups() default {}; 28 | 29 | Class[] payload() default {}; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/ListOfDomains.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | import org.datacite.mds.validation.constraints.impl.ListOfDomainsValidator; 13 | 14 | /** 15 | * This annotation is used for a String containing a comma separated list of 16 | * domains (e.g. "datacite.org,datacite.org.uk") 17 | */ 18 | @Documented 19 | @Constraint(validatedBy = ListOfDomainsValidator.class) 20 | @Target( { ElementType.FIELD, ElementType.ANNOTATION_TYPE }) 21 | @Retention(RetentionPolicy.RUNTIME) 22 | public @interface ListOfDomains { 23 | String message() default "{org.datacite.mds.validation.constraints.ListOfDomains.message}"; 24 | 25 | String wildCard() default "*"; 26 | 27 | Class[] groups() default {}; 28 | 29 | Class[] payload() default {}; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/MatchDoi.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | import org.datacite.mds.validation.constraints.impl.MatchDoiValidator; 13 | 14 | /** 15 | * This annotation has to be placed on type level and is only applicable for a 16 | * Metadata. 17 | * 18 | * It checks if DOI parsed from XML matches DOI from assigned dataset 19 | */ 20 | @Documented 21 | @Constraint(validatedBy = MatchDoiValidator.class) 22 | @Target( { ElementType.TYPE, ElementType.ANNOTATION_TYPE }) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | public @interface MatchDoi { 25 | String message() default "{org.datacite.mds.validation.constraints.MatchDoi.message}"; 26 | 27 | Class[] groups() default {}; 28 | 29 | Class[] payload() default {}; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/MatchDoiPrefix.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | import org.datacite.mds.validation.constraints.impl.MatchDoiPrefixValidator; 13 | 14 | /** 15 | * This annotation has to be placed on type level and is only applicable for a 16 | * Dataset. 17 | * 18 | * It checks if prefix of the specified DOI is in the list of the allowed 19 | * prefixes of the datacentre. 20 | * 21 | * @see org.datacite.mds.domain.Dataset 22 | */ 23 | @Documented 24 | @Constraint(validatedBy = MatchDoiPrefixValidator.class) 25 | @Target( { ElementType.TYPE, ElementType.ANNOTATION_TYPE }) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface MatchDoiPrefix { 28 | String message() default "{org.datacite.mds.validation.constraints.MatchDoiPrefix.message}"; 29 | 30 | Class[] groups() default {}; 31 | 32 | Class[] payload() default {}; 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/MatchDomain.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | import org.datacite.mds.validation.constraints.impl.MatchDomainValidatorForDataset; 13 | import org.datacite.mds.validation.constraints.impl.MatchDomainValidatorForMedia; 14 | 15 | /** 16 | * This annotation has to be placed on type level and is applicable for Dataset 17 | * and Media. 18 | * 19 | * It checks if hostname of the specified URL is in the list of the allowed 20 | * domains of the datacentre. 21 | * 22 | * @see org.datacite.mds.domain.Dataset 23 | * @see org.datacite.mds.domain.Media 24 | */ 25 | @Documented 26 | @Constraint(validatedBy = { MatchDomainValidatorForDataset.class, MatchDomainValidatorForMedia.class }) 27 | @Target( { ElementType.TYPE, ElementType.ANNOTATION_TYPE }) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | public @interface MatchDomain { 30 | String message() default "{org.datacite.mds.validation.constraints.MatchDomain.message}"; 31 | 32 | String wildCard() default "*"; 33 | 34 | Class[] groups() default {}; 35 | 36 | Class[] payload() default {}; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/MatchPrefixes.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | import org.datacite.mds.validation.constraints.impl.MatchPrefixesValidator; 13 | 14 | /** 15 | * This annotation has to be placed on type level and is only applicable for a 16 | * Datacentre. 17 | * 18 | * It checks if list of prefixes is a subset of allocator's prefixes 19 | */ 20 | @Documented 21 | @Constraint(validatedBy = MatchPrefixesValidator.class) 22 | @Target( { ElementType.TYPE, ElementType.ANNOTATION_TYPE }) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | public @interface MatchPrefixes { 25 | String message() default "{org.datacite.mds.validation.constraints.MatchPrefixes.message}"; 26 | 27 | Class[] groups() default {}; 28 | 29 | Class[] payload() default {}; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/MatchSymbolPrefix.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | 12 | import org.datacite.mds.validation.constraints.impl.MatchSymbolPrefixValidator; 13 | 14 | /** 15 | * This annotation has to be placed on type level and is only applicable for a 16 | * Datacentre. 17 | * 18 | * It checks if prefix of the specified symbol begins with the symbol of the 19 | * assigned allocator 20 | * 21 | */ 22 | 23 | @Documented 24 | @Constraint(validatedBy = MatchSymbolPrefixValidator.class) 25 | @Target( { ElementType.TYPE, ElementType.ANNOTATION_TYPE }) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface MatchSymbolPrefix { 28 | String message() default "{org.datacite.mds.validation.constraints.MatchSymbolPrefix.message}"; 29 | 30 | Class[] groups() default {}; 31 | 32 | Class[] payload() default {}; 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/MediaType.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | import javax.validation.constraints.Size; 12 | 13 | import org.datacite.mds.validation.constraints.impl.MediaTypeValidator; 14 | 15 | /** 16 | * This annotation is used for a String containing a Internet Media Type (aka 17 | * MIME type). It checks if the media type is well-formed. 18 | */ 19 | @Documented 20 | @Constraint(validatedBy = MediaTypeValidator.class) 21 | @Size(max = 80) 22 | @Target( { ElementType.FIELD, ElementType.ANNOTATION_TYPE }) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | public @interface MediaType { 25 | String message() default "{org.datacite.mds.validation.constraints.MediaType.message}"; 26 | 27 | Class[] groups() default {}; 28 | 29 | Class[] payload() default {}; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/URL.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | import javax.validation.constraints.Pattern; 12 | import javax.validation.constraints.Size; 13 | 14 | /** 15 | * This annotation is used for a String containing a URL. It checks if the URL 16 | * is well-formed and have one of http, https and ftp as protocol. Null is a 17 | * valid URL (use @NotNull annotation if you don't want this). 18 | */ 19 | @Documented 20 | @Size(max = 2048) 21 | @org.hibernate.validator.constraints.URL 22 | @Pattern(regexp = "(https?|ftp)://.*|\\s*", message = "{org.datacite.mds.validation.constraints.URL.protocol.message}") 23 | @Target( { ElementType.FIELD, ElementType.ANNOTATION_TYPE }) 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @Constraint(validatedBy = {}) 26 | public @interface URL { 27 | String message() default ""; 28 | 29 | Class[] groups() default {}; 30 | 31 | Class[] payload() default {}; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/ValidXML.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.validation.Constraint; 10 | import javax.validation.Payload; 11 | import javax.validation.ReportAsSingleViolation; 12 | 13 | import org.datacite.mds.validation.constraints.impl.ValidXMLValidator; 14 | 15 | /** 16 | * This annotation is used for XML content (byte[]) that should be validate to a 17 | * xml schema. 18 | * 19 | * Example usage: 20 | * 21 | *
22 |  * @ValidXML
23 |  * private byte[] xml;
24 |  * 
25 | */ 26 | @Documented 27 | @Constraint(validatedBy = ValidXMLValidator.class) 28 | @Target( { ElementType.FIELD, ElementType.ANNOTATION_TYPE }) 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @ReportAsSingleViolation 31 | public @interface ValidXML { 32 | 33 | String message() default "{org.datacite.mds.validation.constraints.ValidXML.message}"; 34 | 35 | Class[] groups() default {}; 36 | 37 | Class[] payload() default {}; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/impl/DoiOnCreateOnlyValidator.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints.impl; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import org.datacite.mds.domain.Dataset; 7 | import org.datacite.mds.validation.constraints.Doi; 8 | 9 | public class DoiOnCreateOnlyValidator implements ConstraintValidator { 10 | 11 | DoiValidator doiValidator; 12 | 13 | public void initialize(Doi constraintAnnotation) { 14 | doiValidator = new DoiValidator(); 15 | doiValidator.initialize(constraintAnnotation); 16 | doiValidator.setNodeForMessage("doi"); 17 | } 18 | 19 | public boolean isValid(Dataset dataset, ConstraintValidatorContext context) { 20 | boolean exists = dataset.getId() != null; 21 | return exists || doiValidator.isValid(dataset.getDoi(), context); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/impl/EmailValidator.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints.impl; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import org.datacite.mds.validation.constraints.Email; 7 | 8 | public class EmailValidator implements ConstraintValidator { 9 | 10 | public void initialize(Email constraintAnnotation) { 11 | // nothing to initialize 12 | } 13 | 14 | public boolean isValid(String email, ConstraintValidatorContext context) { 15 | return email == null || org.apache.commons.validator.EmailValidator.getInstance().isValid(email); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/impl/ListOfDomainsValidator.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints.impl; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import org.apache.commons.lang.StringUtils; 7 | import org.datacite.mds.util.Utils; 8 | import org.datacite.mds.util.ValidationUtils; 9 | import org.datacite.mds.validation.constraints.ListOfDomains; 10 | 11 | public class ListOfDomainsValidator implements ConstraintValidator { 12 | 13 | String wildCard; 14 | 15 | public void initialize(ListOfDomains constraintAnnotation) { 16 | this.wildCard = constraintAnnotation.wildCard(); 17 | } 18 | 19 | public boolean isValid(String domains, ConstraintValidatorContext context) { 20 | for (String domain : Utils.csvToList(domains)) { 21 | boolean containsWildcard = StringUtils.contains(domain, wildCard); 22 | boolean isHostName = ValidationUtils.isHostname(domain); 23 | if (! containsWildcard && ! isHostName) { 24 | return false; 25 | } 26 | } 27 | return true; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/impl/MatchDoiValidator.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints.impl; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import org.apache.commons.lang.StringUtils; 7 | import org.datacite.mds.domain.Metadata; 8 | import org.datacite.mds.service.SchemaService; 9 | import org.datacite.mds.util.Utils; 10 | import org.datacite.mds.util.ValidationUtils; 11 | import org.datacite.mds.validation.constraints.MatchDoi; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Component; 14 | 15 | @Component 16 | public class MatchDoiValidator implements ConstraintValidator { 17 | String defaultMessage; 18 | 19 | @Autowired 20 | SchemaService schemaService; 21 | 22 | public void initialize(MatchDoi constraintAnnotation) { 23 | defaultMessage = constraintAnnotation.message(); 24 | } 25 | 26 | @Override 27 | public boolean isValid(Metadata metadata, ConstraintValidatorContext context) { 28 | ValidationUtils.addConstraintViolation(context, defaultMessage, "xml"); 29 | String doiFromDataset = metadata.getDataset().getDoi(); 30 | String doiFromXml = schemaService.getDoi(metadata.getXml()); 31 | doiFromXml = Utils.normalizeDoi(doiFromXml); 32 | boolean isValid = StringUtils.equals(doiFromDataset, doiFromXml); 33 | return isValid; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/impl/MatchDomainValidatorForDataset.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints.impl; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import org.datacite.mds.domain.Datacentre; 7 | import org.datacite.mds.domain.Dataset; 8 | import org.datacite.mds.validation.constraints.MatchDomain; 9 | import org.springframework.beans.factory.annotation.Configurable; 10 | 11 | @Configurable 12 | public class MatchDomainValidatorForDataset extends MatchDomainValidator implements ConstraintValidator { 13 | public boolean isValid(Dataset dataset, ConstraintValidatorContext context) { 14 | String url = dataset.getUrl(); 15 | Datacentre datacentre = dataset.getDatacentre(); 16 | return isValid(url, datacentre, context); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/impl/MatchDomainValidatorForMedia.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints.impl; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import org.datacite.mds.domain.Datacentre; 7 | import org.datacite.mds.domain.Media; 8 | import org.datacite.mds.validation.constraints.MatchDomain; 9 | import org.springframework.beans.factory.annotation.Configurable; 10 | 11 | @Configurable 12 | public class MatchDomainValidatorForMedia extends MatchDomainValidator implements ConstraintValidator { 13 | public boolean isValid(Media media, ConstraintValidatorContext context) { 14 | String url = media.getUrl(); 15 | Datacentre datacentre = media.getDataset().getDatacentre(); 16 | return isValid(url, datacentre, context); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/impl/MatchPrefixesValidator.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints.impl; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import javax.validation.ConstraintValidator; 7 | import javax.validation.ConstraintValidatorContext; 8 | 9 | import org.datacite.mds.domain.Datacentre; 10 | import org.datacite.mds.domain.Prefix; 11 | import org.datacite.mds.util.ValidationUtils; 12 | import org.datacite.mds.validation.constraints.MatchPrefixes; 13 | 14 | public class MatchPrefixesValidator implements ConstraintValidator { 15 | String defaultMessage; 16 | 17 | public void initialize(MatchPrefixes constraintAnnotation) { 18 | defaultMessage = constraintAnnotation.message(); 19 | } 20 | 21 | public boolean isValid(Datacentre datacentre, ConstraintValidatorContext context) { 22 | Set allowedPrefixes = emptySetIfNull(datacentre.getAllocator().getPrefixes()); 23 | Set prefixes = emptySetIfNull(datacentre.getPrefixes()); 24 | boolean isValid = allowedPrefixes.containsAll(prefixes); 25 | ValidationUtils.addConstraintViolation(context, defaultMessage, "prefixes"); 26 | return isValid; 27 | } 28 | 29 | private Set emptySetIfNull(Set set) { 30 | return set == null ? new HashSet() : set; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/validation/constraints/impl/MatchSymbolPrefixValidator.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints.impl; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import org.datacite.mds.domain.Datacentre; 7 | import org.datacite.mds.util.ValidationUtils; 8 | import org.datacite.mds.validation.constraints.MatchSymbolPrefix; 9 | 10 | public class MatchSymbolPrefixValidator implements ConstraintValidator { 11 | String defaultMessage; 12 | 13 | public void initialize(MatchSymbolPrefix constraintAnnotation) { 14 | defaultMessage = constraintAnnotation.message(); 15 | } 16 | 17 | public boolean isValid(Datacentre datacentre, ConstraintValidatorContext context) { 18 | String datacentreSymbol = datacentre.getSymbol(); 19 | String allocatorSymbol = datacentre.getAllocator().getSymbol(); 20 | 21 | ValidationUtils.addConstraintViolation(context, defaultMessage, "symbol"); 22 | 23 | return datacentreSymbol.startsWith(allocatorSymbol + "."); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/BrowserCachingInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.http.HttpServletRequest; 5 | import javax.servlet.http.HttpServletResponse; 6 | 7 | import org.springframework.web.servlet.mvc.WebContentInterceptor; 8 | 9 | public class BrowserCachingInterceptor extends WebContentInterceptor { 10 | 11 | @Override 12 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 13 | throws ServletException { 14 | // fix to stop tomcat from adding "Pragma: No-Cache" for CONFIDENTIAL resources (HTTPS) 15 | response.setHeader("Pragma", ""); 16 | return super.preHandle(request, response, handler); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/ApiAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import org.springframework.security.access.AccessDeniedException; 10 | import org.springframework.security.web.access.AccessDeniedHandlerImpl; 11 | 12 | /** 13 | * This class is a simple wrapper for AccessDeniedHandlerImpl to use our 14 | * ApiResponseWrapper and therefore put the exception message sole into the 15 | * response body 16 | * 17 | * @see ApiResponseWrapper 18 | */ 19 | public class ApiAccessDeniedHandler extends AccessDeniedHandlerImpl { 20 | 21 | @Override 22 | public void handle(HttpServletRequest request, HttpServletResponse response, 23 | AccessDeniedException accessDeniedException) throws IOException, ServletException { 24 | HttpServletResponse wrappedResponse = new ApiResponseWrapper(response); 25 | super.handle(request, wrappedResponse, accessDeniedException); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/ApiBasicAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import org.springframework.security.core.AuthenticationException; 10 | import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; 11 | 12 | public class ApiBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { 13 | 14 | @Override 15 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) 16 | throws IOException, ServletException { 17 | HttpServletResponse wrappedResponse = new ApiResponseWrapper(response); 18 | super.commence(request, wrappedResponse, authException); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/ApiController.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api; 2 | 3 | /** 4 | * Empty Interface to 'mark' all our API controllers 5 | */ 6 | public interface ApiController { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/ApiResponseWrapper.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.http.HttpServletResponse; 6 | import javax.servlet.http.HttpServletResponseWrapper; 7 | 8 | import org.apache.commons.lang.StringUtils; 9 | import org.apache.log4j.Logger; 10 | 11 | /** 12 | * This is a wrapper around HttpServletResponse. By default the sendError 13 | * methods result in a html page generated by tomcat. This wrapper prints only 14 | * the error message to the response body (and sets the given response code) 15 | */ 16 | public class ApiResponseWrapper extends HttpServletResponseWrapper { 17 | 18 | static final String NEW_LINE = System.getProperty("line.separator"); 19 | 20 | Logger log = Logger.getLogger(ApiResponseWrapper.class); 21 | 22 | public ApiResponseWrapper(HttpServletResponse response) { 23 | super(response); 24 | } 25 | 26 | @Override 27 | public void sendError(int sc, String msg) throws IOException { 28 | msg = StringUtils.replace(msg, NEW_LINE, " - "); 29 | log.debug("sendError " + sc + ": " + msg); 30 | setStatus(sc); 31 | getWriter().print(msg); 32 | } 33 | 34 | @Override 35 | public void sendError(int sc) throws IOException { 36 | log.debug("sendError " + sc); 37 | sendError(sc, ""); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/ApiUtils.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api; 2 | 3 | import org.apache.commons.lang.BooleanUtils; 4 | 5 | public class ApiUtils { 6 | public static String makeResponseMessage(String message, Boolean testMode) { 7 | if (BooleanUtils.isTrue(testMode)) 8 | message += " (only test mode!)"; 9 | return message; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/DeletedException.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api; 2 | 3 | public class DeletedException extends Exception { 4 | 5 | public DeletedException() { 6 | super(); 7 | } 8 | 9 | public DeletedException(String message) { 10 | super(message); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api; 2 | 3 | public class NotFoundException extends Exception { 4 | 5 | public NotFoundException() { 6 | super(); 7 | } 8 | 9 | public NotFoundException(String message) { 10 | super(message); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/NullSecurityContextRepository.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.springframework.security.core.context.SecurityContext; 7 | import org.springframework.security.core.context.SecurityContextHolder; 8 | import org.springframework.security.web.context.HttpRequestResponseHolder; 9 | import org.springframework.security.web.context.SecurityContextRepository; 10 | 11 | /** 12 | * @author Luke Taylor 13 | * @since 3.1 14 | */ 15 | public final class NullSecurityContextRepository implements SecurityContextRepository { 16 | 17 | public boolean containsContext(HttpServletRequest request) { 18 | return false; 19 | } 20 | 21 | public SecurityContext loadContext(HttpRequestResponseHolder requestResponseHolder) { 22 | return SecurityContextHolder.createEmptyContext(); 23 | } 24 | 25 | public void saveContext(SecurityContext context, HttpServletRequest request, HttpServletResponse response) { 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/api/controller/StatusController.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.api.controller; 2 | 3 | import javax.persistence.EntityManager; 4 | import javax.persistence.PersistenceContext; 5 | 6 | import org.datacite.mds.service.HandleException; 7 | import org.datacite.mds.service.HandleService; 8 | import org.datacite.mds.web.api.ApiController; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | 15 | @Controller 16 | public class StatusController implements ApiController { 17 | 18 | @PersistenceContext 19 | EntityManager em; 20 | 21 | @Autowired 22 | HandleService handleService; 23 | 24 | @RequestMapping(value = "/status") 25 | public ResponseEntity status() throws HandleException { 26 | checkDatabaseConnection(); 27 | handleService.ping(); 28 | return new ResponseEntity("OK", null, HttpStatus.OK); 29 | } 30 | 31 | private void checkDatabaseConnection() { 32 | em.createNativeQuery("SELECT 1").getSingleResult(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/SwitchUserEmptyDetailsChecker.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui; 2 | 3 | import org.springframework.security.core.userdetails.UserDetails; 4 | import org.springframework.security.core.userdetails.UserDetailsChecker; 5 | 6 | public class SwitchUserEmptyDetailsChecker implements UserDetailsChecker { 7 | 8 | @Override 9 | public void check(UserDetails toCheck) { 10 | // empty to allow to switch to every user regardless of user status 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/SwitchUserFilter.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.apache.log4j.Logger; 6 | import org.datacite.mds.domain.AllocatorOrDatacentre; 7 | import org.datacite.mds.service.SecurityException; 8 | import org.datacite.mds.util.DomainUtils; 9 | import org.datacite.mds.util.SecurityUtils; 10 | import org.springframework.security.authentication.AuthenticationServiceException; 11 | import org.springframework.security.core.Authentication; 12 | import org.springframework.security.core.AuthenticationException; 13 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 14 | 15 | public class SwitchUserFilter extends org.springframework.security.web.authentication.switchuser.SwitchUserFilter { 16 | 17 | private static Logger log = Logger.getLogger(SwitchUserFilter.class); 18 | 19 | @Override 20 | protected Authentication attemptSwitchUser(HttpServletRequest request) throws AuthenticationException { 21 | String targetUsername = request.getParameter(SPRING_SECURITY_SWITCH_USERNAME_KEY); 22 | AllocatorOrDatacentre targetUser = DomainUtils.findAllocatorOrDatacentreBySymbol(targetUsername); 23 | if (targetUser == null) 24 | throw new UsernameNotFoundException("user '" + targetUsername + "' not found"); 25 | 26 | try { 27 | AllocatorOrDatacentre currentUser = SecurityUtils.getCurrentAllocatorOrDatacentre(); 28 | if (!SecurityUtils.isUserSuperiorTo(currentUser, targetUser)) 29 | throw new AuthenticationServiceException("You are not allowed to switch to the specified user"); 30 | } catch (SecurityException e) { 31 | throw new UsernameNotFoundException("user not found", e); 32 | } 33 | 34 | return super.attemptSwitchUser(request); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/UiController.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui; 2 | 3 | /** 4 | * Empty Interface to 'mark' all our UI controllers 5 | */ 6 | public interface UiController { 7 | public static int LIST_DEFAULT_SIZE = 30; 8 | public static int LIST_MAX_SIZE = 100; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/UiUtils.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui; 2 | 3 | import java.util.Collection; 4 | import java.util.LinkedList; 5 | import java.util.TreeSet; 6 | 7 | import javax.servlet.http.HttpSession; 8 | 9 | import org.datacite.mds.domain.AllocatorOrDatacentre; 10 | import org.datacite.mds.util.SecurityUtils; 11 | import org.datacite.mds.util.Utils; 12 | import org.springframework.security.core.Authentication; 13 | 14 | public class UiUtils { 15 | 16 | public static void refreshSymbolsForSwitchUser(HttpSession session) { 17 | Collection users = SecurityUtils.getDirectInferiorsOfCurrentAllocator(); 18 | Collection symbols = new TreeSet(); 19 | symbols.addAll(Utils.toSymbols(users)); 20 | 21 | if (!symbols.isEmpty()) 22 | symbols.add(""); // add empty string to disable symbol default selection 23 | 24 | session.setAttribute("symbols", symbols); 25 | } 26 | 27 | public static void setLoginPathwaySessionAttribute(HttpSession session) { 28 | LinkedList pathway = new LinkedList(); 29 | 30 | Authentication auth = SecurityUtils.getCurrentAuthentication(); 31 | while(auth != null) { 32 | pathway.addFirst(auth.getName()); 33 | auth = SecurityUtils.getOriginalUser(auth); 34 | } 35 | 36 | session.setAttribute("login_pathway", pathway); 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/UsernamePasswordAuthenticationRequireCookiesFilter.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import javax.servlet.http.HttpSession; 6 | 7 | import org.springframework.security.authentication.AuthenticationServiceException; 8 | import org.springframework.security.core.Authentication; 9 | import org.springframework.security.core.AuthenticationException; 10 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 11 | 12 | public class UsernamePasswordAuthenticationRequireCookiesFilter extends UsernamePasswordAuthenticationFilter { 13 | 14 | @Override 15 | public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) 16 | throws AuthenticationException { 17 | HttpSession session = request.getSession(false); 18 | if (session == null) 19 | throw new AuthenticationServiceException("Cannot create session. Cookies disabled?"); 20 | return super.attemptAuthentication(request, response); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/AllocatorController_Roo_Controller.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.io.UnsupportedEncodingException; 7 | import java.lang.Integer; 8 | import java.lang.String; 9 | import javax.servlet.http.HttpServletRequest; 10 | import org.datacite.mds.domain.Allocator; 11 | import org.springframework.ui.Model; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.util.UriUtils; 16 | import org.springframework.web.util.WebUtils; 17 | 18 | privileged aspect AllocatorController_Roo_Controller { 19 | 20 | String AllocatorController.encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) { 21 | String enc = httpServletRequest.getCharacterEncoding(); 22 | if (enc == null) { 23 | enc = WebUtils.DEFAULT_CHARACTER_ENCODING; 24 | } 25 | try { 26 | pathSegment = UriUtils.encodePathSegment(pathSegment, enc); 27 | } 28 | catch (UnsupportedEncodingException uee) {} 29 | return pathSegment; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/AllocatorController_Roo_Controller_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.lang.String; 7 | import org.datacite.mds.domain.Allocator; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | 13 | privileged aspect AllocatorController_Roo_Controller_Finder { 14 | 15 | @RequestMapping(params = { "find=ByNameLike", "form" }, method = RequestMethod.GET) 16 | public String AllocatorController.findAllocatorsByNameLikeForm(Model uiModel) { 17 | return "allocators/findAllocatorsByNameLike"; 18 | } 19 | 20 | @RequestMapping(params = "find=ByNameLike", method = RequestMethod.GET) 21 | public String AllocatorController.findAllocatorsByNameLike(@RequestParam("name") String name, Model uiModel) { 22 | uiModel.addAttribute("allocators", Allocator.findAllocatorsByNameLike(name).getResultList()); 23 | return "allocators/list"; 24 | } 25 | 26 | @RequestMapping(params = { "find=BySymbolEquals", "form" }, method = RequestMethod.GET) 27 | public String AllocatorController.findAllocatorsBySymbolEqualsForm(Model uiModel) { 28 | return "allocators/findAllocatorsBySymbolEquals"; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/DatacentreController_Roo_Controller.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.io.UnsupportedEncodingException; 7 | import java.lang.String; 8 | import javax.servlet.http.HttpServletRequest; 9 | import org.springframework.web.util.UriUtils; 10 | import org.springframework.web.util.WebUtils; 11 | 12 | privileged aspect DatacentreController_Roo_Controller { 13 | 14 | String DatacentreController.encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) { 15 | String enc = httpServletRequest.getCharacterEncoding(); 16 | if (enc == null) { 17 | enc = WebUtils.DEFAULT_CHARACTER_ENCODING; 18 | } 19 | try { 20 | pathSegment = UriUtils.encodePathSegment(pathSegment, enc); 21 | } 22 | catch (UnsupportedEncodingException uee) {} 23 | return pathSegment; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/DatacentreController_Roo_Controller_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.lang.String; 7 | import org.datacite.mds.domain.Datacentre; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | 13 | privileged aspect DatacentreController_Roo_Controller_Finder { 14 | 15 | @RequestMapping(params = { "find=ByNameLike", "form" }, method = RequestMethod.GET) 16 | public String DatacentreController.findDatacentresByNameLikeForm(Model uiModel) { 17 | return "datacentres/findDatacentresByNameLike"; 18 | } 19 | 20 | @RequestMapping(params = "find=ByNameLike", method = RequestMethod.GET) 21 | public String DatacentreController.findDatacentresByNameLike(@RequestParam("name") String name, Model uiModel) { 22 | uiModel.addAttribute("datacentres", Datacentre.findDatacentresByNameLike(name).getResultList()); 23 | return "datacentres/list"; 24 | } 25 | 26 | @RequestMapping(params = { "find=BySymbolEquals", "form" }, method = RequestMethod.GET) 27 | public String DatacentreController.findDatacentresBySymbolEqualsForm(Model uiModel) { 28 | return "datacentres/findDatacentresBySymbolEquals"; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/DatasetController_Roo_Controller.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.io.UnsupportedEncodingException; 7 | import java.lang.String; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import javax.servlet.http.HttpServletRequest; 11 | import org.datacite.mds.domain.Datacentre; 12 | import org.datacite.mds.domain.Dataset; 13 | import org.springframework.ui.Model; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RequestMethod; 16 | import org.springframework.web.util.UriUtils; 17 | import org.springframework.web.util.WebUtils; 18 | 19 | privileged aspect DatasetController_Roo_Controller { 20 | 21 | String DatasetController.encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) { 22 | String enc = httpServletRequest.getCharacterEncoding(); 23 | if (enc == null) { 24 | enc = WebUtils.DEFAULT_CHARACTER_ENCODING; 25 | } 26 | try { 27 | pathSegment = UriUtils.encodePathSegment(pathSegment, enc); 28 | } 29 | catch (UnsupportedEncodingException uee) {} 30 | return pathSegment; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/DatasetController_Roo_Controller_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.lang.String; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | 11 | privileged aspect DatasetController_Roo_Controller_Finder { 12 | 13 | @RequestMapping(params = { "find=ByDoiEquals", "form" }, method = RequestMethod.GET) 14 | public String DatasetController.findDatasetsByDoiEqualsForm(Model uiModel) { 15 | return "datasets/findDatasetsByDoiEquals"; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/MediaController_Roo_Controller.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.io.UnsupportedEncodingException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | 12 | import org.datacite.mds.domain.Dataset; 13 | import org.datacite.mds.domain.Media; 14 | import org.springframework.ui.Model; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestMethod; 17 | import org.springframework.web.util.UriUtils; 18 | import org.springframework.web.util.WebUtils; 19 | 20 | privileged aspect MediaController_Roo_Controller { 21 | 22 | @RequestMapping(params = "form", method = RequestMethod.GET) 23 | public String MediaController.createForm(Model uiModel) { 24 | uiModel.addAttribute("media", new Media()); 25 | List dependencies = new ArrayList(); 26 | if (Dataset.countDatasets() == 0) { 27 | dependencies.add(new String[]{"dataset", "datasets"}); 28 | } 29 | uiModel.addAttribute("dependencies", dependencies); 30 | return "medias/create"; 31 | } 32 | 33 | String MediaController.encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) { 34 | String enc = httpServletRequest.getCharacterEncoding(); 35 | if (enc == null) { 36 | enc = WebUtils.DEFAULT_CHARACTER_ENCODING; 37 | } 38 | try { 39 | pathSegment = UriUtils.encodePathSegment(pathSegment, enc); 40 | } 41 | catch (UnsupportedEncodingException uee) {} 42 | return pathSegment; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/MediaController_Roo_Controller_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.lang.String; 7 | import org.datacite.mds.domain.Dataset; 8 | import org.datacite.mds.domain.Media; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | 14 | privileged aspect MediaController_Roo_Controller_Finder { 15 | 16 | @RequestMapping(params = { "find=ByDataset", "form" }, method = RequestMethod.GET) 17 | public String MediaController.findMediasByDatasetForm(Model uiModel) { 18 | uiModel.addAttribute("datasets", Dataset.findAllDatasets()); 19 | return "medias/findMediasByDataset"; 20 | } 21 | 22 | @RequestMapping(params = "find=ByDataset", method = RequestMethod.GET) 23 | public String MediaController.findMediasByDataset(@RequestParam("dataset") Dataset dataset, Model uiModel) { 24 | uiModel.addAttribute("medias", Media.findMediasByDataset(dataset).getResultList()); 25 | return "medias/list"; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/PrefixController_Roo_Controller_Finder.aj: -------------------------------------------------------------------------------- 1 | // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO. 2 | // You may push code into the target .java compilation unit if you wish to edit any member(s). 3 | 4 | package org.datacite.mds.web.ui.controller; 5 | 6 | import java.lang.String; 7 | import org.datacite.mds.domain.Prefix; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | 13 | privileged aspect PrefixController_Roo_Controller_Finder { 14 | 15 | @RequestMapping(params = { "find=ByPrefixLike", "form" }, method = RequestMethod.GET) 16 | public String PrefixController.findPrefixesByPrefixLikeForm(Model uiModel) { 17 | return "prefixes/findPrefixesByPrefixLike"; 18 | } 19 | 20 | @RequestMapping(params = "find=ByPrefixLike", method = RequestMethod.GET) 21 | public String PrefixController.findPrefixesByPrefixLike(@RequestParam("prefix") String prefix, Model uiModel) { 22 | uiModel.addAttribute("prefixes", Prefix.findPrefixesByPrefixLike(prefix).getResultList()); 23 | return "prefixes/list"; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui.controller; 2 | 3 | import javax.servlet.http.HttpSession; 4 | 5 | import org.datacite.mds.web.ui.UiController; 6 | import org.datacite.mds.web.ui.UiUtils; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | 10 | @RequestMapping("/") 11 | @Controller 12 | public class WelcomeController implements UiController { 13 | @RequestMapping 14 | public String welcome(HttpSession session) { 15 | UiUtils.refreshSymbolsForSwitchUser(session); 16 | UiUtils.setLoginPathwaySessionAttribute(session); 17 | return "index"; 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/model/ChangePasswordMailModel.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui.model; 2 | 3 | import org.datacite.mds.validation.constraints.Symbol; 4 | 5 | public class ChangePasswordMailModel { 6 | @Symbol(value = { Symbol.Type.ALLOCATOR, Symbol.Type.DATACENTRE }, hasToExist = true) 7 | String symbol; 8 | 9 | public String getSymbol() { 10 | return symbol; 11 | } 12 | 13 | public void setSymbol(String symbol) { 14 | this.symbol = symbol; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/model/ChangePasswordModel.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui.model; 2 | 3 | import javax.validation.constraints.AssertTrue; 4 | import javax.validation.constraints.NotNull; 5 | import javax.validation.constraints.Size; 6 | 7 | public class ChangePasswordModel { 8 | @NotNull 9 | @Size(min = 8, max = 30) 10 | String first; 11 | String second; 12 | 13 | String symbol; 14 | 15 | @AssertTrue(message = "{org.datacite.mds.validation.other.FieldEquals.message}") 16 | public boolean isEqual() { 17 | return getFirst().equals(getSecond()); 18 | } 19 | 20 | public String getFirst() { 21 | return first; 22 | } 23 | 24 | public void setFirst(String first) { 25 | this.first = first; 26 | } 27 | 28 | public String getSecond() { 29 | return second; 30 | } 31 | 32 | public void setSecond(String second) { 33 | this.second = second; 34 | } 35 | 36 | public String getSymbol() { 37 | return symbol; 38 | } 39 | 40 | public void setSymbol(String symbol) { 41 | this.symbol = symbol; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/model/CreateDatasetModel.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui.model; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | import org.apache.commons.lang.builder.ToStringBuilder; 6 | import org.datacite.mds.domain.Datacentre; 7 | import org.hibernate.validator.constraints.NotEmpty; 8 | 9 | public class CreateDatasetModel { 10 | 11 | private String doi; 12 | 13 | @NotEmpty 14 | private String url; 15 | 16 | @NotNull 17 | private Datacentre datacentre; 18 | 19 | private byte[] xml; 20 | 21 | private byte[] xmlUpload; 22 | 23 | public String getDoi() { 24 | return doi; 25 | } 26 | 27 | public void setDoi(String doi) { 28 | this.doi = doi; 29 | } 30 | 31 | public String getUrl() { 32 | return url; 33 | } 34 | 35 | public void setUrl(String url) { 36 | this.url = url; 37 | } 38 | 39 | public Datacentre getDatacentre() { 40 | return datacentre; 41 | } 42 | 43 | public void setDatacentre(Datacentre datacentre) { 44 | this.datacentre = datacentre; 45 | } 46 | 47 | public byte[] getXml() { 48 | return xml; 49 | } 50 | 51 | public void setXml(byte[] xml) { 52 | this.xml = xml; 53 | } 54 | 55 | public byte[] getXmlUpload() { 56 | return xmlUpload; 57 | } 58 | 59 | public void setXmlUpload(byte[] xml) { 60 | this.xmlUpload = xml; 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return ToStringBuilder.reflectionToString(this); 66 | } 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/datacite/mds/web/ui/model/PrefixCreateModel.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.web.ui.model; 2 | 3 | public class PrefixCreateModel { 4 | 5 | private String prefixes; 6 | 7 | public String getPrefixes() { 8 | return prefixes; 9 | } 10 | 11 | public void setPrefixes(String prefixes) { 12 | this.prefixes = prefixes; 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/resources/META-INF/persistence.xml.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.hibernate.ejb.HibernatePersistence 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/database.properties.template: -------------------------------------------------------------------------------- 1 | database.password= 2 | database.username= 3 | database.url=jdbc:mysql://localhost/datacite?useUnicode=true&characterEncoding=UTF8 4 | database.driverClassName=com.mysql.jdbc.Driver -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/email.properties.template: -------------------------------------------------------------------------------- 1 | #Updated at Wed Sep 29 16:32:16 BST 2010 2 | #Wed Sep 29 16:32:16 BST 2010 3 | email.host=mail.example.com 4 | email.timeout=10000 5 | email.username=<> 6 | email.password=<> 7 | email.from=do-not-reply@datacite.org 8 | email.replyTo=tech@datacite.org 9 | email.mdsUrl=https://mds.datacite.org 10 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/handle.properties.template: -------------------------------------------------------------------------------- 1 | handle.index=300 2 | handle.id=<> 3 | handle.password=<> 4 | handle.traceMessages=false 5 | handle.dummyMode=true 6 | handle.testPrefix=10.5072 7 | 8 | #number of days after which a test dataset marked for deletion 9 | #negative number disables automatic purging 10 | handle.testPrefix.expiration.days=-1 11 | 12 | #cron expression for purging test prefix 13 | #example: "0 0 0 * * ?" means at midnight every day 14 | handle.testPrefix.expiration.cron=0 0 0 * * ? 15 | 16 | #always allow these domains in URLs regardless of datacentres settings 17 | #same syntax as for datacentre domain list (csv, wildcard support, subdomains included) 18 | handle.alwaysAllowedDomains=datacite.org 19 | 20 | #Does metadata for a given DOIs have to exist before minting DOIs? 21 | handle.metadataRequired=false 22 | 23 | #the server to ping for status check; separate multiple server by space 24 | handle.pingServer=0.SERV/10.TIB 25 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/salt.properties.template: -------------------------------------------------------------------------------- 1 | salt.password=<<'random' string; must not contain one of "{}">> 2 | salt.magicAuthString=<<'random' string>> 3 | salt.rememberMe=<<'random' string>> 4 | 5 | # days a change password link is valid 6 | magicAuthString.validityInDays=7 7 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/xml-validator.properties.template: -------------------------------------------------------------------------------- 1 | xml.validation=true 2 | xml.schema.caching=true 3 | 4 | #schemaLocation in xml must start with this prefix 5 | xml.schema.location.prefix=http://schema.datacite.org/meta/ 6 | 7 | #location of local copy of schemata; will replace the above prefix. 8 | #leave empty if there is no local copy. 9 | xml.schema.location.local= 10 | 11 | xml.schema.xpath.doi=//*[local-name() = 'identifier' and @identifierType='DOI'] 12 | -------------------------------------------------------------------------------- /src/main/resources/ValidationMessages.properties: -------------------------------------------------------------------------------- 1 | org.datacite.mds.validation.constraints.Doi.message=malformed DOI 2 | org.datacite.mds.validation.constraints.Doi.spaces=DOI must not contain any spaces 3 | org.datacite.mds.validation.constraints.DoiPrefix.message=malformed DOI prefix 4 | org.datacite.mds.validation.constraints.ListOfDomains.message=not a comma separated list of domains 5 | org.datacite.mds.validation.constraints.MatchDoi.message=DOI does not match 6 | org.datacite.mds.validation.constraints.MatchDoiPrefix.message=DOI prefix is not allowed 7 | org.datacite.mds.validation.constraints.MatchDomain.message=domain of URL is not allowed 8 | org.datacite.mds.validation.constraints.MatchPrefixes.message=list of DOI prefixes has to be a subset of allocator's list of prefixes 9 | org.datacite.mds.validation.constraints.MatchSymbolPrefix.message=has to begin with your symbol 10 | org.datacite.mds.validation.constraints.MediaType.disallowed.message=media type is not allowed 11 | org.datacite.mds.validation.constraints.MediaType.message=not a valid internet media type 12 | org.datacite.mds.validation.constraints.Symbol.ALLOCATOR.message=malformed allocator symbol (only uppercase letters, numbers or "-" inside; have to begin with a letter; min=2; max=8) 13 | org.datacite.mds.validation.constraints.Symbol.DATACENTRE.message=malformed datacentre symbol ("X.Y", with X and Y only uppercase letters, numbers or "-" inside; have to begin with a letter; each min=2, max=8) 14 | org.datacite.mds.validation.constraints.Symbol.notfound=symbol not found 15 | org.datacite.mds.validation.constraints.URL.protocol.message=protocol not allowed 16 | org.datacite.mds.validation.constraints.Unique.message=already exists 17 | org.datacite.mds.validation.constraints.ValidXML.message=XML does not validate 18 | org.datacite.mds.validation.other.FieldEquals.message=the fields have to be equal 19 | org.datacite.mds.ui.model.CreateDatasetModel.xml.required=XML must be uploaded when minting DOIs 20 | -------------------------------------------------------------------------------- /src/main/resources/conversion/metadata-kernel-2.0_fix-schema-location.xslt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | http://www.w3.org/2001/XMLSchema-instance 12 | http://schema.datacite.org/meta/kernel-2.0/metadata.xsd 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties.template: -------------------------------------------------------------------------------- 1 | #Updated at Wed Sep 29 16:32:16 BST 2010 2 | #Wed Sep 29 16:32:16 BST 2010 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.rootLogger=WARN, stdout 5 | log4j.appender.R.File=mds.log 6 | log4j.appender.R.MaxFileSize=100KB 7 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.R.MaxBackupIndex=1 9 | log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n 10 | log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n 11 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 12 | log4j.appender.R=org.apache.log4j.RollingFileAppender 13 | -------------------------------------------------------------------------------- /src/main/resources/log4j.xml.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/template/ResetPasswordMail: -------------------------------------------------------------------------------- 1 | DataCite Metadata Store: Change Password Request 2 | Dear %contactName%, 3 | 4 | Someone has requested changing the password for the '%symbol%' account 5 | on DataCite's Metadata Store. 6 | 7 | You can change your password with the following link 8 | 9 | %mdsUrl%/resources/change_password?symbol=%symbol%&auth=%magicAuth% 10 | 11 | This link is valid for at least %magicAuthValidityInDays% days. 12 | 13 | King regards, 14 | 15 | DataCite Metadata Store 16 | %mdsUrl% 17 | 18 | -------------------------------------------------------------------------------- /src/main/resources/template/WelcomeAllocatorMail: -------------------------------------------------------------------------------- 1 | DataCite Metadata Store: New Account 2 | Dear %contactName%, 3 | 4 | We welcome you to our Metadata Store on %mdsUrl%. 5 | 6 | An account was created for you. Your login name (symbol) is: 7 | 8 | %symbol% 9 | 10 | To activate your account and set the initial password you have to go to 11 | 12 | %mdsUrl%/resources/change_password?symbol=%symbol%&auth=%magicAuth% 13 | 14 | This link is valid for at least 24 hours. 15 | 16 | After successful login you are able to create datacentres under your 17 | symbol prefix (e.g. %symbol%.DC). By default a welcome mail is sent to 18 | each newly created datacentre, so they can set there password on their own. 19 | 20 | Via the "User Info" link on the upper right corner you can e.g. see the 21 | list of your DOI prefixes. 22 | 23 | Kind regards, 24 | 25 | DataCite Metadata Store 26 | %mdsUrl% 27 | 28 | -------------------------------------------------------------------------------- /src/main/resources/template/WelcomeDatacentreMail: -------------------------------------------------------------------------------- 1 | DataCite Metadata Store: New Account 2 | Dear %contactName%, 3 | 4 | We welcome you to our Metadata Store on %mdsUrl%. 5 | 6 | An account was created for you on behalf of "%allocatorName%" 7 | Your login name (symbol) is: 8 | 9 | %symbol% 10 | 11 | To activate your account and set the initial password you have to go to 12 | 13 | %mdsUrl%/resources/change_password?symbol=%symbol%&auth=%magicAuth% 14 | 15 | This link is valid for at least 24 hours. 16 | 17 | After successful login you can start to register DOIs for your datasets. 18 | 19 | Via the "User Info" link on the upper right corner you can e.g. see the 20 | list of domains and DOI prefixes you are allowed to use. 21 | 22 | Test Prefix: %testPrefix% 23 | 24 | Your Prefix(es): %prefixes% 25 | 26 | Your Domain(s): %domains% 27 | 28 | For testing purposes please only use the test prefix mentioned above. 29 | 30 | Kind regards, 31 | 32 | DataCite Metadata Store 33 | %mdsUrl% 34 | 35 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/classes/standard.properties: -------------------------------------------------------------------------------- 1 | styleSheet=resources/styles/standard.css 2 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/layouts/default.jspx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | <spring:message code="welcome_titlepane" arguments="${app_name}" htmlEscape="false"/> 15 | 16 | 17 | 18 |
19 | 20 | 21 |
22 | 23 | 24 |
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/layouts/layouts.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/spring/link.properties.template: -------------------------------------------------------------------------------- 1 | link.handleProxy=https://doi.org 2 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/menu/category.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
  • 16 |

    17 | 18 |

    19 |
      20 | 21 |
    22 |
  • 23 | 24 |
    25 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/menu/item.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
  • 22 | 23 | 24 | 25 | 26 |
  • 27 | 28 |
    29 |
    30 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/menu/menu.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
      10 | 11 |
    12 |
    13 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/change-password.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ${label} 11 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/comment-xml-upload.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | : 4 | 5 | ${schema} 6 | 7 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/comment.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
    8 | 9 | 10 | 11 | 12 |
    13 |
    14 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/crypt-mail-setup.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 53 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/hide.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
    23 | 24 |
    25 |
    26 |
    27 | 28 | 29 | 30 |
    31 | 32 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/highlight.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 |
    22 |
    23 |       
    24 |          
    25 |       
    26 |     
    27 |
    28 | 29 | 32 | 33 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/indent.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
    5 | 6 |
    7 | 8 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/language.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | ${fn:escapeXml(lang_label)} 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/list.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
      13 | 14 |
    • 15 |
      16 |
    17 |
    18 | 19 | 20 | 21 | 22 |
    23 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/placeholder.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/tab.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
    6 | 7 |
    8 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/tabs.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
    7 | 8 |
    9 | 10 | 34 | 35 | 36 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/theme.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | ${theme_standard} 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | ${theme_alt} 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/toc.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 34 |
    35 |
    36 |
    37 | 38 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/tags/util/tooltip.tagx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/accessDenied.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 |

    ${fn:escapeXml(title)}

    6 |

    7 | 8 |

    9 | 10 |

    11 |

    12 | 13 |

    14 | 15 | 16 | 17 | 18 |

    19 |
    20 |
    21 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/allocators/findAllocatorsByNameLike.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 |
    8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/allocators/findAllocatorsBySymbolEquals.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 |
    8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/allocators/list.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
    17 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/allocators/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/dataAccessFailure.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 |

    ${fn:escapeXml(title)}

    6 |

    7 | 8 |

    9 | 10 |

    11 |

    12 | 13 |

    14 | 15 | 16 | 17 | 18 |

    19 |
    20 |
    21 |
    22 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/datacentres/findDatacentresByNameLike.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 |
    8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/datacentres/findDatacentresBySymbolEquals.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 |
    8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/datacentres/list.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
    18 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/datacentres/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/datasets/create.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
    20 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/datasets/findDatasetsByDoiEquals.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 |
    8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/datasets/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/footer.jspx: -------------------------------------------------------------------------------- 1 | 2 | 41 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/index.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 | 6 |

    7 | 8 |

    9 |
    10 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/medias/create.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
    14 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/medias/findMediasByDataset.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 |
    9 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/medias/list.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
    15 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/medias/show.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
    13 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/medias/update.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
    15 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/medias/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/metadatas/list.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
    15 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/metadatas/update.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
    12 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/metadatas/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/password/change/change.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 | 6 | 7 | 8 |
    9 | 10 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/password/change/expired.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 |

    ${fn:escapeXml(title)}

    6 |

    7 | 8 |

    9 |
    10 |
    11 | 12 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/password/change/success.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 |

    ${fn:escapeXml(title)}

    6 |

    7 | 8 |

    9 | 10 | 11 |

    12 | 13 |

    14 |
    15 | 16 |

    17 | 18 |

    19 |
    20 |
    21 |
    22 |
    23 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/password/change/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/password/mail/mail.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 | 6 |
    7 | 8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/password/mail/success.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 |

    ${fn:escapeXml(title)}

    6 |

    7 | 8 |

    9 |
    10 |
    11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/password/mail/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/prefixes/create.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 |
    9 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/prefixes/findPrefixesByPrefixLike.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 |
    8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/prefixes/list.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
    12 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/prefixes/show.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 |
    10 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/prefixes/update.jspx: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 |
    9 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/prefixes/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/resourceNotFound.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 |

    ${fn:escapeXml(title)}

    6 |

    7 | 8 |

    9 | 10 |

    11 |

    12 | 13 |

    14 | 15 | 16 | 17 | 18 |

    19 |
    20 |
    21 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/static/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/uncaughtException.jspx: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 |

    ${fn:escapeXml(title)}

    6 |

    7 | 8 |

    9 | 10 |

    11 |

    12 | 13 |

    14 | 15 | 16 | 17 | 18 |

    19 |
    20 |
    21 |
    -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/userinfo/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/main/webapp/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/add.png -------------------------------------------------------------------------------- /src/main/webapp/images/banner-graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/banner-graphic.png -------------------------------------------------------------------------------- /src/main/webapp/images/banner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/banner.gif -------------------------------------------------------------------------------- /src/main/webapp/images/create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/create.png -------------------------------------------------------------------------------- /src/main/webapp/images/dc-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/dc-logo.gif -------------------------------------------------------------------------------- /src/main/webapp/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/delete.png -------------------------------------------------------------------------------- /src/main/webapp/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/favicon.png -------------------------------------------------------------------------------- /src/main/webapp/images/flags/de.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/flags/de.png -------------------------------------------------------------------------------- /src/main/webapp/images/flags/en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/flags/en.png -------------------------------------------------------------------------------- /src/main/webapp/images/flags/flags-license.txt: -------------------------------------------------------------------------------- 1 | Flag icons - http://www.famfamfam.com 2 | 3 | These icons are public domain, and as such are free for any use (attribution appreciated but not required). 4 | 5 | Note that these flags are named using the ISO3166-1 alpha-2 country codes where appropriate. A list of codes can be found at http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 6 | 7 | If you find these icons useful, please donate via paypal to mjames@gmail.com (or click the donate button available at http://www.famfamfam.com/lab/icons/silk) 8 | 9 | Contact: mjames@gmail.com -------------------------------------------------------------------------------- /src/main/webapp/images/flags/fr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/flags/fr.png -------------------------------------------------------------------------------- /src/main/webapp/images/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/list.png -------------------------------------------------------------------------------- /src/main/webapp/images/page_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/page_go.png -------------------------------------------------------------------------------- /src/main/webapp/images/resultset_first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/resultset_first.png -------------------------------------------------------------------------------- /src/main/webapp/images/resultset_last.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/resultset_last.png -------------------------------------------------------------------------------- /src/main/webapp/images/resultset_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/resultset_next.png -------------------------------------------------------------------------------- /src/main/webapp/images/resultset_previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/resultset_previous.png -------------------------------------------------------------------------------- /src/main/webapp/images/show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/show.png -------------------------------------------------------------------------------- /src/main/webapp/images/silk-icon-set-license.txt: -------------------------------------------------------------------------------- 1 | Silk icon set 1.3 2 | 3 | _________________________________________ 4 | Mark James 5 | http://www.famfamfam.com/lab/icons/silk/ 6 | _________________________________________ 7 | 8 | This work is licensed under a 9 | Creative Commons Attribution 2.5 License. 10 | [ http://creativecommons.org/licenses/by/2.5/ ] 11 | 12 | This means you may use it for any purpose, 13 | and make any changes you like. 14 | All I ask is that you include a link back 15 | to this page in your credits. 16 | 17 | Are you using this icon set? Send me an email 18 | (including a link or picture if available) to 19 | mjames@gmail.com 20 | 21 | Any other questions about this icon set please 22 | contact mjames@gmail.com -------------------------------------------------------------------------------- /src/main/webapp/images/springsource-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/springsource-logo.png -------------------------------------------------------------------------------- /src/main/webapp/images/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacite/mds/faeeceaa8048b3bacba3a678c9e52bb1256ef12a/src/main/webapp/images/update.png -------------------------------------------------------------------------------- /src/main/webapp/js/autotoc.js: -------------------------------------------------------------------------------- 1 | function autoTOC(rootId, tocId, depth, cssClassPrefix, anchorPrefix) { 2 | var toc = dojo.create("ul", null, tocId); 3 | var anchor = 0; 4 | 5 | dojo.query("h1,h2,h3,h4,h5,h6", rootId).forEach(function(h) { 6 | var level = h.nodeName.charAt(1); 7 | if (level > depth) 8 | return; 9 | anchor++; 10 | var anchorName = anchorPrefix + "-" + anchor; 11 | var cssClass = cssClassPrefix + "-h" + level; 12 | var li = dojo.create("li", { 13 | "class" : cssClass 14 | }, toc); 15 | var link = dojo.create("a", { 16 | href : "#" + anchorName, 17 | innerHTML : h.innerHTML 18 | }, li); 19 | dojo.create("a", { 20 | name : anchorName 21 | }, h); 22 | }); 23 | } -------------------------------------------------------------------------------- /src/main/webapp/js/dojox.highlight.languages.pygments.xmlfix.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. 3 | Available via Academic Free License >= 2.1 OR the modified BSD license. 4 | see: http://dojotoolkit.org/license for details 5 | */ 6 | 7 | 8 | if(!dojo._hasResource["dojox.highlight.languages.pygments.xmlfix"]){ 9 | dojo._hasResource["dojox.highlight.languages.pygments.xmlfix"]=true; 10 | dojo.provide("dojox.highlight.languages.pygments.xmlfix"); 11 | dojo.require("dojox.highlight._base"); 12 | dojox.highlight.languages.pygments.xmlfix={a:1}; 13 | dojox.highlight.languages.xmlfix={defaultMode:{contains:["name entity","comment","comment preproc","_tag"]},modes:[{className:"comment",begin:""},{className:"comment preproc",begin:"\\<\\!\\[CDATA\\[",end:"\\]\\]\\>"},{className:"comment preproc",begin:"\\<\\!",end:"\\>"},{className:"comment preproc",begin:"\\<\\?",end:"\\?\\>",relevance:5},{className:"string",begin:"'",end:"'",illegal:"\\n",relevance:0},{className:"string",begin:"\"",end:"\"",illegal:"\\n",relevance:0},{className:"name entity",begin:"\\&[a-z]+;",end:"^"},{className:"name tag",begin:"\\b[a-zA-Z0-9_\\:\\-]+\\b",end:"^"},{className:"name attribute",begin:"\\b[a-z0-9_\\:\\-]+=",end:"^",relevance:0},{className:"_tag",begin:"\\<",end:"\\>",contains:["name tag","name attribute","string"]},{className:"_tag",begin:"\\",contains:["name tag"]}]}; 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/domain/AllocatorOrDatacentreTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.domain; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.junit.runners.Parameterized; 11 | import org.junit.runners.Parameterized.Parameters; 12 | 13 | @RunWith(Parameterized.class) 14 | public class AllocatorOrDatacentreTest { 15 | 16 | AllocatorOrDatacentre user; 17 | 18 | public AllocatorOrDatacentreTest(AllocatorOrDatacentre user) { 19 | this.user = user; 20 | } 21 | 22 | @Test 23 | public void testTrimEmail() { 24 | String email = "foo@example.com"; 25 | user.setContactEmail(" " + email + " "); 26 | assertEquals(email, user.getContactEmail()); 27 | } 28 | 29 | @Test 30 | public void testNameReplaceLinebreak() { 31 | String name = " Foo\r\nbar\n"; 32 | user.setName(name); 33 | assertEquals("Foo bar", user.getName()); 34 | } 35 | 36 | @Parameters 37 | public static Collection getUsers() { 38 | Collection params = new ArrayList(); 39 | params.add(new Object[] { new Datacentre() }); 40 | params.add(new Object[] { new Allocator() }); 41 | return params; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/domain/DatacentreTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.domain; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.datacite.mds.test.TestUtils; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.test.annotation.Rollback; 9 | import org.springframework.test.context.ContextConfiguration; 10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | @RunWith(SpringJUnit4ClassRunner.class) 14 | @ContextConfiguration("/META-INF/spring/applicationContext.xml") 15 | @Transactional 16 | public class DatacentreTest { 17 | 18 | @Test 19 | @Rollback 20 | public void testIncQuotaUsed() { 21 | Datacentre datacentre = TestUtils.createDefaultDatacentre(); 22 | Integer expectedQuota = 43; 23 | 24 | datacentre.setDoiQuotaUsed(42); 25 | datacentre.persist(); 26 | 27 | datacentre.incQuotaUsed(Datacentre.ForceRefresh.YES); 28 | 29 | assertEquals(expectedQuota, datacentre.getDoiQuotaUsed()); 30 | 31 | Datacentre datacentre2 = Datacentre.findDatacentre(datacentre.getId()); 32 | assertEquals(expectedQuota, datacentre2.getDoiQuotaUsed()); 33 | } 34 | 35 | @Test 36 | @Rollback 37 | public void testIsQuotaExceeded() { 38 | Datacentre datacentre = TestUtils.createDefaultDatacentre(); 39 | datacentre.setDoiQuotaUsed(42); 40 | datacentre.setDoiQuotaAllowed(43); 41 | datacentre.persist(); 42 | 43 | assertFalse(datacentre.isQuotaExceeded()); 44 | 45 | datacentre.incQuotaUsed(Datacentre.ForceRefresh.YES); 46 | 47 | assertTrue(datacentre.isQuotaExceeded()); 48 | 49 | datacentre.setDoiQuotaAllowed(-1); 50 | datacentre.persist(); 51 | 52 | assertFalse(datacentre.isQuotaExceeded()); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/domain/PrefixTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.domain; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.junit.Test; 6 | 7 | public class PrefixTest { 8 | 9 | @Test 10 | public void testCompareTo() { 11 | assertTrue(0 == compareTo("10.5072", "10.5072")); 12 | assertTrue(0 < compareTo("10.12345", "10.4321")); 13 | assertTrue(0 > compareTo("10.42", "10.911")); 14 | assertTrue(0 < compareTo("10.6000", "10.2000")); 15 | assertTrue(0 > compareTo("10.2000", "10.3000")); 16 | } 17 | 18 | private int compareTo(String prefix1, String prefix2) { 19 | Prefix p1 = new Prefix(); 20 | Prefix p2 = new Prefix(); 21 | p1.setPrefix(prefix1); 22 | p2.setPrefix(prefix2); 23 | return p1.compareTo(p2); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/service/impl/PasswordEncoderImplTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service.impl; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.lang.reflect.Field; 6 | 7 | import org.apache.commons.codec.digest.DigestUtils; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | 12 | public class PasswordEncoderImplTest { 13 | 14 | PasswordEncoderImpl passwordEncoder; 15 | final static String SALT = "dummysalt"; 16 | final static String RAW_PASS = "test_pass"; 17 | 18 | @Before 19 | public void init() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { 20 | passwordEncoder = new PasswordEncoderImpl(); 21 | Field saltField = PasswordEncoderImpl.class.getDeclaredField("salt"); 22 | saltField.setAccessible(true); 23 | saltField.set(passwordEncoder, SALT); 24 | } 25 | 26 | @Test 27 | public void encodePassword_algorithm() { 28 | String encPass = DigestUtils.sha256Hex(RAW_PASS + "{" + SALT + "}"); 29 | assertEquals(encPass, passwordEncoder.encodePassword(RAW_PASS, null)); 30 | } 31 | 32 | @Test 33 | public void encodePassword_globalSalt() { 34 | String encPass1 = passwordEncoder.encodePassword(RAW_PASS, "salt"); 35 | String encPass2 = passwordEncoder.encodePassword(RAW_PASS, "another salt"); 36 | assertEquals(encPass1, encPass2); 37 | } 38 | 39 | @Test 40 | public void isPasswordValid() { 41 | String encPass = passwordEncoder.encodePassword(RAW_PASS, "salt"); 42 | assertTrue(passwordEncoder.isPasswordValid(encPass, RAW_PASS, "another salt")); 43 | assertFalse(passwordEncoder.isPasswordValid(encPass, "wrong" + RAW_PASS, "another salt")); 44 | } 45 | 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/service/userdetails/AdminMasterUserDetailsServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service.userdetails; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.datacite.mds.domain.Allocator; 6 | import org.datacite.mds.test.TestUtils; 7 | import org.datacite.mds.util.DomainUtils; 8 | import org.easymock.EasyMock; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.powermock.api.easymock.PowerMock; 12 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 13 | import org.powermock.core.classloader.annotations.PrepareForTest; 14 | import org.powermock.modules.junit4.PowerMockRunner; 15 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 16 | 17 | @RunWith(PowerMockRunner.class) 18 | @PowerMockIgnore( { "javax.*", "org.apache.log4j.*" }) 19 | @PrepareForTest( { DomainUtils.class }) 20 | public class AdminMasterUserDetailsServiceImplTest { 21 | 22 | AdminMasterUserDetailsServiceImpl service = new AdminMasterUserDetailsServiceImpl(); 23 | 24 | @Test 25 | public void test() { 26 | String admin = "ADMIN"; 27 | mockGetAdmin(TestUtils.createAdmin(admin)); 28 | assertEquals(admin,service.getMasterUsername("FOOBAR")); 29 | } 30 | 31 | @Test(expected = UsernameNotFoundException.class) 32 | public void testAdminNotFound() { 33 | mockGetAdmin(null); 34 | service.getMasterUsername("FOOBAR"); 35 | } 36 | 37 | void mockGetAdmin(Allocator mockReturn) { 38 | PowerMock.mockStatic(DomainUtils.class); 39 | EasyMock.expect(DomainUtils.getAdmin()).andReturn(mockReturn); 40 | PowerMock.replay(DomainUtils.class); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/service/userdetails/AllocatorMasterUserDetailsServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.service.userdetails; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 7 | 8 | public class AllocatorMasterUserDetailsServiceImplTest { 9 | 10 | AllocatorMasterUserDetailsServiceImpl service = new AllocatorMasterUserDetailsServiceImpl(); 11 | 12 | @Test 13 | public void test() { 14 | assertEquals("AL",service.getMasterUsername("AL.DC")); 15 | } 16 | 17 | @Test(expected = UsernameNotFoundException.class) 18 | public void testAllocatorSymbol() { 19 | service.getMasterUsername("AL"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/util/FilterPredicatesTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.util; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import java.util.Set; 7 | 8 | import org.apache.commons.collections.Predicate; 9 | import org.datacite.mds.domain.Allocator; 10 | import org.datacite.mds.domain.Datacentre; 11 | import org.datacite.mds.domain.Prefix; 12 | import org.datacite.mds.test.TestUtils; 13 | import org.junit.Test; 14 | 15 | public class FilterPredicatesTest { 16 | @Test 17 | public void testAllocatorOrDatacentreContainsPrefixPredicate() { 18 | Prefix prefix = TestUtils.createPrefix("10.5072"); 19 | Prefix anotherPrefix = TestUtils.createPrefix("10.0000"); 20 | Set prefixes = TestUtils.createPrefixes("10.5072", "10.5432"); 21 | Allocator allocator = TestUtils.createAllocator("AL"); 22 | allocator.setPrefixes(prefixes); 23 | Datacentre datacentre = TestUtils.createDatacentre("AL.DC", allocator); 24 | datacentre.setPrefixes(prefixes); 25 | 26 | assertTrue(prefixes.contains(prefix)); 27 | assertFalse(prefixes.contains(anotherPrefix)); 28 | 29 | Predicate predicate = FilterPredicates.getAllocatorOrDatacentreContainsPrefixPredicate(prefix); 30 | assertTrue(predicate.evaluate(allocator)); 31 | assertTrue(predicate.evaluate(datacentre)); 32 | 33 | predicate = FilterPredicates.getAllocatorOrDatacentreContainsPrefixPredicate(anotherPrefix); 34 | assertFalse(predicate.evaluate(allocator)); 35 | assertFalse(predicate.evaluate(datacentre)); 36 | } 37 | 38 | @Test 39 | public void callConstructor() { 40 | TestUtils.callConstructor(FilterPredicates.class); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/DoiPrefixTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.junit.Test; 7 | 8 | public class DoiPrefixTest extends AbstractContraintsTest { 9 | @DoiPrefix 10 | String prefix; 11 | 12 | @Test 13 | public void test() { 14 | assertTrue(isValid(null)); 15 | assertFalse(isValid("")); 16 | assertFalse(isValid("abc")); 17 | assertFalse(isValid("10")); 18 | assertFalse(isValid("10.abc")); 19 | assertFalse(isValid("10.1234/")); 20 | assertFalse(isValid("10.1234/test")); 21 | assertFalse(isValid("10..1234")); 22 | assertTrue(isValid("10.1234")); 23 | assertTrue(isValid("10.12345")); 24 | } 25 | 26 | boolean isValid(String prefix) { 27 | this.prefix = prefix; 28 | return super.isValid(this, "prefix"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/DoiTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.junit.Test; 7 | 8 | public class DoiTest extends AbstractContraintsTest { 9 | @Doi 10 | String doi; 11 | 12 | @Test 13 | public void test() { 14 | assertTrue(isValid(null)); 15 | assertFalse(isValid("")); 16 | assertFalse(isValid("a/b")); 17 | assertFalse(isValid("10.a/test")); 18 | assertFalse(isValid("10.1234/")); 19 | assertFalse(isValid("10..1234/test")); 20 | assertTrue(isValid("10.1234/test")); 21 | assertTrue(isValid("10.12345/test")); 22 | assertFalse(isValid("10.1234/a/foobar")); 23 | assertFalse(isValid("10.1234/foo/bar\u0010foo")); 24 | assertFalse(isValid("10.1234/foo\nbar")); 25 | } 26 | 27 | @Test 28 | public void testSpaces() { 29 | assertTrue(isValid("10.1234/test")); 30 | assertFalse(isValid(" 10.1234/test")); 31 | assertFalse(isValid("10.1234/test ")); 32 | assertFalse(isValid("10.1234/te st")); 33 | assertFalse(isValid("10. 1234/test")); 34 | } 35 | 36 | boolean isValid(String doi) { 37 | this.doi = doi; 38 | return super.isValid(this, "doi"); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/EmailTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.junit.Test; 7 | 8 | public class EmailTest extends AbstractContraintsTest { 9 | @Email 10 | String email; 11 | 12 | @Test 13 | public void test() { 14 | assertTrue(isValid(null)); 15 | assertFalse(isValid("")); 16 | assertFalse(isValid("@")); 17 | assertFalse(isValid("a@b")); 18 | assertFalse(isValid("a@b.c")); 19 | assertFalse(isValid("a@b.cd.e")); 20 | assertFalse(isValid("a@b@c.de")); 21 | assertFalse(isValid("a@com")); 22 | assertFalse(isValid("a @b.com")); 23 | assertFalse(isValid("a@b.com/path")); 24 | assertFalse(isValid("a@b%com")); 25 | assertFalse(isValid("a@b_com")); 26 | assertFalse(isValid("()[]\\;:,<>@example.com")); 27 | assertFalse(isValid("foo.example.com")); 28 | assertTrue(isValid("foo@example.com")); 29 | assertTrue(isValid("foo_bar#1@test.de")); 30 | assertTrue(isValid("foobar.bar@foo.bar.org")); 31 | } 32 | 33 | boolean isValid(String email) { 34 | this.email = email; 35 | return super.isValid(this, "email"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/ListOfDomainsTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.junit.Test; 7 | 8 | public class ListOfDomainsTest extends AbstractContraintsTest { 9 | @ListOfDomains(wildCard = "#") 10 | String domains; 11 | 12 | @Test 13 | public void test() { 14 | assertTrue(isValid(null)); 15 | assertFalse(isValid("com")); 16 | assertFalse(isValid("example.o")); 17 | assertFalse(isValid("com,example.com")); 18 | assertFalse(isValid("example.org;example.com")); 19 | assertFalse(isValid("example.com/path")); 20 | assertFalse(isValid("http://example.com")); 21 | assertTrue(isValid("example.org,foo.bar.org,a.b.c.de")); 22 | 23 | assertTrue(isValid("#")); 24 | assertTrue(isValid("#.com")); 25 | assertTrue(isValid("example.com,#.org")); 26 | assertFalse(isValid("example.com,#.org,net")); 27 | } 28 | 29 | boolean isValid(String domains) { 30 | this.domains = domains; 31 | return super.isValid(this, "domains"); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/MatchDoiTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.datacite.mds.domain.Dataset; 7 | import org.datacite.mds.domain.Metadata; 8 | import org.datacite.mds.test.TestUtils; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | 15 | @RunWith(SpringJUnit4ClassRunner.class) 16 | @ContextConfiguration("/META-INF/spring/applicationContext.xml") 17 | public class MatchDoiTest extends AbstractContraintsTest { 18 | 19 | String doiFromXml = "10.1594/WDCC/CCSRNIES_SRES_B2"; 20 | 21 | 22 | Metadata metadata; 23 | 24 | @Before 25 | public void init() throws Exception { 26 | Dataset dataset = new Dataset(); 27 | metadata = new Metadata(); 28 | metadata.setDataset(dataset); 29 | } 30 | 31 | @Test 32 | public void testVersion21() throws Exception { 33 | metadata.setXml(TestUtils.getTestMetadata21()); 34 | assertTrue(isValid(doiFromXml)); 35 | assertFalse(isValid(doiFromXml + ".")); 36 | } 37 | 38 | boolean isValid(String doi) { 39 | metadata.getDataset().setDoi(doi); 40 | return super.isValidAnnotation(metadata, MatchDoi.class); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/MatchSymbolPrefixTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.datacite.mds.domain.Allocator; 7 | import org.datacite.mds.domain.Datacentre; 8 | import org.datacite.mds.test.TestUtils; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | 15 | @RunWith(SpringJUnit4ClassRunner.class) 16 | @ContextConfiguration("/META-INF/spring/applicationContext.xml") 17 | public class MatchSymbolPrefixTest extends AbstractContraintsTest { 18 | 19 | Datacentre datacentre; 20 | 21 | @Before 22 | public void init() { 23 | Allocator allocator = TestUtils.createAllocator("AL"); 24 | datacentre = TestUtils.createDatacentre("AL.DC", allocator); 25 | } 26 | 27 | @Test 28 | public void test() { 29 | assertTrue(isValid(null)); 30 | assertTrue(isValid("AL.DC")); 31 | assertFalse(isValid("OTHER.DC")); 32 | } 33 | 34 | boolean isValid(String symbol) { 35 | datacentre.setSymbol(symbol); 36 | return super.isValidAnnotation(datacentre, MatchSymbolPrefix.class); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/URLTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.apache.commons.lang.StringUtils; 7 | import org.junit.Test; 8 | 9 | public class URLTest extends AbstractContraintsTest { 10 | @URL 11 | String url; 12 | 13 | @Test 14 | public void test() { 15 | assertTrue(isValid(null)); 16 | assertTrue(isValid("")); 17 | assertTrue(isValid("http://example.com")); 18 | assertTrue(isValid("http://example.com:8080/path?q=query&x#fragment")); 19 | assertFalse(isValid("http://example.com:-42")); 20 | } 21 | 22 | @Test 23 | public void testLength() { 24 | assertTrue(isValid(urlWithLength(2048))); 25 | assertFalse(isValid(urlWithLength(2049))); 26 | } 27 | 28 | @Test 29 | public void testProtocol() { 30 | assertTrue(isValid("http://example.com")); 31 | assertTrue(isValid("https://example.com")); 32 | assertTrue(isValid("ftp://example.com")); 33 | assertFalse(isValid("file://example.com")); 34 | } 35 | 36 | String urlWithLength(int len) { 37 | return urlWithLength(len, "http://example.com/"); 38 | } 39 | 40 | String urlWithLength(int len, String base) { 41 | return StringUtils.rightPad(base, len, 'x'); 42 | } 43 | 44 | boolean isValid(String url) { 45 | this.url = url; 46 | return super.isValid(this, "url"); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/UniqueTestEntity.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | 6 | @Unique(field = "uniqField") 7 | @Entity 8 | public class UniqueTestEntity { 9 | @Id 10 | private Integer id; 11 | 12 | private String uniqField; 13 | 14 | public static UniqueTestEntity create(Integer id, String uniqField) { 15 | UniqueTestEntity entity = new UniqueTestEntity(); 16 | entity.id = id; 17 | entity.uniqField = uniqField; 18 | return entity; 19 | } 20 | 21 | public Integer getId() { 22 | return id; 23 | } 24 | 25 | public void setId(Integer id) { 26 | this.id = id; 27 | } 28 | 29 | public String getUniqField() { 30 | return uniqField; 31 | } 32 | 33 | public void setUniqField(String uniqField) { 34 | this.uniqField = uniqField; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/org/datacite/mds/validation/constraints/ValidXmlTest.java: -------------------------------------------------------------------------------- 1 | package org.datacite.mds.validation.constraints; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.IOException; 6 | 7 | import org.datacite.mds.test.TestUtils; 8 | import org.junit.Test; 9 | 10 | public class ValidXmlTest extends AbstractContraintsTest { 11 | 12 | @ValidXML 13 | byte[] xml; 14 | 15 | @Test 16 | public void test() throws IOException { 17 | assertTrue(isValid(TestUtils.getTestMetadata())); 18 | assertFalse(isValid("")); 19 | } 20 | 21 | boolean isValid(String xml) { 22 | this.xml = xml.getBytes(); 23 | return super.isValid(this, "xml"); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.hibernate.ejb.HibernatePersistence 5 | 6 | 7 | 8 | 9 | 10 | org.datacite.mds.domain.Allocator 11 | org.datacite.mds.domain.Datacentre 12 | org.datacite.mds.domain.Dataset 13 | org.datacite.mds.domain.Metadata 14 | org.datacite.mds.domain.Media 15 | org.datacite.mds.domain.Prefix 16 | org.datacite.mds.validation.constraints.UniqueTestEntity 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/test/resources/META-INF/spring/database.properties.template: -------------------------------------------------------------------------------- 1 | database.password= 2 | database.username= 3 | database.url=jdbc:mysql://localhost/datacite_test?useUnicode=true&characterEncoding=UTF8 4 | database.driverClassName=com.mysql.jdbc.Driver 5 | -------------------------------------------------------------------------------- /src/test/resources/META-INF/spring/email.properties: -------------------------------------------------------------------------------- 1 | email.host= 2 | email.timeout= 3 | email.username= 4 | email.password= 5 | email.from=do-not-reply@datacite.org 6 | email.replyTo= 7 | email.mdsUrl=http://mds.example.com -------------------------------------------------------------------------------- /src/test/resources/META-INF/spring/handle.properties: -------------------------------------------------------------------------------- 1 | handle.index=300 2 | handle.id= 3 | handle.password= 4 | handle.traceMessages=false 5 | handle.dummyMode=true 6 | handle.testPrefix=10.9999 7 | handle.testPrefix.expiration.days=-1 8 | handle.testPrefix.expiration.cron=0 0 0 1 1 ? 9 | handle.alwaysAllowedDomains=datacite.org,foobar.* 10 | handle.metadataRequired=false 11 | handle.pingServer= 12 | -------------------------------------------------------------------------------- /src/test/resources/META-INF/spring/salt.properties: -------------------------------------------------------------------------------- 1 | salt.password=foobar 2 | salt.magicAuthString=foobar 3 | salt.rememberMe=foobar 4 | 5 | magicAuthString.validityInDays=7 -------------------------------------------------------------------------------- /src/test/resources/META-INF/spring/xml-validator.properties: -------------------------------------------------------------------------------- 1 | xml.validation=true 2 | xml.schema.caching=true 3 | xml.schema.location.prefix=http://schema.datacite.org/meta/ 4 | xml.schema.location.local= 5 | xml.schema.xpath.doi=//*[local-name() = 'identifier' and @identifierType='DOI'] 6 | -------------------------------------------------------------------------------- /src/test/resources/conversion/metadata-kernel-2.0_fix-schema-location/converted.xml: -------------------------------------------------------------------------------- 1 | 10.5524/104aad,adf,asdfadfaGigaScience2011 -------------------------------------------------------------------------------- /src/test/resources/conversion/metadata-kernel-2.0_fix-schema-location/missing_no_namespace_schema_location.xml: -------------------------------------------------------------------------------- 1 | 2 | 10.5524/104aad,adf,asdfadfaGigaScience2011 3 | -------------------------------------------------------------------------------- /src/test/resources/conversion/metadata-kernel-2.0_fix-schema-location/wrong_no_namespace_schema_location.xml: -------------------------------------------------------------------------------- 1 | 2 | 10.5524/104aad,adf,asdfadfaGigaScience2011 3 | -------------------------------------------------------------------------------- /src/test/resources/conversion/metadata-kernel-2.0_fix-schema-location/wrong_xsi_namespace.xml: -------------------------------------------------------------------------------- 1 | 2 | 10.5524/104aad,adf,asdfadfaGigaScience2011 3 | -------------------------------------------------------------------------------- /src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=WARN, stdout 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.logger.org.datacite.mds.validation.constraints.impl.UniqueValidator=OFF 6 | 7 | -------------------------------------------------------------------------------- /src/test/resources/template/TestMail: -------------------------------------------------------------------------------- 1 | Subject 2 | Text --------------------------------------------------------------------------------