Skip to content

Commit 2337556

Browse files
SentinelDataHubRaffaele Bua
authored andcommitted
OSF publication - version 0.9.0-2-hotfix-4
1 parent 93118eb commit 2337556

File tree

27 files changed

+493
-198
lines changed

27 files changed

+493
-198
lines changed

.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Compiled source #
2+
###################
3+
*.com
4+
*.class
5+
*.dll
6+
*.exe
7+
*.o
8+
*.so
9+
10+
# Packages #
11+
############
12+
# it's better to unpack these files and commit the raw source
13+
# git has its own built in compression methods
14+
*.7z
15+
*.dmg
16+
*.gz
17+
*.iso
18+
*.jar
19+
*.rar
20+
*.tar
21+
*.zip
22+
23+
# Logs and databases #
24+
######################
25+
*.log
26+
*.sql
27+
*.sqlite
28+
29+
# OS generated files #
30+
######################
31+
.DS_Store
32+
.DS_Store?
33+
._*
34+
.Spotlight-V100
35+
.Trashes
36+
ehthumbs.db
37+
Thumbs.db
38+
39+
# IDE files #
40+
#############
41+
.~lock.*
42+
.buildpath
43+
44+
# Netbeans
45+
nbproject
46+
nbactions.xml
47+
nb-configuration.xml
48+
49+
# Eclipse
50+
.classpath
51+
.project
52+
.settings/
53+
54+
# Intellij
55+
.idea/
56+
*.iml
57+
*.iws
58+
59+
# Mac
60+
.DS_Store
61+
62+
# Maven
63+
target/
64+
local_dhus_test/

client/gwt/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>fr.gael.dhus</groupId>
99
<artifactId>dhus-parent</artifactId>
10-
<version>0.9.0-2</version>
10+
<version>0.9.0-2-hotfix-4</version>
1111
<relativePath></relativePath>
1212
</parent>
1313

client/html/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>fr.gael.dhus</groupId>
1212
<artifactId>dhus-parent</artifactId>
13-
<version>0.9.0-2</version>
13+
<version>0.9.0-2-hotfix-4</version>
1414
</parent>
1515

1616
<artifactId>dhus-client-html</artifactId>

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>fr.gael.dhus</groupId>
99
<artifactId>dhus-parent</artifactId>
10-
<version>0.9.0-2</version>
10+
<version>0.9.0-2-hotfix-4</version>
1111
<relativePath></relativePath>
1212
</parent>
1313

client/webclient/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>fr.gael.dhus</groupId>
1212
<artifactId>dhus-parent</artifactId>
13-
<version>0.9.0-2</version>
13+
<version>0.9.0-2-hotfix-4</version>
1414
</parent>
1515

1616
<artifactId>dhus-web-client</artifactId>

client/webclient/src/main/frontend/app/config/appconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,4 @@
163163
]
164164

165165
}
166+

client/webclient/src/main/frontend/app/scripts/services/odata-synchronizer-service.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ angular
4343
<d:ServiceUrl>'+model.serviceUrl+'</d:ServiceUrl> \
4444
<d:ServiceLogin>'+model.serviceLoginUsername+'</d:ServiceLogin> '+
4545
((model.serviceLoginPassword && (model.serviceLoginPassword!=''))?('<d:ServicePassword>'+model.serviceLoginPassword+'</d:ServicePassword> ' ):'')+
46-
'<d:Schedule>'+model.schedule+'</d:Schedule> \
47-
<d:RemoteIncoming>'+model.remoteIncoming+'</d:RemoteIncoming> \
48-
<d:Request>'+model.request+'</d:Request> '+
46+
'<d:Schedule>'+model.schedule+'</d:Schedule> ' +
47+
((model.remoteIncoming && (model.remoteIncoming!=''))?('<d:RemoteIncoming>'+model.remoteIncoming+'</d:RemoteIncoming> ' ):'')+
48+
'<d:Request>'+model.request+'</d:Request> '+
4949
((model.copyProduct && (model.copyProduct!=''))?('<d:CopyProduct>'+model.copyProduct+'</d:CopyProduct> ' ):'')+
5050
((model.filterParam && (model.filterParam!=''))?('<d:FilterParam>'+model.filterParam+'</d:FilterParam> '):'<d:FilterParam></d:FilterParam>')+
5151
((model.sourceCollection && (model.sourceCollection!=''))?('<d:SourceCollection>'+model.sourceCollection+'"</d:SourceCollection> '):'')+

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<parent>
4040
<groupId>fr.gael.dhus</groupId>
4141
<artifactId>dhus-parent</artifactId>
42-
<version>0.9.0-2</version>
42+
<version>0.9.0-2-hotfix-4</version>
4343
<relativePath></relativePath>
4444
</parent>
4545

