Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
#13 Re-Enable the edit of standard fields
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer committed Apr 4, 2014
1 parent f8f08f5 commit 44b0790
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

package org.echocat.adam.profile;

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditMyProfileAction;
import org.echocat.adam.profile.element.ElementModel;
Expand All @@ -32,6 +31,9 @@
import static org.apache.commons.lang3.StringUtils.join;
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.EMAIL_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.FULL_NAME_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.USER_NAME_ELEMENT_ID;

@SuppressWarnings("deprecation")
public class ExtendedEditMyProfileAction extends EditMyProfileAction {
Expand All @@ -53,11 +55,11 @@ public String doEdit() throws Exception {
private void updateFields(@Nonnull Profile profile) {
for (final Group group : profileModelProvider().get()) {
for (final ElementModel elementModel : group) {
if (!elementModel.isStandard()) {
final String id = elementModel.getId();
final String id = elementModel.getId();
if (!id.equals(FULL_NAME_ELEMENT_ID) && !id.equals(EMAIL_ELEMENT_ID) && !id.equals(USER_NAME_ELEMENT_ID)) {
final String[] plainValues = _parameters.get(id);
final String plainValue = plainValues != null && plainValues.length > 0 ? join(plainValues, ' ') : null;
if (plainValue != null && elementModel.getAccess().checkEdit(AuthenticatedUserThreadLocal.get(), profile).isEditAllowed()) {
if (plainValue != null && elementModel.getAccess().checkEdit(getAuthenticatedUser(), profile).isEditAllowed()) {
profile.setValue(elementModel, plainValue);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static org.apache.commons.lang3.StringUtils.join;
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.*;

public class ExtendedEditUserAction extends EditUserAction {

Expand All @@ -53,8 +54,8 @@ public String doEdit() throws Exception {
private void updateFields(@Nonnull Profile profile) {
for (final Group group : profileModelProvider().get()) {
for (final ElementModel elementModel : group) {
if (!elementModel.isStandard()) {
final String id = elementModel.getId();
final String id = elementModel.getId();
if (!id.equals(FULL_NAME_ELEMENT_ID) && !id.equals(EMAIL_ELEMENT_ID) && !id.equals(USER_NAME_ELEMENT_ID)) {
final String[] plainValues = _parameters.get(id);
final String plainValue = plainValues != null && plainValues.length > 0 ? join(plainValues, ' ') : null;
if (plainValue != null && elementModel.getAccess().checkEdit(AuthenticatedUserThreadLocal.get(), profile).isEditAllowed()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public interface ElementModel extends Localized {
@Nonnull
public static final String FULL_NAME_ELEMENT_ID = "fullName";
@Nonnull
public static final String USER_NAME_ELEMENT_ID = "username";
@Nonnull
public static final String EMAIL_ELEMENT_ID = "email";
@Nonnull
public static final String WEBSITE_ELEMENT_ID = "website";
Expand Down

0 comments on commit 44b0790

Please sign in to comment.