Skip to content

Commit

Permalink
Merge branch 'master' into access-certification
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 27, 2015
2 parents e975f16 + 1e3382d commit e6f204e
Show file tree
Hide file tree
Showing 150 changed files with 1,674 additions and 985 deletions.
19 changes: 19 additions & 0 deletions dist/testng-integration.xml
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015 Evolveum
~
~ 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.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="integration" parallel="false" verbose="1">
</suite>
19 changes: 19 additions & 0 deletions dist/testng-unit.xml
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015 Evolveum
~
~ 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.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="unit" parallel="false" verbose="1">
</suite>
Expand Up @@ -34,6 +34,7 @@
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.util.Selectable;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

Expand All @@ -51,6 +52,8 @@ public class ObjectDataProvider<W extends Serializable, T extends ObjectType>
private static final String OPERATION_SEARCH_OBJECTS = DOT_CLASS + "searchObjects";
private static final String OPERATION_COUNT_OBJECTS = DOT_CLASS + "countObjects";

private Set<T> selected = new HashSet<>();

private Class<T> type;
private Collection<SelectorOptions<GetOperationOptions>> options;

Expand All @@ -60,10 +63,46 @@ public ObjectDataProvider(Component component, Class<T> type) {
Validate.notNull(type);
this.type = type;
}


public List<T> getSelectedData() {
for (Serializable s : super.getAvailableData()){
if (s instanceof SelectableBean){
SelectableBean<T> selectable = (SelectableBean<T>) s;
if (selectable.isSelected()){
selected.add(selectable.getValue());
}
}
}
List<T> allSelected = new ArrayList<>();
allSelected.addAll(selected);
return allSelected;
}


@Override
public Iterator<W> internalIterator(long first, long count) {
LOGGER.trace("begin::iterator() from {} count {}.", new Object[]{first, count});

for (W available : getAvailableData()){
if (available instanceof SelectableBean){
SelectableBean<T> selectableBean = (SelectableBean<T>) available;
if (selectableBean.isSelected()){
selected.add(selectableBean.getValue());
}
}
}

for (W available : getAvailableData()){
if (available instanceof SelectableBean){
SelectableBean<T> selectableBean = (SelectableBean<T>) available;
if (!selectableBean.isSelected()){
if (selected.contains(selectableBean.getValue())){
selected.remove(selectableBean.getValue());
}
}
}
}

getAvailableData().clear();

OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
Expand Down Expand Up @@ -104,7 +143,11 @@ protected void handleNotSuccessOrHandledErrorInIterator(OperationResult result){
}

public W createDataObjectWrapper(PrismObject<T> obj) {
return (W) new SelectableBean<T>(obj.asObjectable());
SelectableBean<T> selectable = new SelectableBean<T>(obj.asObjectable());
if (selected.contains(obj.asObjectable())){
selectable.setSelected(true);
}
return (W) selectable ;
}

@Override
Expand Down
Expand Up @@ -197,13 +197,13 @@ public void onClick(AjaxRequestTarget target) {
@Override
public void onClick(AjaxRequestTarget target) {
DataTable table = getTable().getDataTable();
List<SelectableBean> availableData = ((ObjectDataProvider)table.getDataProvider()).getAvailableData();
List<T> selected = new ArrayList<>();
for (SelectableBean o : availableData){
if (o.isSelected()){
selected.add((T)o.getValue());
}
}
List<T> selected = ((ObjectDataProvider)table.getDataProvider()).getSelectedData();
// List<T> selected = new ArrayList<>();
// for (SelectableBean o : availableData){
// if (o.isSelected()){
// selected.add((T)o.getValue());
// }
// }
addPerformed(target, selected);
}
};
Expand Down
Expand Up @@ -65,6 +65,7 @@ public T getObject() {
return (T)WebMiscUtil.getOrigStringFromPoly(row.getLabel());
}
}
return (T)key;
}