core/src/main/java/fr/gael/dhus/api/stub/StubUserController.java

Lines changed: 9 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.Iterator;
77
import java.util.Set;
88

9+
import fr.gael.dhus.service.exception.RequiredFieldMissingException;
910
import org.apache.commons.logging.Log;
1011
import org.apache.commons.logging.LogFactory;
1112
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,31 +26,20 @@
2526
import fr.gael.dhus.api.stub.stub_share.exceptions.UserBadEncryptionException;
2627
import fr.gael.dhus.api.stub.stub_share.exceptions.UserBadOldPasswordException;
2728
import fr.gael.dhus.api.stub.stub_share.exceptions.UserPasswordConfirmationException;
28-
import fr.gael.dhus.database.dao.UserDao;
2929
import fr.gael.dhus.database.object.User;
3030
import fr.gael.dhus.database.object.User.PasswordEncryption;
31-
import fr.gael.dhus.messaging.mail.MailServer;
3231
import fr.gael.dhus.service.UserService;
3332
import fr.gael.dhus.service.exception.RootNotModifiableException;
3433
import fr.gael.dhus.spring.context.ApplicationContextProvider;
35-
import fr.gael.dhus.system.config.ConfigurationManager;
3634

3735
@RestController
3836
public class StubUserController {
3937
private static Log logger = LogFactory.getLog(StubUserController.class);
4038

41-
@Autowired
42-
private UserDao userDao;
4339

4440
@Autowired
4541
private UserService userService;
4642

47-
@Autowired
48-
private ConfigurationManager cfgManager;
49-
50-
@Autowired
51-
private MailServer mailer;
52-
5343
private User getUserFromPrincipal(Principal principal) {
5444
User user = ((User) ((UsernamePasswordAuthenticationToken) principal)
5545
.getPrincipal());
@@ -67,27 +57,14 @@ public User getUserProfile(Principal principal,
6757
@RequestMapping(value = "/stub/users/{userid}", method = RequestMethod.PUT)
6858
public int updateUserProfile(Principal principal,
6959
@RequestBody UserRequestBody body,
70-
@PathVariable(value = "userid") String userid) {
60+
@PathVariable(value = "userid") String userid) throws RequiredFieldMissingException, RootNotModifiableException {
7161
logger.info("******** updateUserProfile()");
7262
int responseCode = 0;
7363
User user = body.getUser();
7464
logger.info("******** called body.getUser");
7565
PasswordModel passwordModel = body.getPasswordModel();
7666
User u = getUserFromPrincipal(principal);
77-
try {
78-
logger.info("******** inside try");
79-
checkRoot(u);
80-
} catch (RootNotModifiableException e) {
81-
logger.info("******** caught RootNotModifiableException");
82-
responseCode = 1001;
83-
logger.error("Root cannot be modified: " + e.getMessage());
84-
e.printStackTrace();
85-
return responseCode;
86-
} catch (Exception ex) {
87-
logger.info("******** caught generic exception");
88-
logger.error(ex.getMessage());
89-
}
90-
logger.error("******** fields check");
67+
9168
// check user fields. set only not empty fields
9269
if (user.getEmail() != null && !user.getEmail().isEmpty())
9370
u.setEmail(user.getEmail());
@@ -146,12 +123,11 @@ public int updateUserProfile(Principal principal,
146123
throw new UserPasswordConfirmationException(
147124
"Confirmation password value doesn't match.");
148125
}
149-
// logger.info("new pwd: " +
150-
// passwordModel.getConfirmPassword());RootNotModifiableException
151-
u.setPassword(passwordModel.getConfirmPassword());
126+
userService.selfChangePassword(u.getId(),passwordModel.getOldPassword(),passwordModel.getConfirmPassword());
152127
}
153128
logger.info("******** update user");
154-
userDao.update(u);
129+
130+
userService.selfUpdateUser(u);
155131
return responseCode;
156132
}
157133

@@ -160,68 +136,18 @@ public int forgotPassword(@RequestBody User user)
160136
throws RootNotModifiableException {
161137
int responseCode = 0;
162138

163-
if (userDao.isRootUser(user)) {
164-
logger.error("Root cannot be modified");
165-
responseCode = 1001;
166-
return responseCode;
167-
}
168-
User checked = userService.resolveUser(userDao.getByName(user
169-
.getUsername()));
170-
if (checked == null
171-
|| !checked.getEmail().toLowerCase()
172-
.equals(user.getEmail().toLowerCase())) {
173-
logger.error("No user can be found for this "
174-
+ "username/mail combination");
175-
responseCode = 1002;
176-
return responseCode;
177-
}
178-
179-
String message = "Dear " + getUserWelcome(checked) + ",\n\n"
180-
+ "Please follow this link to set a new password in the "
181-
+ cfgManager.getNameConfiguration().getShortName()
182-
+ " system:\n"
183-
+ cfgManager.getServerConfiguration().getExternalUrl()
184-
+ "#/home/r="
185-
+ userDao.computeUserCodeForPasswordReset(checked) + "\n\n"
186-
+ "For help requests please write to: "
187-
+ cfgManager.getSupportConfiguration().getMail() + "\n\n"
188-
+ "Kind regards.\n"
189-
+ cfgManager.getSupportConfiguration().getName() + ".\n"
190-
+ cfgManager.getServerConfiguration().getExternalUrl();
191-
192-
//logger.info("Forgot password mail message: " + message);
193-
String subject = "User password reset";
194-
195139
try {
196-
mailer.send(checked.getEmail(), null, null, subject, message);
140+
userService.forgotPassword ("#/home/r=", user);
197141
} catch (Exception e) {
198-
logger.error("Cannot send email to " + checked.getEmail(), e);
142+
logger.error("Reset password of user: " + user + " failed", e);
199143
responseCode = 1003;
200144
return responseCode;
201145
}
202-
logger.info("responseCode: " + responseCode);
146+
logger.info("responseCode: " + responseCode);
203147

204148
return responseCode;
205149
}
206150

207-
private void checkRoot(User user) throws RootNotModifiableException {
208-
if (userDao.isRootUser(user)) {
209-
logger.error("Root cannot be modified");
210-
throw new RootNotModifiableException("Root cannot be modified");
211-
}
212-
}
213-
214-
private String getUserWelcome(User u) {
215-
String firstname = u.getUsername();
216-
String lastname = "";
217-
if (u.getFirstname() != null && !u.getFirstname().trim().isEmpty()) {
218-
firstname = u.getFirstname();
219-
if (u.getLastname() != null && !u.getLastname().trim().isEmpty())
220-
lastname = " " + u.getLastname();
221-
}
222-
return firstname + lastname;
223-
}
224-
225151
/**
226152
* Uploaded products ids list of logged user
227153
*

core/src/main/java/fr/gael/dhus/api/stub/admin/AdminUserController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ public ResponseEntity<?> updateUser (@RequestBody UserData userData, @PathVaria
248248

249249
User user = new User ();
250250
user.setId (userid);
251+
user.setUsername(userData.getUsername());
251252
user.setFirstname (userData.getFirstname ());
252253
user.setLastname (userData.getLastname ());
253254
user.setAddress (userData.getAddress ());

0 commit comments

Comments
 (0)