Skip to content

Commit

Permalink
Changing operation result params to string: it compiles!
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jul 27, 2017
1 parent f7c40ca commit 8b8ac97
Show file tree
Hide file tree
Showing 41 changed files with 246 additions and 269 deletions.
Expand Up @@ -39,6 +39,7 @@
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -100,23 +101,23 @@ public static OpResult getOpResult(PageBase page, OperationResult result){
}

if (result.getParams() != null) {
for (Map.Entry<String, Serializable> entry : result.getParams().entrySet()) {
for (Map.Entry<String, Collection<String>> entry : result.getParams().entrySet()) {
String paramValue = null;
Object value = entry.getValue();
if (value != null) {
paramValue = value.toString();
Collection<String> values = entry.getValue();
if (values != null) {
paramValue = values.toString();
}

opResult.getParams().add(new Param(entry.getKey(), paramValue));
}
}

if(result.getContext() != null){
for (Map.Entry<String, Serializable> entry : result.getContext().entrySet()) {
for (Map.Entry<String, Collection<String>> entry : result.getContext().entrySet()) {
String contextValue = null;
Object value = entry.getValue();
if (value != null) {
contextValue = value.toString();
Collection<String> values = entry.getValue();
if (values != null) {
contextValue = values.toString();
}

opResult.getContexts().add(new Context(entry.getKey(), contextValue));
Expand Down
Expand Up @@ -1083,8 +1083,10 @@ public static boolean isSuccessOrHandledError(OperationResult result) {
}

public static boolean isSuccessOrHandledError(OperationResultType resultType) {
OperationResult result = OperationResult.createOperationResult(resultType);
return isSuccessOrHandledError(result);
if (resultType == null) {
return false;
}
return resultType.getStatus() == OperationResultStatusType.SUCCESS || resultType.getStatus() == OperationResultStatusType.HANDLED_ERROR;
}

public static boolean isSuccessOrHandledErrorOrWarning(OperationResult result) {
Expand Down
Expand Up @@ -37,6 +37,8 @@
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -187,11 +189,15 @@ protected Iterator<SelectableBean<O>> handleNotSuccessOrHandledErrorInIterator(O

public SelectableBean<O> createDataObjectWrapper(O obj) {
SelectableBean<O> selectable = new SelectableBean<O>(obj);
if (!WebComponentUtil.isSuccessOrHandledError(obj.getFetchResult())){
selectable.setResult(obj.getFetchResult());
if (!WebComponentUtil.isSuccessOrHandledError(obj.getFetchResult())) {
try {
selectable.setResult(obj.getFetchResult());
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
}
for (O s : selected){
if (s.getOid().equals(obj.getOid())){
if (s.getOid().equals(obj.getOid())) {
selectable.setSelected(true);
}
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.column.InlineMenuable;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void setResult(OperationResult result) {
this.result = result;
}

public void setResult(OperationResultType resultType) {
public void setResult(OperationResultType resultType) throws SchemaException {
this.result = OperationResult.createOperationResult(resultType);
}

Expand Down
Expand Up @@ -84,6 +84,7 @@
import com.evolveum.midpoint.util.exception.PolicyViolationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -634,7 +635,12 @@ public IModel<String> getDataModel(IModel<SelectableBean<ShadowType>> rowModel)
@Override
public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ShadowType>> rowModel) {
OperationResultType resultType = getResult(rowModel);
OperationResult result = OperationResult.createOperationResult(resultType);
OperationResult result;
try {
result = OperationResult.createOperationResult(resultType);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}

OperationResultPanel body = new OperationResultPanel(
ResourceContentPanel.this.getPageBase().getMainPopupBodyId(),
Expand Down
Expand Up @@ -83,7 +83,7 @@ private void initResultsModel(String resourceOid) {
for (OperationResult subresult: result.getSubresults()) {
if (isConnectorResult(subresult)) {
ConnectorStruct connectorStruct = new ConnectorStruct();
connectorStruct.connectorName = (String) subresult.getParams().get(OperationResult.PARAM_NAME);
connectorStruct.connectorName = subresult.getParamSingle(OperationResult.PARAM_NAME);
if (connectorStruct.connectorName == null) {
connectorStruct.connectorName = "";
}
Expand Down
Expand Up @@ -25,6 +25,8 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -109,7 +111,11 @@ private ObjectWrapper<ShadowType> loadAccount(PageParameters parameters) {

ObjectWrapper wrapper = ObjectWrapperUtil.createObjectWrapper(null, null, account, ContainerStatus.MODIFYING, task, this);
OperationResultType fetchResult = account.getPropertyRealValue(ShadowType.F_FETCH_RESULT, OperationResultType.class);
wrapper.setFetchResult(OperationResult.createOperationResult(fetchResult));
try {
wrapper.setFetchResult(OperationResult.createOperationResult(fetchResult));
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
wrapper.setShowEmpty(false);
return wrapper;
}
Expand Down
Expand Up @@ -283,7 +283,7 @@ private void fillInParentTaskAttributes(TaskType taskType, TaskService taskServi
}
}

private void fillInOperationResultAttributes(TaskType taskType) {
private void fillInOperationResultAttributes(TaskType taskType) throws SchemaException {
opResult = new ArrayList<OperationResult>();
if (taskType.getResult() != null) {
taskOperationResult = OperationResult.createOperationResult(taskType.getResult());
Expand Down
Expand Up @@ -365,14 +365,13 @@ private EventResult validateObjectInternal(Element objectElement, OperationResul
Objectable objectType = null;
if (object != null) {
objectType = object.asObjectable();
objectResult.addContext(OperationResult.CONTEXT_OBJECT, object.toString());
}

if (verbose) {
LOGGER.trace("Processing OID " + objectType.getOid());
}

objectResult.addContext(OperationResult.CONTEXT_OBJECT, objectType);

validateObject(objectType, objectResult);

if (handler != null) {
Expand Down Expand Up @@ -517,12 +516,12 @@ void checkUri(Objectable object, String value, String propertyName, OperationRes
}

void error(String message, Objectable object, OperationResult subResult) {
subResult.addContext(OperationResult.CONTEXT_OBJECT, object);
subResult.addContext(OperationResult.CONTEXT_OBJECT, object.toString());
subResult.recordFatalError(message);
}

void error(String message, Objectable object, String propertyName, OperationResult subResult) {
subResult.addContext(OperationResult.CONTEXT_OBJECT, object);
subResult.addContext(OperationResult.CONTEXT_OBJECT, object.toString());
subResult.addContext(OperationResult.CONTEXT_ITEM, propertyName);
subResult.recordFatalError("<" + propertyName + ">: " + message);
}
Expand Down

0 comments on commit 8b8ac97

Please sign in to comment.