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
Erik Suta committed Feb 19, 2015
2 parents a19c277 + ea88d84 commit 029ec96
Show file tree
Hide file tree
Showing 20 changed files with 531 additions and 45 deletions.
Expand Up @@ -72,6 +72,13 @@ <h3><wicket:message key="PageAbout.title.repository.additional"/></h3>
<td><span wicket:id="detailValue" /></td>
</tr>
</table>
<h2><wicket:message key="PageAbout.title.provisioning"/></h2>
<table class="table">
<tr wicket:id="provisioningAdditionalDetails">
<td><span wicket:id="provisioningDetailName" /></td>
<td><span wicket:id="provisioningDetailValue" /></td>
</tr>
</table>
</div>
</div>
</div>
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.web.page.admin.configuration;

import com.evolveum.midpoint.schema.LabeledString;
import com.evolveum.midpoint.schema.ProvisioningDiag;
import com.evolveum.midpoint.schema.RepositoryDiag;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
Expand Down Expand Up @@ -61,6 +62,7 @@ public class PageAbout extends PageAdminConfiguration {
private static final String OPERATION_TEST_REPOSITORY = DOT_CLASS + "testRepository";
private static final String OPERATION_TEST_REPOSITORY_CHECK_ORG_CLOSURE = DOT_CLASS + "testRepositoryCheckOrgClosure";
private static final String OPERATION_GET_REPO_DIAG = DOT_CLASS + "getRepoDiag";
private static final String OPERATION_GET_PROVISIONING_DIAG = DOT_CLASS + "getProvisioningDiag";

private static final String ID_REVISION = "revision";
private static final String ID_PROPERTY = "property";
Expand All @@ -78,13 +80,17 @@ public class PageAbout extends PageAdminConfiguration {
private static final String ID_ADDITIONAL_DETAILS = "additionalDetails";
private static final String ID_DETAIL_NAME = "detailName";
private static final String ID_DETAIL_VALUE = "detailValue";
private static final String ID_PROVISIONING_ADDITIONAL_DETAILS = "provisioningAdditionalDetails";
private static final String ID_PROVISIONING_DETAIL_NAME = "provisioningDetailName";
private static final String ID_PROVISIONING_DETAIL_VALUE = "provisioningDetailValue";
private static final String ID_JVM_PROPERTIES = "jvmProperties";

private static final String[] PROPERTIES = new String[]{"file.separator", "java.class.path",
"java.home", "java.vendor", "java.vendor.url", "java.version", "line.separator", "os.arch",
"os.name", "os.version", "path.separator", "user.dir", "user.home", "user.name"};

private IModel<RepositoryDiag> repoDiagModel;
private IModel<ProvisioningDiag> provisioningDiagModel;

public PageAbout() {
repoDiagModel = new LoadableModel<RepositoryDiag>(false) {
Expand All @@ -94,6 +100,13 @@ protected RepositoryDiag load() {
return loadRepoDiagModel();
}
};
provisioningDiagModel = new LoadableModel<ProvisioningDiag>(false) {

@Override
protected ProvisioningDiag load() {
return loadProvisioningDiagModel();
}
};
initLayout();
}

Expand Down Expand Up @@ -144,6 +157,24 @@ protected void populateItem(ListItem<LabeledString> item) {
};
add(additionalDetails);

ListView<LabeledString> provisioningAdditionalDetails = new ListView<LabeledString>(ID_PROVISIONING_ADDITIONAL_DETAILS,
new PropertyModel<List<? extends LabeledString>>(provisioningDiagModel, "additionalDetails")) {

@Override
protected void populateItem(ListItem<LabeledString> item) {
LabeledString labeledString = item.getModelObject();

Label property = new Label(ID_PROVISIONING_DETAIL_NAME, labeledString.getLabel());
property.setRenderBodyOnly(true);
item.add(property);

Label value = new Label(ID_PROVISIONING_DETAIL_VALUE, labeledString.getData());
value.setRenderBodyOnly(true);
item.add(value);
}
};
add(provisioningAdditionalDetails);

Label jvmProperties = new Label(ID_JVM_PROPERTIES, new LoadableModel<String>(false) {

@Override
Expand Down Expand Up @@ -223,6 +254,27 @@ private RepositoryDiag loadRepoDiagModel() {
return diag;
}

private ProvisioningDiag loadProvisioningDiagModel() {
OperationResult result = new OperationResult(OPERATION_GET_PROVISIONING_DIAG);
ProvisioningDiag diag = null;
try {
Task task = createSimpleTask(OPERATION_GET_PROVISIONING_DIAG);
diag = getModelDiagnosticService().getProvisioningDiag(task, result);

result.recordSuccessIfUnknown();
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "Couldn't get provisioning diagnostics", ex);
result.recordFatalError("Couldn't get provisioning diagnostics.", ex);
}
result.recomputeStatus();

if (!WebMiscUtil.isSuccessOrHandledError(result)) {
showResult(result);
}

return diag;
}

private IModel<List<SystemItem>> getItems() {
return new LoadableModel<List<SystemItem>>(false) {

Expand Down
Expand Up @@ -25,6 +25,7 @@ PageAbout.title.basic=Basic
PageAbout.title.systemProperties=System properties
PageAbout.title.repository=Repository
PageAbout.title.repository.additional=Additional details
PageAbout.title.provisioning=Provisioning
PageAbout.title.jvmProperties=JVM properties
PageAbout.repoDiag.implementationShortName=Implementation name
PageAbout.repoDiag.implementationDescription=Implementation description
Expand Down
Expand Up @@ -891,11 +891,12 @@ public FilterTranslator<Filter> createFilterTranslator(ObjectClass objectClass,
* {@inheritDoc}
*/
public void executeQuery(ObjectClass objectClass, Filter query, ResultsHandler handler, OperationOptions options) {
log.info("executeQuery::begin");
log.info("executeQuery({0},{1},{2},{3})", objectClass, query, handler, options);
validate(objectClass);
notNull(handler, "Results handled object can't be null.");

Collection<String> attributesToGet = getAttrsToGet(options);
log.ok("attributesToGet={0}", attributesToGet);

try {
if (ObjectClass.ACCOUNT.is(objectClass.getObjectClassValue())) {
Expand Down Expand Up @@ -1139,7 +1140,7 @@ private ConnectorObject convertToConnectorObject(DummyAccount account, Collectio

// Password is not returned by default (hardcoded ICF specification)
if (account.getPassword() != null && configuration.getReadablePassword() &&
attributesToGet.contains(OperationalAttributes.PASSWORD_NAME)) {
attributesToGet != null && attributesToGet.contains(OperationalAttributes.PASSWORD_NAME)) {
GuardedString gs = new GuardedString(account.getPassword().toCharArray());
builder.addAttribute(OperationalAttributes.PASSWORD_NAME,gs);
}
Expand Down
Expand Up @@ -145,6 +145,17 @@ public RefinedObjectClassDefinition getRefinedDefinition(ShadowKindType kind, Co
}

public RefinedObjectClassDefinition getRefinedDefinition(QName objectClassName) {
for (Definition def: definitions) {
if ((def instanceof RefinedObjectClassDefinition)
&& ((RefinedObjectClassDefinition)def).isDefault()
&& (QNameUtil.match(def.getTypeName(), objectClassName))) {
//&& (def.getTypeName().equals(objectClassName))) {
return (RefinedObjectClassDefinition)def;
}
}
// No default for this object class, so just use the first one.
// This is not strictly correct .. but it is a "compatible bug" :-)
// TODO: remove this in next major revision
for (Definition def: definitions) {
if ((def instanceof RefinedObjectClassDefinition)
&& (QNameUtil.match(def.getTypeName(), objectClassName))) {
Expand Down Expand Up @@ -175,6 +186,14 @@ public RefinedObjectClassDefinition findRefinedDefinitionByObjectClassQName(Shad
if (objectClass == null) {
return getDefaultRefinedDefinition(kind);
}
for (RefinedObjectClassDefinition acctDef: getRefinedDefinitions(kind)) {
if (acctDef.isDefault() && QNameUtil.match(acctDef.getObjectClassDefinition().getTypeName(), objectClass)) {
return acctDef;
}
}
// No default for this object class, so just use the first one.
// This is not strictly correct .. but it is a "compatible bug" :-)
// TODO: remove this in next major revision
for (RefinedObjectClassDefinition acctDef: getRefinedDefinitions(kind)) {
if (QNameUtil.match(acctDef.getObjectClassDefinition().getTypeName(), objectClass)) {
return acctDef;
Expand Down
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2010-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.
*/
package com.evolveum.midpoint.schema;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* DTO that contains provisioning run-time configuration and diagnostic information.
*
* All information contained in this class are meant for information purposes only.
* They are not meant to be used by a machine or algorithm, they are meant to be displayed
* to a human user.
*
* @author Radovan Semancik
* @author mederly
*
*/
public class ProvisioningDiag implements Serializable {

// TODO some information about connector frameworks used etc

/**
* Additional repository information that do not fit the structured data above.
* May be anything that the implementations thinks is important.
*
* Currently used as a hack to display connId version
*/
private List<LabeledString> additionalDetails = new ArrayList<>();

public List<LabeledString> getAdditionalDetails() {
return additionalDetails;
}

public void setAdditionalDetails(List<LabeledString> additionalDetails) {
this.additionalDetails = additionalDetails;
}

@Override
public String toString() {
return "ProvisioningDiag(additionalDetails=" + additionalDetails + ")";
}


}
Expand Up @@ -19,6 +19,7 @@

import com.evolveum.midpoint.model.api.context.ModelContext;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.ProvisioningDiag;
import com.evolveum.midpoint.schema.RepositoryDiag;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
Expand Down Expand Up @@ -83,4 +84,9 @@ public interface ModelDiagnosticService {
*/
public OperationResult provisioningSelfTest(Task task);

/**
* Provide provisioning run-time configuration and diagnostic information.
*/
public ProvisioningDiag getProvisioningDiag(Task task, OperationResult parentResult);

}
Expand Up @@ -20,6 +20,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.schema.ProvisioningDiag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -132,7 +133,12 @@ public OperationResult provisioningSelfTest(Task task) {
return testResult;
}

private void repositorySelfTestUser(Task task, OperationResult testResult) {
@Override
public ProvisioningDiag getProvisioningDiag(Task task, OperationResult parentResult) {
return provisioningService.getProvisioningDiag();
}

private void repositorySelfTestUser(Task task, OperationResult testResult) {
OperationResult result = testResult.createSubresult(REPOSITORY_SELF_TEST_USER);

PrismObject<UserType> user = getObjectDefinition(UserType.class).instantiate();
Expand Down
Expand Up @@ -1381,7 +1381,7 @@ private <F extends FocusType> void checkAssigneeConstraints(LensContext<F> conte
if (multiplicity >= 0 && assigneeCount < multiplicity && plusMinus == PlusMinusZero.MINUS) {
if (constraint.getEnforcement() == null || constraint.getEnforcement() == PolicyConstraintEnforcementType.ENFORCE) {
throw new PolicyViolationException("Policy violation: "+target+" requires at least "+multiplicity+
" assignees. The operation would result in "+assigneeCount+" assignees."+plusMinus);
" assignees. The operation would result in "+assigneeCount+" assignees.");
}
}
}
Expand All @@ -1391,7 +1391,7 @@ private <F extends FocusType> void checkAssigneeConstraints(LensContext<F> conte
if (multiplicity >= 0 && assigneeCount > multiplicity && plusMinus == PlusMinusZero.PLUS) {
if (constraint.getEnforcement() == null || constraint.getEnforcement() == PolicyConstraintEnforcementType.ENFORCE) {
throw new PolicyViolationException("Policy violation: "+target+" requires at most "+multiplicity+
" assignees. The operation would result in "+assigneeCount+" assignees."+plusMinus);
" assignees. The operation would result in "+assigneeCount+" assignees.");
}
}
}
Expand Down
Expand Up @@ -31,6 +31,7 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ObjectOperationOption;
import com.evolveum.midpoint.schema.ProvisioningDiag;
import com.evolveum.midpoint.schema.ResultHandler;
import com.evolveum.midpoint.schema.SearchResultList;
import com.evolveum.midpoint.schema.SearchResultMetadata;
Expand Down Expand Up @@ -459,8 +460,15 @@ public <T extends ObjectType> void applyDefinition(Class<T> type, ObjectQuery qu
* general setup. Use ModelService.testResource for testing individual resource configurations.
*/
public void provisioningSelfTest(OperationResult parentTestResult, Task task);

/**

/**
* Returns a diagnostic information.
* @see com.evolveum.midpoint.schema.ProvisioningDiag
* @return
*/
ProvisioningDiag getProvisioningDiag();

/**
* Finish initialization of provisioning system.
*
* The implementation may execute resource-intensive tasks in this method. All the dependencies should be already
Expand All @@ -479,4 +487,5 @@ ConstraintsCheckingResult checkConstraints(RefinedObjectClassDefinition shadowDe
void enterConstraintsCheckerCache();

void exitConstraintsCheckerCache();

}
Expand Up @@ -483,7 +483,11 @@ private boolean compareConnectors(PrismObject<ConnectorType> prismA, PrismObject
return false;
}

private class ConfiguredConnectorInstanceEntry {
public String getFrameworkVersion() {
return connectorFactory.getFrameworkVersion();
}

private class ConfiguredConnectorInstanceEntry {
public String connectorOid;
public PrismContainer configuration;
public ConnectorInstance connectorInstance;
Expand Down
Expand Up @@ -30,6 +30,8 @@
import com.evolveum.midpoint.provisioning.api.ConstraintViolationConfirmer;
import com.evolveum.midpoint.provisioning.api.ConstraintsCheckingResult;
import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance;
import com.evolveum.midpoint.schema.LabeledString;
import com.evolveum.midpoint.schema.ProvisioningDiag;
import com.evolveum.midpoint.schema.RetrieveOption;

import org.apache.commons.lang.Validate;
Expand Down Expand Up @@ -123,6 +125,7 @@ public class ProvisioningServiceImpl implements ProvisioningService {

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

private static final String DETAILS_CONNECTOR_FRAMEWORK_VERSION = "ConnId framework version"; // TODO generalize

public ShadowCache getShadowCache(ShadowCacheFactory.Mode mode){
return shadowCacheFactory.getShadowCache(mode);
Expand Down Expand Up @@ -1531,12 +1534,24 @@ public void provisioningSelfTest(OperationResult parentTestResult, Task task) {
connectorManager.connectorFrameworkSelfTest(parentTestResult, task);
}

/*
* (non-Javadoc)
*
* @see
* com.evolveum.midpoint.provisioning.api.ProvisioningService#initialize()
*/
@Override
public ProvisioningDiag getProvisioningDiag() {
ProvisioningDiag provisioningDiag = new ProvisioningDiag();

String frameworkVersion = connectorManager.getFrameworkVersion();
if (frameworkVersion == null) {
frameworkVersion = "unknown";
}
provisioningDiag.getAdditionalDetails().add(new LabeledString(DETAILS_CONNECTOR_FRAMEWORK_VERSION, frameworkVersion));
return provisioningDiag;
}

/*
* (non-Javadoc)
*
* @see
* com.evolveum.midpoint.provisioning.api.ProvisioningService#initialize()
*/
@Override
public void postInit(OperationResult parentResult) {

Expand Down

0 comments on commit 029ec96

Please sign in to comment.