Skip to content

Commit

Permalink
Switching operation result parameters/context/returns to string (work…
Browse files Browse the repository at this point in the history
… in progress)
  • Loading branch information
semancik committed Jul 26, 2017
1 parent 01a81e4 commit ff4db26
Show file tree
Hide file tree
Showing 32 changed files with 417 additions and 237 deletions.
2 changes: 1 addition & 1 deletion build-system/pom.xml
Expand Up @@ -74,7 +74,7 @@
<jdbc.postgres>9.4.1212.jre7</jdbc.postgres>
<jdbc.mariadb>1.5.5</jdbc.mariadb>
<jdbc.mysql>6.0.5</jdbc.mysql>
<wicket.version>7.6.0</wicket.version>
<wicket.version>7.9.0-SNAPSHOT</wicket.version>
<groovy.version>2.4.0</groovy.version>
<activiti-engine.version>5.22.0</activiti-engine.version>
<activiti-spring.version>5.22.0</activiti-spring.version>
Expand Down
Expand Up @@ -142,7 +142,7 @@ private void startPerformed(AjaxRequestTarget target) {
getScriptingService().evaluateExpression((ScriptingExpressionType) parsed, task, result);
result.recordStatus(OperationResultStatus.SUCCESS, "Action executed. Returned " + executionResult.getDataOutput().size() + " item(s). Console and data output available via 'Export to XML' function.");
result.addReturn("console", executionResult.getConsoleOutput());
result.addCollectionOfSerializablesAsReturn("data", executionResult.getDataOutput());
result.addArbitraryObjectCollectionAsReturn("data", executionResult.getDataOutput());
} catch (ScriptExecutionException|SchemaException|SecurityViolationException e) {
result.recordFatalError("Couldn't execute bulk action", e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute bulk action", e);
Expand Down
Expand Up @@ -17,9 +17,16 @@

import java.util.List;

import javax.xml.bind.JAXBElement;

import org.apache.wicket.core.util.objects.checker.IObjectChecker;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;

Expand All @@ -28,17 +35,46 @@
*
*/
public class MidPointObjectChecker implements IObjectChecker {

private static final Trace LOGGER = TraceManager.getTrace(MidPointObjectChecker.class);

private String label;

public MidPointObjectChecker() {
this(null);
}

public MidPointObjectChecker(String label) {
super();
this.label = label;
}

/* (non-Javadoc)
* @see org.apache.wicket.core.util.objects.checker.IObjectChecker#check(java.lang.Object)
*/
@SuppressWarnings("unchecked")
@Override
public Result check(Object object) {

if (label != null) {
LOGGER.info("CHECK: {}: {}", label, object);
}

if (object instanceof PrismObject<?>) {
return checkObject((PrismObject<? extends ObjectType>)object);
} else if (object instanceof ObjectType) {
return checkObject(((ObjectType)object).asPrismObject());
} else if (object instanceof Document) {
return new Result( Result.Status.FAILURE, "Storage of DOM documents not allowed: "+object);
// LOGGER.warn("Attempt to serialize DOM element: {}", DOMUtil.getQName((Element)object));
} else if (object instanceof Element) {
return new Result( Result.Status.FAILURE, "Storage of DOM elements not allowed: "+object);
// LOGGER.warn("Attempt to serialize DOM element: {}", DOMUtil.getQName((Element)object));

// JAXBElement: expression evaluator in expressions, it is JAXBElement even in prism objects
// } else if (object instanceof JAXBElement) {
// return new Result( Result.Status.FAILURE, "Storage of JAXB elements not allowed: "+object);
// LOGGER.warn("Attempt to serialize DOM element: {}", DOMUtil.getQName((Element)object));
}

return Result.SUCCESS;
Expand All @@ -48,6 +84,7 @@ public Result check(Object object) {

private <O extends ObjectType> Result checkObject(PrismObject<O> object) {

LOGGER.info("Serializing prism object: {}", object);
if (object.canRepresent(ResourceType.class)) {
return new Result( Result.Status.FAILURE, "Storage of ResourceType objects not allowed: "+object);
}
Expand Down
4 changes: 2 additions & 2 deletions gui/admin-gui/src/main/webapp/WEB-INF/web.xml
Expand Up @@ -98,8 +98,8 @@
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>configuration</param-name>
<!-- <param-value>development</param-value> -->
<param-value>deployment</param-value>
<param-value>development</param-value>
<!-- <param-value>deployment</param-value> -->
</init-param>
<init-param>
<param-name>applicationBean</param-name>
Expand Down
Expand Up @@ -262,8 +262,8 @@ public boolean isDefault() {
}

@Override
public ResourceType getResourceType() {
return structuralObjectClassDefinition.getResourceType();
public String getResourceOid() {
return structuralObjectClassDefinition.getResourceOid();
}

@Override
Expand Down Expand Up @@ -321,23 +321,23 @@ public boolean matches(ShadowType shadowType) {
return structuralObjectClassDefinition.matches(shadowType);
}

public <T extends CapabilityType> T getEffectiveCapability(Class<T> capabilityClass) {
return structuralObjectClassDefinition.getEffectiveCapability(capabilityClass);
public <T extends CapabilityType> T getEffectiveCapability(Class<T> capabilityClass, ResourceType resourceType) {
return structuralObjectClassDefinition.getEffectiveCapability(capabilityClass, resourceType);
}

@Override
public PagedSearchCapabilityType getPagedSearches() {
return structuralObjectClassDefinition.getPagedSearches();
public PagedSearchCapabilityType getPagedSearches(ResourceType resourceType) {
return structuralObjectClassDefinition.getPagedSearches(resourceType);
}

@Override
public boolean isPagedSearchEnabled() {
return structuralObjectClassDefinition.isPagedSearchEnabled();
public boolean isPagedSearchEnabled(ResourceType resourceType) {
return structuralObjectClassDefinition.isPagedSearchEnabled(resourceType);
}

@Override
public boolean isObjectCountingEnabled() {
return structuralObjectClassDefinition.isObjectCountingEnabled();
public boolean isObjectCountingEnabled(ResourceType resourceType) {
return structuralObjectClassDefinition.isObjectCountingEnabled(resourceType);
}

@Override
Expand Down Expand Up @@ -486,11 +486,6 @@ public void merge(ComplexTypeDefinition otherComplexTypeDef) {
throw new UnsupportedOperationException("TODO implement if needed");
}

@Override
public String getResourceNamespace() {
return structuralObjectClassDefinition.getResourceNamespace();
}

// TODO
@Override
public Class getTypeClassIfKnown() {
Expand Down
Expand Up @@ -45,7 +45,8 @@
*
*/
public class LayerRefinedObjectClassDefinitionImpl implements LayerRefinedObjectClassDefinition {

private static final long serialVersionUID = 1L;

private RefinedObjectClassDefinition refinedObjectClassDefinition;
private LayerType layer;
/**
Expand Down Expand Up @@ -247,7 +248,7 @@ public <X> LayerRefinedAttributeDefinition<X> findAttributeDefinition(@NotNull Q

@Override
public LayerRefinedAttributeDefinition<?> findAttributeDefinition(String elementLocalname) {
return findAttributeDefinition(new QName(getResourceNamespace(), elementLocalname)); // todo or should we use ns-less matching?
return LayerRefinedAttributeDefinitionImpl.wrap(refinedObjectClassDefinition.findAttributeDefinition(elementLocalname), layer);
}

@Override
Expand Down Expand Up @@ -291,8 +292,8 @@ public boolean containsAttributeDefinition(ItemPathType pathType) {
}

@Override
public ResourceType getResourceType() {
return refinedObjectClassDefinition.getResourceType();
public String getResourceOid() {
return refinedObjectClassDefinition.getResourceOid();
}

@Override
Expand Down Expand Up @@ -432,23 +433,23 @@ public AttributeFetchStrategyType getActivationFetchStrategy(QName propertyName)
}

@Override
public <T extends CapabilityType> T getEffectiveCapability(Class<T> capabilityClass) {
return (T) refinedObjectClassDefinition.getEffectiveCapability(capabilityClass);
public <T extends CapabilityType> T getEffectiveCapability(Class<T> capabilityClass, ResourceType resourceType) {
return (T) refinedObjectClassDefinition.getEffectiveCapability(capabilityClass, resourceType);
}

@Override
public PagedSearchCapabilityType getPagedSearches() {
return refinedObjectClassDefinition.getPagedSearches();
public PagedSearchCapabilityType getPagedSearches(ResourceType resourceType) {
return refinedObjectClassDefinition.getPagedSearches(resourceType);
}

@Override
public boolean isPagedSearchEnabled() {
return refinedObjectClassDefinition.isPagedSearchEnabled();
public boolean isPagedSearchEnabled(ResourceType resourceType) {
return refinedObjectClassDefinition.isPagedSearchEnabled(resourceType);
}

@Override
public boolean isObjectCountingEnabled() {
return refinedObjectClassDefinition.isObjectCountingEnabled();
public boolean isObjectCountingEnabled(ResourceType resourceType) {
return refinedObjectClassDefinition.isObjectCountingEnabled(resourceType);
}

@Override
Expand Down Expand Up @@ -564,11 +565,6 @@ public RefinedObjectClassDefinition deepClone(Map<QName, ComplexTypeDefinition>
return new LayerRefinedObjectClassDefinitionImpl(refinedObjectClassDefinition.deepClone(ctdMap), layer);
}

@Override
public String getResourceNamespace() {
return refinedObjectClassDefinition.getResourceNamespace();
}

@Override
public ResourceObjectReferenceType getBaseContext() {
return refinedObjectClassDefinition.getBaseContext();
Expand Down
Expand Up @@ -114,9 +114,7 @@ default Collection<? extends RefinedAttributeDefinition<?>> getAllIdentifiers()

ObjectClassComplexTypeDefinition getObjectClassDefinition();

ResourceType getResourceType();

String getResourceNamespace();
String getResourceOid();

boolean isDefault();

Expand Down Expand Up @@ -171,13 +169,13 @@ default PrismObject<ShadowType> createBlankShadow() {

//region Capabilities ========================================================

<T extends CapabilityType> T getEffectiveCapability(Class<T> capabilityClass);
<T extends CapabilityType> T getEffectiveCapability(Class<T> capabilityClass, ResourceType resourceType);

PagedSearchCapabilityType getPagedSearches();
PagedSearchCapabilityType getPagedSearches(ResourceType resourceType);

boolean isPagedSearchEnabled();
boolean isPagedSearchEnabled(ResourceType resourceType);

boolean isObjectCountingEnabled();
boolean isObjectCountingEnabled(ResourceType resourceType);

//endregion

Expand Down

0 comments on commit ff4db26

Please sign in to comment.