return null;
Expand All @@ -82,11 +83,15 @@ public void setObject(T object) {
String label = (String) object;
String key;

for(LookupTableRowType row: lookupTable.getRow()){
if(label.equals(WebMiscUtil.getOrigStringFromPoly(row.getLabel()))){
key = row.getKey();
if (label != null && label.trim().equals("")){
PropertyResolver.setValue(expression, getInnermostModelOrObject(), "", prc);
} else {
for (LookupTableRowType row : lookupTable.getRow()) {
if (label.equals(WebMiscUtil.getOrigStringFromPoly(row.getLabel()))) {
key = row.getKey();

PropertyResolver.setValue(expression, getInnermostModelOrObject(), key, prc);
PropertyResolver.setValue(expression, getInnermostModelOrObject(), key, prc);
}
}
}
}
Expand Down
Expand Up @@ -529,12 +529,20 @@ private void loadParentOrgs(ObjectWrapper<T> wrapper, Task task, OperationResult
subResult);
LOGGER.trace("Loaded parent org with result {}",
new Object[] { subResult.getLastSubresult() });
} catch (AuthorizationException e) {
// This can happen if the user has permission to read parentOrgRef but it does not have
// the permission to read target org
// It is OK to just ignore it.
subResult.muteLastSubresultError();
LOGGER.debug("User {} does not have permission to read parent org unit {} (ignoring error)", task.getOwner().getName(), parentOrgRef.getOid());
} catch (Exception ex) {
subResult.recordWarning("Cannot load parent org " + parentOrgRef.getOid(), ex);
LOGGER.warn("Cannot load parent org {}: {}", parentOrgRef.getOid(), ex.getMessage(), ex);
}

wrapper.getParentOrgs().add(parentOrg);
if (parentOrg != null) {
wrapper.getParentOrgs().add(parentOrg);
}
}
subResult.computeStatus();
}
Expand Down Expand Up @@ -638,6 +646,10 @@ private <P extends ObjectType> List<FocusProjectionDto> loadProjectionWrappers(C

PrismObject<P> projection = WebModelUtils.loadObject(type, reference.getOid(), options, this,
task, subResult);
if (projection == null) {
// No access, just skip it
continue;
}
P projectionType = projection.asObjectable();

OperationResultType fetchResult = projectionType.getFetchResult();
Expand Down
Expand Up @@ -20,6 +20,8 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPropagationUserControlType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordChangeSecurityType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

/**
Expand All @@ -29,9 +31,13 @@ public class MyPasswordsDto implements Serializable {

public static final String F_ACCOUNTS = "accounts";
public static final String F_PASSWORD = "password";
public static final String F_OLD_PASSWORD = "oldPassword";

private List<PasswordAccountDto> accounts;
private ProtectedStringType password;
private CredentialsPropagationUserControlType propagation;
private PasswordChangeSecurityType passwordChangeSecurity;
private String oldPassword;

public List<PasswordAccountDto> getAccounts() {
if (accounts == null) {
Expand All @@ -47,4 +53,28 @@ public ProtectedStringType getPassword() {
public void setPassword(ProtectedStringType password) {
this.password = password;
}

public void setPropagation(CredentialsPropagationUserControlType propagation) {
this.propagation = propagation;
}

public CredentialsPropagationUserControlType getPropagation() {
return propagation;
}

public PasswordChangeSecurityType getPasswordChangeSecurity() {
return passwordChangeSecurity;
}

public void setPasswordChangeSecurity(PasswordChangeSecurityType passwordChangeSecurity) {
this.passwordChangeSecurity = passwordChangeSecurity;
}

public String getOldPassword() {
return oldPassword;
}

public void setOldPassword(String oldPassword) {
this.oldPassword = oldPassword;
}
}
Expand Up @@ -30,7 +30,7 @@ public class PasswordAccountDto extends Selectable implements Comparable<Passwor
private String oid;
private String displayName;
private String resourceName;
private String cssClass;
private String cssClass = "";
private boolean enabled;
private boolean passwordOutbound;
/**
Expand Down
Expand Up @@ -31,6 +31,10 @@ <h3><wicket:message key="pageTask.basic"/></h3>
<td><wicket:message key="pageTask.type"/></td>
<td><select class="form-control input-sm" wicket:id="category"/></td>
</tr>
<tr>
<td><wicket:message key="pageTask.focusType"/></td>
<td><select class="form-control input-sm" wicket:id="focusType"/></td>
</tr>
<tr>
<td><wicket:message key="pageTask.objectRef"/></td>
<td><select class="form-control input-sm" wicket:id="resource"/></td>
Expand Down
Expand Up @@ -86,7 +86,8 @@ public class PageTaskAdd extends PageAdminTasks {

private static final long serialVersionUID = 2317887071933841581L;

private static final String ID_DRY_RUN = "dryRun";
private static final String ID_DRY_RUN = "dryRun";
private static final String ID_FOCUS_TYPE = "focusType";
private static final String ID_KIND = "kind";
private static final String ID_INTENT = "intent";
private static final String ID_OBJECT_CLASS = "objectClass";
Expand Down Expand Up @@ -206,6 +207,41 @@ protected void onUpdate(AjaxRequestTarget target) {
resource.setOutputMarkupId(true);
mainForm.add(resource);

final DropDownChoice focusType = new DropDownChoice<>(ID_FOCUS_TYPE,
new PropertyModel<QName>(model, TaskAddDto.F_FOCUS_TYPE),
new AbstractReadOnlyModel<List<QName>>() {

@Override
public List<QName> getObject() {
return createFocusTypeList();
}
}, new IChoiceRenderer<QName>() {

@Override
public Object getDisplayValue(QName object) {
if (FocusType.COMPLEX_TYPE.equals(object)){
return "All (including role,orgs,users)";
}
return object.getLocalPart();
}

@Override
public String getIdValue(QName object, int index) {
return Integer.toString(index);
}
});
focusType.setOutputMarkupId(true);
focusType.add(new VisibleEnableBehaviour(){

@Override
public boolean isEnabled() {
TaskAddDto dto = model.getObject();
return TaskCategory.RECOMPUTATION.equals(dto.getCategory());
}
});
mainForm.add(focusType);


final DropDownChoice kind = new DropDownChoice<>(ID_KIND,
new PropertyModel<ShadowKindType>(model, TaskAddDto.F_KIND),
new AbstractReadOnlyModel<List<ShadowKindType>>() {
Expand Down Expand Up @@ -305,6 +341,7 @@ protected void onUpdate(AjaxRequestTarget target) {
target.add(intent);
target.add(kind);
target.add(objectClass);
target.add(focusType);
}
});
type.setRequired(true);
Expand Down Expand Up @@ -554,6 +591,17 @@ private List<ShadowKindType> createShadowKindTypeList(){

return kindList;
}

private List<QName> createFocusTypeList(){
List<QName> focusTypeList = new ArrayList<>();

focusTypeList.add(UserType.COMPLEX_TYPE);
focusTypeList.add(RoleType.COMPLEX_TYPE);
focusTypeList.add(OrgType.COMPLEX_TYPE);
focusTypeList.add(FocusType.COMPLEX_TYPE);

return focusTypeList;
}

private List<TaskAddResourcesDto> createResourceList() {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
Expand Down Expand Up @@ -679,6 +727,16 @@ private TaskType createTask(TaskAddDto dto) throws SchemaException {
dryRun.setRealValue(true);
}

if (dto.getFocusType() != null){

PrismObject<TaskType> prismTask = task.asPrismObject();

ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE);
PrismProperty focusType = prismTask.findOrCreateProperty(path);
focusType.setRealValue(dto.getFocusType());

}

if(dto.getKind() != null){
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND);
Expand Down

0 comments on commit e6f204e

Please sign in to comment.