Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into gui-devel
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jun 24, 2014
2 parents d147256 + c4787b0 commit ade4da5
Show file tree
Hide file tree
Showing 7 changed files with 427 additions and 27 deletions.
Expand Up @@ -36,6 +36,10 @@
<input type="checkbox" wicket:id="validateSchema">
<wicket:message key="pageDebugView.validateSchema"/>
</label>
<label class="col-lg-3 checkbox-inline">
<input type="checkbox" wicket:id="saveAsRaw">
<wicket:message key="pageDebugView.saveAsRaw"/>
</label>
</div>
</div>
</div>
Expand Down
Expand Up @@ -79,6 +79,7 @@ public class PageDebugView extends PageAdminConfiguration {
private IModel<ObjectViewDto> model;
private AceEditor editor;
private final IModel<Boolean> encrypt = new Model<Boolean>(true);
private final IModel<Boolean> saveAsRaw = new Model<>(true);
private final IModel<Boolean> validateSchema = new Model<Boolean>(false);

public PageDebugView() {
Expand Down Expand Up @@ -169,6 +170,13 @@ protected void onUpdate(AjaxRequestTarget target) {
}
});

mainForm.add(new AjaxCheckBox("saveAsRaw", saveAsRaw) {

@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});

mainForm.add(new AjaxCheckBox("validateSchema", validateSchema) {

@Override
Expand Down Expand Up @@ -280,8 +288,10 @@ public void savePerformed(AjaxRequestTarget target) {
}

Collection<ObjectDelta<? extends ObjectType>> deltas = (Collection) MiscUtil.createCollection(delta);
ModelExecuteOptions options = ModelExecuteOptions.createRaw();

ModelExecuteOptions options = new ModelExecuteOptions();
if (saveAsRaw.getObject()) {
options.setRaw(true);
}
if(!encrypt.getObject()) {
options.setNoCrypt(true);
}
Expand Down
Expand Up @@ -21,5 +21,6 @@ pageDebugView.options=Options
pageDebugView.edit=Edit
pageDebugView.encrypt=Protected by encryption
pageDebugView.validateSchema=Validate schema
pageDebugView.saveAsRaw=Save in raw mode
pageDebugView.message.cantSaveEmpty=Can't save empty xml.
pageDebugView.message.oidNotDefined=Object oid is not defined.
Expand Up @@ -257,7 +257,7 @@ public <T> T unmarshall(MapXNode xnode, Class<T> beanClass) throws SchemaExcepti
// This is the case of Collection<JAXBElement<?>>
// we need to exctract the specific type from the factory method
if (elementMethod == null){
throw new IllegalArgumentException("Wildcard type in JAXBElement field specification and no facotry method found for field "+fieldName+" in "+beanClass+", cannot determine collection type (inner type argument)");
throw new IllegalArgumentException("Wildcard type in JAXBElement field specification and no factory method found for field "+fieldName+" in "+beanClass+", cannot determine collection type (inner type argument)");
}
Type factoryMethodGenericReturnType = elementMethod.getGenericReturnType();
Type factoryMethodTypeArgument = getTypeArgument(factoryMethodGenericReturnType, "in factory method "+elementMethod+" return type for field "+fieldName+" in "+beanClass+", cannot determine collection type");
Expand Down Expand Up @@ -428,7 +428,7 @@ private <T extends SearchFilterType> T unmarshalSearchFilterType(MapXNode xmap,
return filterType;
}

private XNode marshalSearchFilterType(SearchFilterType value) throws SchemaException {
private MapXNode marshalSearchFilterType(SearchFilterType value) throws SchemaException {
if (value == null) {
return null;
}
Expand Down Expand Up @@ -624,32 +624,39 @@ public <T> XNode marshall(T bean) throws SchemaException {
return xProtected;
} else if (bean instanceof ItemPathType){
return marshalItemPathType((ItemPathType) bean);
} else if (bean instanceof SearchFilterType) {
return marshalSearchFilterType((SearchFilterType) bean);
} else if (bean instanceof RawType) {
return marshalRawValue((RawType) bean);
} else if (bean instanceof XmlAsStringType) {
return marshalXmlAsStringType((XmlAsStringType) bean);
}
else if (prismContext != null && prismContext.getSchemaRegistry().determineDefinitionFromClass(bean.getClass()) != null){
} else if (prismContext != null && prismContext.getSchemaRegistry().determineDefinitionFromClass(bean.getClass()) != null){
return prismContext.getXnodeProcessor().serializeObject(((Objectable)bean).asPrismObject()).getSubnode();
}

MapXNode xmap = new MapXNode();

Class<? extends Object> beanClass = bean.getClass();

//check for enums
if (beanClass.isEnum()){
String enumValue = XNodeProcessorUtil.findEnumFieldValue(beanClass, bean);
if (StringUtils.isEmpty(enumValue)){
enumValue = bean.toString();
}
QName fieldTypeName = inspector.findFieldTypeName(null, beanClass, DEFAULT_PLACEHOLDER);
return createPrimitiveXNode(enumValue, fieldTypeName, false);
// return marshallValue(bean, fieldTypeName, false);
}


// Note: SearchFilterType is treated below

Class<? extends Object> beanClass = bean.getClass();

//check for enums
if (beanClass.isEnum()){
String enumValue = XNodeProcessorUtil.findEnumFieldValue(beanClass, bean);
if (StringUtils.isEmpty(enumValue)){
enumValue = bean.toString();
}
QName fieldTypeName = inspector.findFieldTypeName(null, beanClass, DEFAULT_PLACEHOLDER);
return createPrimitiveXNode(enumValue, fieldTypeName, false);
}

MapXNode xmap;
if (bean instanceof SearchFilterType) {
// this hack is here because of c:ConditionalSearchFilterType - it is analogous to situation when unmarshalling this type (TODO: rework this in a nicer way)
xmap = marshalSearchFilterType((SearchFilterType) bean);
if (SearchFilterType.class.equals(bean.getClass())) {
return xmap; // nothing more to serialize; otherwise we continue, because in that case we deal with a subclass of SearchFilterType
}
} else {
xmap = new MapXNode();
}

XmlType xmlType = beanClass.getAnnotation(XmlType.class);
if (xmlType == null) {
throw new IllegalArgumentException("Cannot marshall "+beanClass+" it does not have @XmlType annotation");
Expand Down
Expand Up @@ -73,9 +73,7 @@


@XmlAccessorType(XmlAccessType.NONE) // we select getters/fields to expose via JAXB individually
@XmlType(name = "SearchFilterType", propOrder = {
"description",
"filterClause",
@XmlType(name = "SearchFilterType", propOrder = { // no prop order, because we serialize this class manually
})
public class SearchFilterType implements Serializable, Cloneable, Equals, HashCode, DebugDumpable, Revivable
{
Expand Down
3 changes: 3 additions & 0 deletions infra/schema/src/test/resources/common/resource-opendj.xml
Expand Up @@ -641,6 +641,9 @@ This is now the only account type that midPoint can work with. -->
</script>
</expression>
</q:equal>
<condition>
<value>true</value>
</condition>
</correlation>

<!-- Confirmation rule may be here, but as the search above will
Expand Down

0 comments on commit ade4da5

Please sign in to comment.