Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jan 23, 2017
2 parents e786602 + 50c0955 commit e8ed6a1
Show file tree
Hide file tree
Showing 20 changed files with 288 additions and 78 deletions.
Expand Up @@ -127,7 +127,7 @@
<div class="pull-right hidden-xs" wicket:id="version">
<b><wicket:message key="PageTemplate.version"/></b> <wicket:message key="pageBase.midPointVersion"/>
</div>
<wicket:message key="PageTemplate.copy"/>
<div wicket:id="subscriptionMessage"/>
</footer>
</div>

Expand Down
Expand Up @@ -181,9 +181,11 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private static final String ID_BC_NAME = "bcName";
private static final String ID_MAIN_POPUP = "mainPopup";
private static final String ID_MAIN_POPUP_BODY = "popupBody";
private static final String ID_SUBSCRIPTION_MESSAGE = "subscriptionMessage";
private static final String ID_LOGO = "logo";

private static final String OPERATION_GET_SYSTEM_CONFIG = DOT_CLASS + "getSystemConfiguration";
private static final String OPERATION_GET_DEPLOYMENT_INFORMATION = DOT_CLASS + "getDeploymentInformation";

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

Expand Down Expand Up @@ -620,6 +622,23 @@ public boolean isVisible() {
});
add(version);

Label subscriptionMessage = new Label(ID_SUBSCRIPTION_MESSAGE, createStringResource("PageBase.subscriptionMessage"));
subscriptionMessage.setOutputMarkupId(true);
subscriptionMessage.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
String subscriptionId = getSubscriptionId();
if (StringUtils.isEmpty(subscriptionId)){
return true;
}
//TODO temporary condition is to check if subscriptionId contains any number
return !subscriptionId.matches(".*\\d.*");
}
});
add(subscriptionMessage);

WebMarkupContainer feedbackContainer = new WebMarkupContainer(ID_FEEDBACK_CONTAINER);
feedbackContainer.setOutputMarkupId(true);
add(feedbackContainer);
Expand Down Expand Up @@ -1532,6 +1551,20 @@ public AdminGuiConfigurationType loadAdminGuiConfiguration() {
}
}

public DeploymentInformationType loadDeploymentInformationType() {
DeploymentInformationType deploymentInformationType = null;
OperationResult result = new OperationResult(OPERATION_GET_DEPLOYMENT_INFORMATION);
try {
deploymentInformationType = getModelInteractionService().getDeploymentInformationConfiguration(result);
LOGGER.trace("Deployment information : {}", deploymentInformationType);
result.recordSuccess();
} catch(Exception ex){
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load deployment information", ex);
result.recordFatalError("Couldn't load deployment information.", ex);
}
return deploymentInformationType;
}

