19 package org.turro.contacts.profile;
21 import java.io.IOException;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import org.turro.string.Strings;
25 import org.turro.action.Actions;
26 import org.turro.action.Contacts;
27 import org.turro.annotation.ElephantPlugin;
28 import org.turro.auth.Authentication;
29 import org.turro.collections.KeyValueMap;
30 import org.turro.contacts.BusinessRelation;
31 import org.turro.contacts.Contact;
32 import org.turro.contacts.db.ContactsPU;
33 import org.turro.elephant.context.ElephantContext;
34 import org.turro.elephant.context.IConstructor;
35 import org.turro.elephant.direct.AbstractDirectEntityCtrl;
36 import org.turro.elephant.direct.DirectContent;
37 import org.turro.marker.ElephantMarker;
38 import org.turro.plugin.contacts.IContact;
52 super(
"widgets/profile",
"profile");
61 this.contact = contact;
65 public String
editLink(Object entity, String element) {
66 KeyValueMap kvm =
new KeyValueMap();
67 kvm.put(
"type",
"edit");
68 kvm.put(
"contact", contact.
getId());
69 kvm.put(
"element", element);
77 KeyValueMap kvm =
new KeyValueMap();
78 kvm.put(
"type",
"add");
79 kvm.put(
"contact", contact.
getId());
80 kvm.put(
"element",
"company");
85 KeyValueMap kvm =
new KeyValueMap();
86 kvm.put(
"type",
"add");
87 kvm.put(
"contact", contact.
getId());
88 kvm.put(
"element",
"center");
92 public String
publicLink(Object entity, String element) {
93 KeyValueMap kvm =
new KeyValueMap();
94 kvm.put(
"type",
"public");
95 kvm.put(
"contact", contact.
getId());
96 kvm.put(
"element", element);
103 public String
usersLink(Object entity, String element) {
104 KeyValueMap kvm =
new KeyValueMap();
105 kvm.put(
"type",
"users");
106 kvm.put(
"contact", contact.
getId());
107 kvm.put(
"element", element);
115 KeyValueMap kvm =
new KeyValueMap();
116 kvm.put(
"type",
"following");
117 kvm.put(
"contact", contact.
getId());
118 kvm.put(
"element", element);
126 KeyValueMap kvm =
new KeyValueMap();
127 kvm.put(
"type",
"private");
128 kvm.put(
"contact", contact.
getId());
129 kvm.put(
"element", element);
147 marker.
put(
"profile",
new Profile(contact,
true));
159 String type = map.get(
"type");
161 if(current !=
null) {
162 if(
"edit".equals(type)) {
164 if(map.containsKey(
"relation")) {
167 case CONTACT_COMPANY:
170 case CONTACT_LEARNINGCENTER:
174 }
else if(
"skills".equals(map.get(
"element"))) {
182 }
catch (IOException ex) {
185 }
else if(
"add".equals(type)) {
187 switch(map.get(
"element")) {
195 }
catch (IOException ex) {
202 if(
"public".equals(type)) {
204 }
else if(
"users".equals(type)) {
206 }
else if(
"following".equals(type)) {
209 pp.
setPolicy(relation ==
null ? current.
getContact() : relation, map.get(
"element"), policy);
213 constructor.
redirect(
"/user/profile");
214 }
catch (IOException ex) {
221 if(!Strings.isBlank(relationId)) {
223 if(relation.getId().equals(relationId))
return relation;
229 private BusinessRelation getRelation(IContact current, String relationId) {
231 for(BusinessRelation br : c.getBusinessRelations()) {
232 if(br.getId().equals(relationId)) {
static String createRightNowAction(String values)
static IContact getIContact()
static String logMsg(String msg)
String createRightNowURL(String values)
void setNeedsUser(boolean needsUser)
void addContainerId(ElephantMarker marker, boolean container)
Object put(Object key, Object value)
void setTemplate(String template)
void redirect(String path)