📄 edituserprofileaction.java
字号:
/*
* Copyright 2005-2008 WSO2, Inc. (http://wso2.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.solutions.identity.user.ui.action;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.StrutsStatics;
import org.wso2.solutions.identity.UserStore;
import org.wso2.solutions.identity.admin.ClaimsAdmin;
import org.wso2.solutions.identity.persistence.dataobject.ClaimDO;
import org.wso2.solutions.identity.user.ui.ClaimValue;
import org.wso2.solutions.identity.user.ui.UIConstants;
import org.wso2.solutions.identity.users.IdentityDefaultRealm;
import org.wso2.solutions.identity.users.IdentityUserStoreReader;
import com.opensymphony.xwork2.ActionContext;
public class EditUserProfileAction extends ManagedAction {
/**
*
*/
private static final long serialVersionUID = -6574411044104451252L;
private List<ClaimValue> claims = null;
private String profileName;
public String execute() throws Exception {
String userName = null;
HttpServletRequest request = null;
IdentityDefaultRealm realm = null;
IdentityUserStoreReader reader = null;
Map<String, String> userProperties = null;
request = (HttpServletRequest) ActionContext.getContext().get(
StrutsStatics.HTTP_REQUEST);
userName = (String) request.getSession().getAttribute(UIConstants.USER);
profileName = (String) request.getParameter("profileName");
if (profileName == null) {
profileName = (String) request.getSession().getAttribute(
"profileName");
}
if (userName == null) {
this.addErrorMessage(getText("invalid_user_login"));
return ERROR;
}
if (profileName == null || profileName.trim().length() == 0) {
this.addErrorMessage(getText("profile_name_required"));
return ERROR;
}
realm = (IdentityDefaultRealm) UserStore.getInstance().getRealm();
reader = realm.getIdentityUserStoreReader();
userProperties = reader.getUserProperties(userName, profileName);
if (userProperties == null || userProperties.isEmpty())
return ERROR;
ClaimsAdmin ClaimsAdmin = new ClaimsAdmin();
ClaimDO[] claimDOs = ClaimsAdmin.getAllMappedEnabledClaims();
claims = new ArrayList<ClaimValue>();
ClaimValue claimValue = null;
for (int i = 0; i < claimDOs.length; i++) {
if (claimDOs[i].isUserEditable()) {
claimValue = new ClaimValue();
claimValue.setClaim(claimDOs[i]);
claimValue.setClaimValue((String) userProperties
.get(claimDOs[i].getAttrId()));
claims.add(claimValue);
}
}
request.getSession().removeAttribute("profileName");
loadMessages();
return SUCCESS;
}
public List<ClaimValue> getClaims() {
return claims;
}
public void setClaims(List<ClaimValue> claims) {
this.claims = claims;
}
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -