BrightSide Workbench Full Report + Source Code
LoadLogged.java
Go to the documentation of this file.
1
/*
2
* TurrĂ³ i Cutiller Foundation. License notice.
3
* Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Affero General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
14
*
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
package
org.turro.contacts.util;
19
20
import
javax.persistence.Query;
21
import
org.turro.contacts.Connector;
22
import
org.turro.contacts.Contact;
23
import
org.turro.contacts.db.ContactsPU;
24
import
org.turro.elephant.context.Application;
25
import
org.turro.elephant.security.IUser;
26
import
org.turro.jpa.Dao;
27
32
@Deprecated
33
public
class
LoadLogged
{
34
35
private
Contact
contact =
null
;
36
37
public
LoadLogged
(
Application
app) {
38
Dao
dao =
new
ContactsPU
();
39
try
{
40
Query q = dao.
createNamedQuery
(
"contactByLogin"
);
41
q.setParameter(
"login"
, app.
getConstructor
().
getUser
().
getId
());
42
contact = (
Contact
) q.getSingleResult();
43
if
(contact !=
null
) {
44
app.
getHttpServletRequest
().setAttribute(
"name"
, contact.
getName
());
45
app.
getHttpServletRequest
().setAttribute(
"email"
, getConnector(contact,
IUser
.
CONNECTOR_EMAIL
));
46
app.
getHttpServletRequest
().setAttribute(
"emailLogin"
, getConnector(contact,
IUser
.
CONNECTOR_EMAIL_LOGIN
));
47
}
48
}
finally
{
49
dao.
close
();
50
}
51
}
52
53
public
String
getId
() {
54
return
contact !=
null
? contact.
getId
() :
null
;
55
}
56
57
public
Contact
getContact
() {
58
return
contact;
59
}
60
61
private
String getConnector(
Contact
contact, String key) {
62
for
(
Connector
connector : contact.
getConnectors
()) {
63
if
(key.equalsIgnoreCase(connector.getDescription())) {
64
return
connector.getValue();
65
}
66
}
67
return
""
;
68
}
69
70
}
org.turro.contacts.Connector
Definition:
Connector.java:32
org.turro.contacts.Contact
Definition:
Contact.java:51
org.turro.contacts.Contact.getId
String getId()
Definition:
Contact.java:128
org.turro.contacts.Contact.getName
String getName()
Definition:
Contact.java:204
org.turro.contacts.Contact.getConnectors
Set< Connector > getConnectors()
Definition:
Contact.java:358
org.turro.contacts.db.ContactsPU
Definition:
ContactsPU.java:42
org.turro.contacts.util.LoadLogged
Definition:
LoadLogged.java:33
org.turro.contacts.util.LoadLogged.getId
String getId()
Definition:
LoadLogged.java:53
org.turro.contacts.util.LoadLogged.LoadLogged
LoadLogged(Application app)
Definition:
LoadLogged.java:37
org.turro.contacts.util.LoadLogged.getContact
Contact getContact()
Definition:
LoadLogged.java:57
org.turro.elephant.context.Application
Definition:
Application.java:47
org.turro.elephant.context.Application.getConstructor
IConstructor getConstructor()
Definition:
Application.java:204
org.turro.elephant.context.Application.getHttpServletRequest
abstract HttpServletRequest getHttpServletRequest()
org.turro.jpa.Dao
Definition:
Dao.java:52
org.turro.jpa.Dao.close
void close()
Definition:
Dao.java:71
org.turro.jpa.Dao.createNamedQuery
Query createNamedQuery(String name)
Definition:
Dao.java:66
org.turro.elephant.context.IConstructor.getUser
IUser getUser()
org.turro.elephant.security.IUser
Definition:
IUser.java:30
org.turro.elephant.security.IUser.CONNECTOR_EMAIL
static final String CONNECTOR_EMAIL
Definition:
IUser.java:32
org.turro.elephant.security.IUser.CONNECTOR_EMAIL_LOGIN
static final String CONNECTOR_EMAIL_LOGIN
Definition:
IUser.java:35
org.turro.elephant.security.IUser.getId
String getId()
TurroProjects
Public
BrightSide
contacts
src
main
java
org
turro
contacts
util
LoadLogged.java
Generated on Sun May 8 2022 11:23:27 for BrightSide by
1.9.1