public Breadcrumb redirectBack() {
List<Breadcrumb> breadcrumbs = getBreadcrumbs();
if (breadcrumbs.size() < 2) {
Expand Down Expand Up @@ -1668,4 +1701,12 @@ public Breadcrumb getLastBreadcrumb() {
public void clearBreadcrumbs() {
getBreadcrumbs().clear();
}

private String getSubscriptionId(){
DeploymentInformationType deploymentInformationType = loadDeploymentInformationType();
if (deploymentInformationType == null){
return null;
}
return deploymentInformationType.getSubscriptionIdentifier();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -627,7 +627,7 @@ private String formatItemInfo(ResourceItemDefinitionType item, ItemPathType ref,
if (outbound != null) {
sb.append(" | ").append(getString("SchemaHandlingStep.out")).append(": ");
boolean first = true;
for (MappingSourceDeclarationType source : outbound.getSource()) {
for (VariableBindingDefinitionType source : outbound.getSource()) {
if (source != null) {
if (first) first = false; else sb.append(", ");
sb.append(formatPath(source.getPath()));
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -117,7 +117,7 @@ private void prepareActivationObject(ResourceActivationDefinitionType activation
} else {
for(MappingType mapping: activation.getExistence().getInbound()){
if(mapping.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(EXISTENCE_DEFAULT_SOURCE));
mapping.getSource().add(source);
}
Expand All @@ -129,23 +129,23 @@ private void prepareActivationObject(ResourceActivationDefinitionType activation
} else {
for(MappingType outbound: activation.getAdministrativeStatus().getOutbound()){
if(outbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(ADM_STATUS_OUT_SOURCE_DEFAULT));
outbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(ADM_STATUS_OUT_TARGET_DEFAULT));
outbound.setTarget(target);
}
}

for(MappingType inbound: activation.getAdministrativeStatus().getInbound()){
if(inbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(ADM_STATUS_IN_SOURCE_DEFAULT));
inbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(ADM_STATUS_IN_TARGET_DEFAULT));
inbound.setTarget(target);
}
Expand All @@ -157,23 +157,23 @@ private void prepareActivationObject(ResourceActivationDefinitionType activation
} else {
for(MappingType outbound: activation.getValidFrom().getOutbound()){
if(outbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(VALID_FROM_OUT_SOURCE_DEFAULT));
outbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(VALID_FROM_OUT_TARGET_DEFAULT));
outbound.setTarget(target);
}
}

for(MappingType inbound: activation.getValidFrom().getInbound()){
if(inbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(VALID_FROM_IN_SOURCE_DEFAULT));
inbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(VALID_FROM_IN_TARGET_DEFAULT));
inbound.setTarget(target);
}
Expand All @@ -185,23 +185,23 @@ private void prepareActivationObject(ResourceActivationDefinitionType activation
} else {
for(MappingType outbound: activation.getValidTo().getOutbound()){
if(outbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(VALID_TO_OUT_SOURCE_DEFAULT));
outbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(VALID_TO_OUT_TARGET_DEFAULT));
outbound.setTarget(target);
}
}

for(MappingType inbound: activation.getValidTo().getInbound()){
if(inbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(VALID_TO_IN_SOURCE_DEFAULT));
inbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(VALID_TO_IN_TARGET_DEFAULT));
inbound.setTarget(target);
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -83,7 +83,7 @@ public MappingTypeDto(MappingType mapping, PrismContext prismContext){

oldMappingObject = mappingObject.clone();

for(MappingSourceDeclarationType mappingSource: mappingObject.getSource()){
for(VariableBindingDefinitionType mappingSource: mappingObject.getSource()){
if(mappingSource.getPath() != null && mappingSource.getPath().getItemPath() != null){
source.add(mappingSource.getPath().getItemPath().toString());
}
Expand Down Expand Up @@ -139,21 +139,21 @@ public MappingType prepareDtoToSave(PrismContext prismContext) throws SchemaExce
}

if(target != null){
MappingTargetDeclarationType mappingTarget = new MappingTargetDeclarationType();
VariableBindingDefinitionType mappingTarget = new VariableBindingDefinitionType();
mappingTarget.setPath(new ItemPathType(target));
mappingObject.setTarget(mappingTarget);
} else {
mappingObject.setTarget(null);
}

mappingObject.getSource().clear();
List<MappingSourceDeclarationType> mappingSourceList = new ArrayList<>();
List<VariableBindingDefinitionType> mappingSourceList = new ArrayList<>();
for(String s: source){
if(s == null){
continue;
}

MappingSourceDeclarationType mappingSource = new MappingSourceDeclarationType();
VariableBindingDefinitionType mappingSource = new VariableBindingDefinitionType();
mappingSource.setPath(new ItemPathType(s));
mappingSourceList.add(mappingSource);
}
Expand Down Expand Up @@ -346,7 +346,7 @@ public static String createMappingLabel(MappingType mapping, Trace LOGGER, Prism
}

if(!mapping.getSource().isEmpty()){
for(MappingSourceDeclarationType source: mapping.getSource()){
for(VariableBindingDefinitionType source: mapping.getSource()){
if(source.getPath() != null && source.getPath().getItemPath() != null
&& source.getPath().getItemPath().getSegments() != null){

Expand All @@ -367,7 +367,7 @@ public static String createMappingLabel(MappingType mapping, Trace LOGGER, Prism
sb.append("->");

if (mapping.getTarget() != null) {
MappingTargetDeclarationType target = mapping.getTarget();
VariableBindingDefinitionType target = mapping.getTarget();
if (target.getPath() != null && !ItemPath.isNullOrEmpty(target.getPath().getItemPath())) {
List<ItemPathSegment> segments = target.getPath().getItemPath().getSegments();
sb.append(segments.get(segments.size() - 1));
Expand Down
Expand Up @@ -1145,6 +1145,7 @@ PageBase.button.update=Update
PageBase.clearCssCache=Clear less/js cache
pageBase.midPointVersion=${pom.version}, ${git.describe}
pageBase.unknownBuildNumber=unknown
PageBase.subscriptionMessage=Non-subscription.
PageBulkAction.async=Asynchronous
PageBulkAction.button.start=Start
PageBulkAction.message.emptyString=Inserted bulk action is empty. Please provide non-empty script.
Expand Down
Expand Up @@ -241,7 +241,7 @@ private XNode parseJsonObject(JsonParsingContext ctx) throws SchemaException, IO
}

final MapXNode map = new MapXNode();
XNode explicitValue = null;
XNode wrappedValue = null;
boolean defaultNamespaceDefined = false;
QNameUtil.QNameInfo currentFieldNameInfo = null;
for (;;) {
Expand Down Expand Up @@ -278,10 +278,10 @@ private XNode parseJsonObject(JsonParsingContext ctx) throws SchemaException, IO
}
elementNameInfo = QNameUtil.uriToQNameInfo(getStringValue(valueXNode, currentFieldNameInfo, ctx), true);
} else if (isValue(currentFieldNameInfo.name)) {
if (explicitValue != null) {
if (wrappedValue != null) {
ctx.prismParsingContext.warnOrThrow(LOGGER, "Value ('" + PROP_VALUE + "') defined more than once at " + getPositionSuffix(ctx));
}
explicitValue = valueXNode;
wrappedValue = valueXNode;
}
} else {
Map.Entry<QName, XNode> entry = map.putReturningEntry(currentFieldNameInfo.name, valueXNode);
Expand All @@ -294,22 +294,37 @@ private XNode parseJsonObject(JsonParsingContext ctx) throws SchemaException, IO
}
// Return either map or primitive value (in case of @type/@value)
XNode rv;
if (explicitValue != null) {
if (wrappedValue != null) {
if (!map.isEmpty()) {
ctx.prismParsingContext.warnOrThrow(LOGGER, "Both '" + PROP_VALUE + "' and regular content present at " + getPositionSuffix(ctx));
rv = map;
} else {
rv = explicitValue;
rv = wrappedValue;
}
} else {
rv = map;
}
// TODO beware, explicitValue can have conflicting type/element name info ...
if (typeName != null) {
if (wrappedValue != null && wrappedValue.getTypeQName() != null && !wrappedValue.getTypeQName().equals(typeName)) {
ctx.prismParsingContext.warnOrThrow(LOGGER, "Conflicting type names for '" + PROP_VALUE
+ "' (" + wrappedValue.getTypeQName() + ") and regular content (" + typeName + ") present at "
+ getPositionSuffix(ctx));
}
rv.setTypeQName(typeName);
rv.setExplicitTypeDeclaration(true);
}
if (elementNameInfo != null) {
if (wrappedValue != null && wrappedValue.getElementName() != null) {
boolean wrappedValueElementNoNamespace = ctx.noNamespaceElementNames.containsKey(wrappedValue);
if (!wrappedValue.getElementName().equals(elementNameInfo.name)
|| wrappedValueElementNoNamespace != elementNameInfo.explicitEmptyNamespace) {
ctx.prismParsingContext.warnOrThrow(LOGGER, "Conflicting element names for '" + PROP_VALUE
+ "' (" + wrappedValue.getElementName() + "; no NS=" + wrappedValueElementNoNamespace
+ ") and regular content (" + elementNameInfo.name + "; no NS="
+ elementNameInfo.explicitEmptyNamespace + ") present at "
+ getPositionSuffix(ctx));
}
}
rv.setElementName(elementNameInfo.name);
if (elementNameInfo.explicitEmptyNamespace) {
ctx.noNamespaceElementNames.put(rv, null);
Expand Down Expand Up @@ -524,7 +539,7 @@ private void serializeFromNull(JsonSerializationContext ctx) throws IOException
private void writeAuxiliaryInformation(XNode xnode, JsonSerializationContext ctx) throws IOException {
QName elementName = xnode.getElementName();
if (elementName != null) {
ctx.generator.writeObjectField(PROP_ELEMENT, elementName);
ctx.generator.writeObjectField(PROP_ELEMENT, createElementNameUri(elementName, ctx));
}
QName typeName = getExplicitType(xnode);
if (typeName != null) {
Expand All @@ -547,9 +562,9 @@ private void serializeFromMap(MapXNode map, JsonSerializationContext ctx) throws
writeInlineTypeIfNeeded(map, ctx);
ctx.generator.writeStartObject();
resetInlineTypeIfPossible(ctx);
writeAuxiliaryInformation(map, ctx);
String oldDefaultNamespace = ctx.currentNamespace;
generateNsDeclarationIfNeeded(map, ctx);
writeAuxiliaryInformation(map, ctx);
for (Entry<QName,XNode> entry : map.entrySet()) {
if (entry.getValue() == null) {
continue;
Expand Down Expand Up @@ -587,8 +602,10 @@ private String determineNewCurrentNamespace(MapXNode map, JsonSerializationConte
if (childNs.equals(ctx.currentNamespace)) {
return ctx.currentNamespace; // found existing => continue with it
}
Integer c = counts.get(childNs);
counts.put(childNs, c != null ? c+1 : 1);
increaseCounter(counts, childNs);
}
if (map.getElementName() != null && QNameUtil.hasNamespace(map.getElementName())) {
increaseCounter(counts, map.getElementName().getNamespaceURI());
}
// otherwise, take the URI that occurs the most in the map
Entry<String,Integer> max = null;
Expand All @@ -600,6 +617,11 @@ private String determineNewCurrentNamespace(MapXNode map, JsonSerializationConte
return max != null ? max.getKey() : null;
}

private void increaseCounter(Map<String, Integer> counts, String childNs) {
Integer c = counts.get(childNs);
counts.put(childNs, c != null ? c+1 : 1);
}

private String createKeyUri(Entry<QName,XNode> entry, JsonSerializationContext ctx) {
QName key = entry.getKey();
if (namespaceMatch(ctx.currentNamespace, key.getNamespaceURI())) {
Expand All @@ -611,6 +633,14 @@ private String createKeyUri(Entry<QName,XNode> entry, JsonSerializationContext c
}
}

private String createElementNameUri(QName elementName, JsonSerializationContext ctx) {
if (namespaceMatch(ctx.currentNamespace, elementName.getNamespaceURI())) {
return elementName.getLocalPart();
} else {
return QNameUtil.qNameToUri(elementName, StringUtils.isNotEmpty(ctx.currentNamespace));
}
}

private boolean isAttribute(XNode node) {
return node instanceof PrimitiveXNode && ((PrimitiveXNode) node).isAttribute();
}
Expand Down

0 comments on commit e8ed6a1

Please sign in to comment.