I get error in following lines.
error: incompatible types
required : java.util.Map.entry<java.lang.String,java.lang.String[]>
found :java.lang.Object
full code is below
package com.auth.actions;
public class SocialAuthSuccessAction extends Action {
final Log LOG = LogFactory.getLog(SocialAuthSuccessAction.class);
@Override
public ActionForward execute(final ActionMapping mapping,
final ActionForm form, final HttpServletRequest request,
final HttpServletResponse response) throws Exception {
AuthForm authForm = (AuthForm) form;
SocialAuthManager manager = null;
if (authForm.getSocialAuthManager() != null) {
manager = authForm.getSocialAuthManager();
}
if (manager != null) {
List<Contact> contactsList = new ArrayList<Contact>();
Profile profile = null;
try {
Map<String, String> paramsMap = new HashMap<String, String>();
for (Map.Entry<String, String[]> entry :request.getParameterMap().entrySet() ) { // error in this line!
String key = entry.getKey();
String values[] = entry.getValue();
paramsMap.put(key, values[0].toString()); // Only 1 value is
}
AuthProvider provider = manager.connect(paramsMap);
profile = provider.getUserProfile();
contactsList = provider.getContactList();
if (contactsList != null && contactsList.size() > 0) {
for (Contact p : contactsList) {
if (StringUtils.isEmpty(p.getFirstName())
&& StringUtils.isEmpty(p.getLastName())) {
p.setFirstName(p.getDisplayName());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("profile", profile);
request.setAttribute("contacts", contactsList);
return mapping.findForward("success");
}
// if provider null
return mapping.findForward("failure");
}
}
Please help
You need to cast request.getParameterMap()
to Map<String, String[]>
for (Map.Entry<String, String[]> entry :
((Map<String, String[]>)request.getParameterMap()).entrySet())
Try the following:
for (Object obj :request.getParameterMap().entrySet() ) {
Map.Entry<String, String[]> entry = (Map.Entry<String, String[]>) obj;
String key = entry.getKey();
String values[] = entry.getValue();
paramsMap.put(key, values[0].toString()); // Only 1 value is
}
Am not really sure this will work, anyway, you got the approach. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With