Project

General

Profile

« Previous | Next » 

Revision 32398

Added by Nikon Gasparis over 9 years ago

*fixed a bug while registering aggregator without set
*fixed a wrong response message when a journal/aggregator were already registered in db

View differences:

modules/uoa-madgik-validator/trunk/src/main/java/gr/uoa/di/validatorweb/actions/registration/dnet/RepoRegistration.java
30 30
	private static final long serialVersionUID = -2912240396302341015L;
31 31
	private static Logger logger = Logger.getLogger(RepoRegistration.class);
32 32

  
33
	
34 33
	private VocabularyLoader vocabularyLoader = null;
35 34
	private Map<String, Object> session;
36 35
	private List<String> adminEmails;
......
130 129
					fileIface.setAccessProtocol("files_from_metadata");
131 130
					fileIface.getAccessParams().put("xpath",pubFileIface.getXpath());
132 131
				}
133
				
134 132
//				
135 133
				logger.debug("source: " + pubFileIface.getMethodology());
136 134
				logger.debug("protocol: " + pubFileIface.getProtocol());
......
151 149
			return "exception";
152 150
		}
153 151

  
154
		try {
155
//			Map <String, String> compMap;
156
//			compMap = getRepoAPI().getRepoCompatibility(repo.getOfficialName(), repo.getId());
157
			if (!this.getOpenAIREValidator().userOverridesRepoRegistration((String) session.get(Constants.loggedInField))) {
158
				logger.debug("User is not regRepoOverrrider");
159
//FOR TESTING
160
//				this.adminEmails.clear();
161
//				this.adminEmails.add((String) session.get(Constants.loggedInField));
162
//FOR TESTING
163
				logger.debug("interfacesToRegister : " + interfacesToRegister.size());
164
				for (RepositoryInterface iFace : interfacesToRegister) {
165
					if(iFace.getAccessSet() == null || iFace.getAccessSet().isEmpty()) {
166
						logger.debug("updating set to none");
167
						iFace.setAccessSet("none");
168
					}
169
					this.printInterface(iFace);
170
//					logger.debug("current ComplianceEname: "+ iFace.getComplianceName());
171
//					logger.debug("current ComplianceCode: "+ iFace.getCompliance());
172
//					logger.debug("desired Compliance: "+ iFace.getDesiredCompatibilityLevel());
173
//					if ((this.getDbMode().equalsIgnoreCase("direct") && !compMap.containsKey(iFace.getDesiredCompatibilityLevel())) 
174
//					 || (this.getDbMode().equalsIgnoreCase("dms") && (!(iFace.getDesiredCompatibilityLevel().equalsIgnoreCase(getComplianceCode(iFace.getCompliance()))) && 
175
//							 !(iFace.getDesiredCompatibilityLevel().equalsIgnoreCase("openaire2.0_data") && getComplianceCode(iFace.getCompliance()).equalsIgnoreCase("openaire2.0"))))){
176
					if (this.getDbMode().equalsIgnoreCase("dms") && (!(iFace.getDesiredCompatibilityLevel().equalsIgnoreCase(iFace.getCompliance())) && 
177
									 !(iFace.getDesiredCompatibilityLevel().equalsIgnoreCase("openaire2.0_data") && iFace.getCompliance().equalsIgnoreCase("openaire2.0")))){
178
						logger.debug("initiating preregistration validations on repo :" + iFace.getBaseUrl() + "for set: " + iFace.getAccessSet() + " and compliance: " + iFace.getDesiredCompatibilityLevel());
179
						JobForRegistration job = new JobForRegistration();
180
						job.setActivation_id(UUID.randomUUID().toString());
181
						job.setAdmin_emails(this.adminEmails);
182
						job.setBaseurl(iFace.getBaseUrl());
183
						job.setDatasource_id(repo.getId());
184
						job.setDesired_compatiblity_level(iFace.getDesiredCompatibilityLevel());
185
						job.setInterface_id(iFace.getId());
186
						job.setInterface_id_old(null);
187
						job.setOfficial_name(repo.getOfficialName());
188
						job.setRepo_type(repoType);
189
						job.setUser((String) session.get(Constants.loggedInField));
190
						job.setValidation_set(iFace.getAccessSet());
191
						job.setPurpose("register");
152
		logger.debug("interfacesToRegister : " + interfacesToRegister.size());
153
		if (interfacesToRegister.size() > 0) {
154
			try {
155
	//			Map <String, String> compMap;
156
	//			compMap = getRepoAPI().getRepoCompatibility(repo.getOfficialName(), repo.getId());
157
				if (!this.getOpenAIREValidator().userOverridesRepoRegistration((String) session.get(Constants.loggedInField))) {
158
					logger.debug("User is not regRepoOverrrider");
159
	//FOR TESTING
160
//					this.adminEmails.clear();
161
//					this.adminEmails.add((String) session.get(Constants.loggedInField));
162
	//FOR TESTING
163
					
164
					for (RepositoryInterface iFace : interfacesToRegister) {
165
						if(iFace.getAccessSet() == null || iFace.getAccessSet().isEmpty()) {
166
							logger.debug("updating set to none");
167
							iFace.setAccessSet("none");
168
						}
192 169
						this.printInterface(iFace);
193
						this.getOpenAIREValidator().storeJobForRegistration(job);
194
						this.getOpenAIREValidator().preRegistrationValidations(job);
195
					} else {
196
						logger.debug("repo :" + iFace.getBaseUrl() + " for : " + iFace.getAccessSet() + " is already compliant on desiredcompliance: " + iFace.getCompliance());
197
						List<String> rec = new ArrayList<String>();
198
						rec.add((String) session.get(Constants.loggedInField));
199
						String msgUpgrade = "";
200
						if (iFace.getCompliance() != null && !mode.equalsIgnoreCase("re3data") && !iFace.getCompliance().equalsIgnoreCase("openaire3.0"))
201
							msgUpgrade = "\n\n Please consider to upgrade to OpenAIRE Guidelines v3. Link: https://guidelines.openaire.eu/wiki/OpenAIRE_Guidelines:_For_Literature_repositories";
202

  
203
						this.getEmailer().sendMail(rec, "Request to Join OpenAIRE - Test Results [" + repo.getOfficialName() + "]", "Your " + repoType + " is already \"" + iFace.getDesiredCompatibilityLevel() + "\" compliant. As a result, there is no need to run registration test for url: " + iFace.getBaseUrl() + " and set: " + iFace.getAccessSet() + " ." + msgUpgrade, false, null);
170
	//					logger.debug("current ComplianceEname: "+ iFace.getComplianceName());
171
	//					logger.debug("current ComplianceCode: "+ iFace.getCompliance());
172
	//					logger.debug("desired Compliance: "+ iFace.getDesiredCompatibilityLevel());
173
	//					if ((this.getDbMode().equalsIgnoreCase("direct") && !compMap.containsKey(iFace.getDesiredCompatibilityLevel())) 
174
	//					 || (this.getDbMode().equalsIgnoreCase("dms") && (!(iFace.getDesiredCompatibilityLevel().equalsIgnoreCase(getComplianceCode(iFace.getCompliance()))) && 
175
	//							 !(iFace.getDesiredCompatibilityLevel().equalsIgnoreCase("openaire2.0_data") && getComplianceCode(iFace.getCompliance()).equalsIgnoreCase("openaire2.0"))))){
176
						if (this.getDbMode().equalsIgnoreCase("dms") && (!(iFace.getDesiredCompatibilityLevel().equalsIgnoreCase(iFace.getCompliance())) && 
177
										 !(iFace.getDesiredCompatibilityLevel().equalsIgnoreCase("openaire2.0_data") && iFace.getCompliance().equalsIgnoreCase("openaire2.0")))){
178
							logger.debug("initiating preregistration validations on repo :" + iFace.getBaseUrl() + "for set: " + iFace.getAccessSet() + " and compliance: " + iFace.getDesiredCompatibilityLevel());
179
							JobForRegistration job = new JobForRegistration();
180
							job.setActivation_id(UUID.randomUUID().toString());
181
							job.setAdmin_emails(this.adminEmails);
182
							job.setBaseurl(iFace.getBaseUrl());
183
							job.setDatasource_id(repo.getId());
184
							job.setDesired_compatiblity_level(iFace.getDesiredCompatibilityLevel());
185
							job.setInterface_id(iFace.getId());
186
							job.setInterface_id_old(null);
187
							job.setOfficial_name(repo.getOfficialName());
188
							job.setRepo_type(repoType);
189
							job.setUser((String) session.get(Constants.loggedInField));
190
							job.setValidation_set(iFace.getAccessSet());
191
							job.setPurpose("register");
192
							this.printInterface(iFace);
193
							this.getOpenAIREValidator().storeJobForRegistration(job);
194
							this.getOpenAIREValidator().preRegistrationValidations(job);
195
						} else {
196
							logger.debug("repo :" + iFace.getBaseUrl() + " for : " + iFace.getAccessSet() + " is already compliant on desiredcompliance: " + iFace.getCompliance());
197
							List<String> rec = new ArrayList<String>();
198
							rec.add((String) session.get(Constants.loggedInField));
199
							String msgUpgrade = "";
200
							if (iFace.getCompliance() != null && !mode.equalsIgnoreCase("re3data") && !iFace.getCompliance().equalsIgnoreCase("openaire3.0"))
201
								msgUpgrade = "\n\n Please consider to upgrade to OpenAIRE Guidelines v3. Link: https://guidelines.openaire.eu/wiki/OpenAIRE_Guidelines:_For_Literature_repositories";
202
	
203
							this.getEmailer().sendMail(rec, "Request to Join OpenAIRE - Test Results [" + repo.getOfficialName() + "]", "Your " + repoType + " is already \"" + iFace.getDesiredCompatibilityLevel() + "\" compliant. As a result, there is no need to run registration test for url: " + iFace.getBaseUrl() + " and set: " + iFace.getAccessSet() + " ." + msgUpgrade, false, null);
204
						}
204 205
					}
206
					String validationStarted = "Compatibility test(s) for the " + repoType + " you wish to add have automatically started . You will be notified via email with further instructions when the test(s) has finished. For this " + repoType + " to be added in the OpenAIRE compliant list, the test must be successful.";
207
					this.addActionMessage(validationStarted);
208
	//				this.addActionMessage(this.getText("repoRegistration.validationStarted"));
209
					this.addActionMessage("Administrator email:" + this.adminEmails.get(0));
210
					this.addActionMessage((this.getText("general.unblock") + " " + this.getEmailer().getFrom()));
211
					List<String> recipients = new ArrayList<String>();
212
					recipients.addAll(this.adminEmails);
213
					this.getEmailer().sendMail(recipients, "Request to Join OpenAIRE - Confirmation [" + repo.getOfficialName() + "]", "A request has been sent to add '" + repo.getOfficialName() + "' " + repoType + " to the OpenAIRE compliant list. If you have any questions you can communicate with the user that made the request using this email: " + (String) session.get(Constants.loggedInField), false, null);
214
					recipients.clear();
215
					recipients.add((String) session.get(Constants.loggedInField));
216
					this.getEmailer().sendMail(recipients, "Request to Join OpenAIRE - Confirmation [" + repo.getOfficialName() + "]", "A request has been sent to add '" + repo.getOfficialName() + "' " + repoType + " to the OpenAIRE compliant list. The neccessary compatibility tests will begin shortly", true, null);
217
				} else {
218
					logger.debug("User is regRepoOverrider");
219
					List<String> recipients = new ArrayList<String>();
220
					recipients.add((String) session.get(Constants.loggedInField));
221
					this.getEmailer().sendMail(recipients, "Request to Join OpenAIRE [" + repo.getOfficialName() + "]", "A request has been sent to add '" + repo.getOfficialName() + "' to the OpenAIRE compliant list. Since you are logged-in as administrator, registration tests are bypassed.", false, null);
222
	
223
					this.addActionMessage((this.getText("repoRegistration.overriden.successful")));
224
					for (RepositoryInterface iFace : repo.getInterfaces()) {
225
						getRepoAPI().updateRepositoryInterfaceCompliance(repo.getOfficialName(), repo.getId(), iFace.getId(), iFace.getDesiredCompatibilityLevel(),iFace.getAccessSet(),iFace.getBaseUrl(), iFace.getExtraFields().get("oldId"));				}
205 226
				}
206
				String validationStarted = "Compatibility test(s) for the " + repoType + " you wish to add have automatically started . You will be notified via email with further instructions when the test(s) has finished. For this " + repoType + " to be added in the OpenAIRE compliant list, the test must be successful.";
207
				this.addActionMessage(validationStarted);
208
//				this.addActionMessage(this.getText("repoRegistration.validationStarted"));
209
				this.addActionMessage("Administrator email:" + this.adminEmails.get(0));
210
				this.addActionMessage((this.getText("general.unblock") + " " + this.getEmailer().getFrom()));
211
				List<String> recipients = new ArrayList<String>();
212
				recipients.addAll(this.adminEmails);
213
				this.getEmailer().sendMail(recipients, "Request to Join OpenAIRE - Confirmation [" + repo.getOfficialName() + "]", "A request has been sent to add '" + repo.getOfficialName() + "' " + repoType + " to the OpenAIRE compliant list. If you have any questions you can communicate with the user that made the request using this email: " + (String) session.get(Constants.loggedInField), false, null);
214
				recipients.clear();
215
				recipients.add((String) session.get(Constants.loggedInField));
216
				this.getEmailer().sendMail(recipients, "Request to Join OpenAIRE - Confirmation [" + repo.getOfficialName() + "]", "A request has been sent to add '" + repo.getOfficialName() + "' " + repoType + " to the OpenAIRE compliant list. The neccessary compatibility tests will begin shortly", true, null);
217
			} else {
218
				logger.debug("User is regRepoOverrider");
219
				List<String> recipients = new ArrayList<String>();
220
				recipients.add((String) session.get(Constants.loggedInField));
221
				this.getEmailer().sendMail(recipients, "Request to Join OpenAIRE [" + repo.getOfficialName() + "]", "A request has been sent to add '" + repo.getOfficialName() + "' to the OpenAIRE compliant list. Since you are logged-in as administrator, registration tests are bypassed.", false, null);
222

  
223
				this.addActionMessage((this.getText("repoRegistration.overriden.successful")));
224
				for (RepositoryInterface iFace : repo.getInterfaces()) {
225
					getRepoAPI().updateRepositoryInterfaceCompliance(repo.getOfficialName(), repo.getId(), iFace.getId(), iFace.getDesiredCompatibilityLevel(),iFace.getAccessSet(),iFace.getBaseUrl(), iFace.getExtraFields().get("oldId"));				}
227
			} catch (Exception e) {
228
				logger.error("error registering repo " + repo.getOfficialName(), e);
229
				this.addActionError(this.getText("generic.error"));
230
				reportException(e);
231
				return "exception";
226 232
			}
227
		} catch (Exception e) {
228
			logger.error("error registering repo " + repo.getOfficialName(), e);
229
			this.addActionError(this.getText("generic.error"));
230
			reportException(e);
231
			return "exception";
232 233
		}
233
		
234
		
235 234
		return Action.SUCCESS;
236
		
237 235
	}
238 236

  
239 237
	private String getCountryCode(String countryName) {
modules/uoa-madgik-validator/trunk/src/main/java/gr/uoa/di/validator/database/OpenDoarRepositoryFactoryDmsImpl.java
73 73
					
74 74
					logger.debug("looking if " + datatype + " " + repo.getOfficialName() + " is already in datasources");
75 75
					if (dmService.getService().getDatasource(repo.getId()) != null) {
76
						retMessage = datatype + " " + repo.getOfficialName() + " is already in datasources.";
76
						retMessage = datatype + " '" + repo.getOfficialName() + "' is already in datasources.";
77
						repo.getInterfaces().clear();
77 78
						logger.debug(retMessage);
78 79
					} else {
79 80
						logger.debug(datatype + " " + repo.getOfficialName() + " is not in datasources. Inserting..");
......
137 138
							iFace.removeAccessSet();
138 139
						}
139 140
						logger.debug("new ifaceId :" + iFace.getId());
140
						if(iFace.getAccessSet().isEmpty()) {
141
							logger.debug("set is empty: " + iFace.getAccessSet());
142
							iFace.removeAccessSet();
143
						}
144 141
						if (dmService.getService().addInterface(repo.getId(), iFace))
145 142
							logger.debug("added successfully");
146 143
						else
......
149 146
					interfacesToRegister.add(iFace);
150 147
				}
151 148
			}
152
		} catch (DatasourceManagerServiceException e) {
153
			logger.error("Error storing repo " + repo.getOfficialName() + " in dms", e);
154 149
		} catch (Exception e) {
155 150
			logger.error("Error storing repo " + repo.getOfficialName() + " in dms", e);
156 151
		}
modules/uoa-madgik-validator/trunk/pom.xml
10 10
	<groupId>eu.dnetlib</groupId>
11 11
	<artifactId>uoa-madgik-validator</artifactId>
12 12
	<packaging>war</packaging>
13
	<version>1.1.0-SNAPSHOT</version>
13
	<version>1.0.1-SNAPSHOT</version>
14 14
	<scm>
15 15
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-madgik-validator/trunk</developerConnection>
16 16
	</scm>

Also available in: Unified diff