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
KaterynaHonchar committed Oct 12, 2018
2 parents af80389 + 3a87434 commit 95843f0
Show file tree
Hide file tree
Showing 53 changed files with 1,571 additions and 334 deletions.
2 changes: 2 additions & 0 deletions README.md
@@ -1,5 +1,7 @@
Status: [![Build Status](https://travis-ci.org/Evolveum/midpoint.svg?branch=master)](https://travis-ci.org/Evolveum/midpoint)

Gitter: [![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/Evolveum/midpoint)

MidPoint 3.9 development branch
------------------------------------

Expand Down
Expand Up @@ -123,7 +123,7 @@
</wicket:enclosure>
<div class="content-wrapper" style="min-height: 916px;">
<!-- Main content -->
<section class="content">
<section class="content col-xs-12" style="float:left;">
<div wicket:id="feedbackContainer" class="feedbackContainer">
<div wicket:id="feedback" class="messagePanel"/>
<!-- <div wicket:id="tempFeedback" class="tempMessage"/> -->
Expand Down
Expand Up @@ -2798,7 +2798,7 @@ public void onClick(AjaxRequestTarget target) {
result.recordInProgress(); // this should be probably have been done in submitTaskFromTemplate
result.setBackgroundTaskOid(executorTask.getOid());
} else {
result.recordWarning("There are no objects to execute the action on"); // TODO i18n
result.recordWarning(pageBase.createStringResource("webComponentUtil.message.createMenuItemsFromActions.warning").getString());
}
} catch (Exception ex) {
result.recordFatalError(result.getOperation(), ex);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
import com.evolveum.midpoint.model.api.ScriptExecutionResult;
import com.evolveum.midpoint.model.api.ScriptingService;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
Expand Down Expand Up @@ -53,6 +54,7 @@ public class PostInitialDataImport extends DataImport{
private static final Trace LOGGER = TraceManager.getTrace(PostInitialDataImport.class);

private static final String SUFFIX_FOR_IMPORTED_FILE = "done";
private static final String XML_SUFFIX = "xml";

private ScriptingService scripting;

Expand All @@ -68,58 +70,57 @@ public void init() throws SchemaException {
Task task = taskManager.createTaskInstance(OPERATION_INITIAL_OBJECTS_IMPORT);
task.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI);

int countImpotredObjects = 0;
int countExecutedScripts = 0;

File[] files = getPostInitialImportObjects();
LOGGER.debug("Files to be imported: {}.", Arrays.toString(files));

SecurityContext securityContext = provideFakeSecurityContext();

int countImpotredObjects = 0;
int countExecutedScripts = 0;

for (File file : files) {
if(FilenameUtils.getExtension(file.getName()).equals(SUFFIX_FOR_IMPORTED_FILE)) {
continue;
}
if(!FilenameUtils.getExtension(file.getName()).equals(XML_SUFFIX)) {
LOGGER.warn("Post-initial import support only xml files. Actual file: " + file.getName());
continue;
}
Item item = null;
try {
item = prismContext.parserFor(file).parseItem();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't parse file {}", ex, file.getName());
mainResult.recordFatalError("Couldn't parse file '" + file.getName() + "'", ex);
}
if(item instanceof PrismObject) {
try {
LOGGER.debug("Considering post-initial import of file {}.", file.getName());
PrismObject object = (PrismObject)item;
if (ReportType.class.equals(object.getCompileTimeClass())) {
ReportTypeUtil.applyDefinition(object, prismContext);
}

Boolean importObject = importObject(object, file, task, mainResult);
if (importObject) {
file.renameTo(new File(file.getPath() + "." + SUFFIX_FOR_IMPORTED_FILE));
countImpotredObjects++;
} else {
break;
}
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import file {}", ex, file.getName());
mainResult.recordFatalError("Couldn't import file '" + file.getName() + "'", ex);
}
} else if(item instanceof PrismProperty && (((PrismProperty)item).getRealValue() instanceof ScriptingExpressionType) || ((PrismProperty)item).getRealValue() instanceof ExecuteScriptType){
PrismProperty<Object> expression = (PrismProperty<Object>)item;
Boolean executeScript = executeScript(expression, file, task, mainResult);
if (executeScript) {
file.renameTo(new File(file.getPath() + "." + SUFFIX_FOR_IMPORTED_FILE));
countExecutedScripts++;
} else {
break;
}
} else {
mainResult.recordFatalError("\"Provided file" + file.getName() +" is not a bulk action object or prism object.\"");
}

if(item instanceof PrismProperty && (((PrismProperty)item).getRealValue() instanceof ScriptingExpressionType || ((PrismProperty)item).getRealValue() instanceof ExecuteScriptType)){
PrismProperty<Object> expression = (PrismProperty<Object>)item;
Boolean executeScript = executeScript(expression, file, task, mainResult);
if (executeScript) {
file.renameTo(new File(file.getPath() + "." + SUFFIX_FOR_IMPORTED_FILE));
countExecutedScripts++;
} else {
break;
}
} else {
try {
LOGGER.debug("Considering post-initial import of file {}.", file.getName());

Boolean importObject = importObject(file, task, mainResult);
if (importObject) {
file.renameTo(new File(file.getPath() + "." + SUFFIX_FOR_IMPORTED_FILE));
countImpotredObjects++;
} else {
break;
}
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import file {}", ex, file.getName());
mainResult.recordFatalError("Couldn't import file '" + file.getName() + "'", ex);
}
}
}

securityContext.setAuthentication(null);

mainResult.recomputeStatus("Couldn't import objects.");
Expand All @@ -129,29 +130,24 @@ public void init() throws SchemaException {
LOGGER.trace("Initialization status:\n" + mainResult.debugDump());
}
}

/**
* @param object
* @param task
* @param mainResult
* @return true if it was success, otherwise false
*/
private <O extends ObjectType> Boolean importObject(PrismObject<O> object, File file, Task task, OperationResult mainResult) {
private <O extends ObjectType> Boolean importObject(File file, Task task, OperationResult mainResult) {
OperationResult result = mainResult.createSubresult(OPERATION_IMPORT_OBJECT);
preImportUpdate(object);

ObjectDelta delta = ObjectDelta.createAddDelta(object);
try {
LOGGER.info("Starting post-initial import of file {}.", file.getName());
ImportOptionsType options = new ImportOptionsType();
options.overwrite(true);
model.importObjectsFromFile(file, options, task, result);
result.recordSuccess();
LOGGER.info("Created {} as part of post-initial import", object);
return true;
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import {} from file {}: ", e, object,
file.getName(), e.getMessage());
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import object from file {}: ", e, file.getName(), e.getMessage());
result.recordFatalError(e);

LOGGER.info("\n" + result.debugDump());
Expand Down Expand Up @@ -201,9 +197,15 @@ private File[] getPostInitialImportObjects() {
File folder = new File(postInitialObjectsPath);
files = listFiles(folder);
sortFiles(files);
}
else {
LOGGER.debug("Directory " + postInitialObjectsPath + " does not exist.");
} else {
LOGGER.info("Directory " + postInitialObjectsPath + " does not exist. Creating.");
File dir = new File(postInitialObjectsPath);
if (!dir.exists() || !dir.isDirectory()) {
boolean created = dir.mkdirs();
if (!created) {
LOGGER.error("Unable to create directory " + postInitialObjectsPath + " as user " + System.getProperty("user.name"));
}
}
}
}
else {
Expand All @@ -214,13 +216,18 @@ private File[] getPostInitialImportObjects() {

private File[] listFiles(File folder) {
File[] files = folder.listFiles();
File[] retFiles =new File[0];
for(File file: files){
if(file.isFile()){
retFiles = (File[])ArrayUtils.add(retFiles, file);
continue;
}
if(file.isDirectory()){
files = (File[])ArrayUtils.removeElement(files, file);
files = (File[])ArrayUtils.addAll(files, listFiles(file));

retFiles = (File[])ArrayUtils.addAll(retFiles, listFiles(file));
}
}
return files;
return retFiles;
}

private boolean checkDirectoryExistence(String dir) {
Expand Down
Expand Up @@ -15,14 +15,14 @@
~ limitations under the License.
-->
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<div wicket:id="summaryBox" class="info-box">
<div wicket:id="summaryBox" class="col-xs-12 info-box" style="padding: 0px; padding-bottom:5px">
<!-- take care that there are no whitespaces inside the following div -->
<div wicket:id="summaryIconBox" class="info-box-icon"><span class="user-thumbnail-helper"/><span wicket:id="summaryIcon"/><img wicket:id="summaryPhoto" class="user-thumbnail"/></div>
<div class="info-box-content">
<span class="summary-content-box">
<span class="summary-text-box">
<span class="info-box-number">
<span class="summary-panel-display-name" wicket:id="summaryDisplayName"/> <span class="summary-panel-identifier" wicket:id="summaryIdentifierPanel">(<span wicket:id="summaryIdentifier"/>)</span>
<span class="col-xs-12 col-sm-6 col-md-8 col-lg-9 summary-text-box" style="padding: 0px;">
<span class="col-xs-12 info-box-number" style="padding: 0px;">
<span class="col-xs-12 summary-panel-display-name" wicket:id="summaryDisplayName" style="padding: 0px;"/> <span class="col-xs-12 summary-panel-identifier" wicket:id="summaryIdentifierPanel" style="padding: 0px;">(<span wicket:id="summaryIdentifier"/>)</span>
</span>
<span wicket:id="summaryTitle" class="summary-panel-title">
</span>
Expand All @@ -33,7 +33,7 @@
<span wicket:id="summaryOrganization" class="summary-panel-organization">
</span>
</span>
<span wicket:id="summaryTagBox" class="summary-tag-box">
<span wicket:id="summaryTagBox" class="col-xs-12 col-sm-6 col-md-4 col-lg-3 summary-tag-box">
<wicket:child />
</span>
</span>
Expand Down
Expand Up @@ -59,7 +59,7 @@ public abstract class AbstractSummaryPanel<C extends Containerable> extends Base
protected static final String ID_PHOTO = "summaryPhoto"; // perhaps useful only for focal objects but it was simpler to include it here
protected static final String ID_ORGANIZATION = "summaryOrganization"; // similar (requires ObjectWrapper to get parent organizations so hard to use in ObjectSummaryPanel)

protected static final String BOX_CSS_CLASS = "info-box";
protected static final String BOX_CSS_CLASS = "col-xs-12 info-box";
protected static final String ICON_BOX_CSS_CLASS = "info-box-icon";

protected SummaryPanelSpecificationType configuration;
Expand Down
Expand Up @@ -17,7 +17,7 @@
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<div class="col-lg-3 col-xs-6">
<div class="col-lg-3 col-md-6 col-xs-12">
<div class="small-box shopping-cart-item-box">
<div wicket:id="itemButtonContainer">
<div wicket:id="inner" class="inner">
Expand Down
Expand Up @@ -17,7 +17,7 @@
<html xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<form wicket:id="mainForm" class="form-horizontal">
<form wicket:id="mainForm" class="col-xs-12 form-horizontal" style="padding:0px;">

<div wicket:id="tabPanel" class="nav-tabs-custom" />

Expand Down
Expand Up @@ -17,7 +17,7 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div wicket:id="labelContainer" class="col-xs-2 prism-property-label">
<div wicket:id="labelContainer" class="col-md-2 col-xs-12 prism-property-label">
<span wicket:id="label"/>
<span wicket:id="required" style="color: #f00; font-weight: bold;"
wicket:message="title:prismPropertyPanel.required">*</span>
Expand All @@ -29,7 +29,7 @@
<i wicket:id="deprecated"/>
<i wicket:id="experimental"/>
</div>
<div class="col-md-10 prism-property-value" wicket:id="values">
<div class="col-md-10 col-xs-12 prism-property-value" wicket:id="values">
<div wicket:id="value"/>
</div>
</wicket:panel>
Expand Down
Expand Up @@ -15,36 +15,36 @@
~ limitations under the License.
-->
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<form wicket:id="form" class="form-inline pull-right search-form">
<form wicket:id="form" class="form-inline pull-right search-form" style="padding-bottom:5px;">

<div class="form-group has-feedback" wicket:id="advancedGroup">
<label class="control-label" style="vertical-align: top;">
<div class="form-group has-feedback" wicket:id="advancedGroup" style="float:left; padding-right: 5px;">
<label class="control-label" style="vertical-align: top; float:left; padding-right: 5px;">
<i class="fa fa-lg" wicket:id="advancedCheck"/>
</label>
<textarea class="form-control input-sm" rows="2" wicket:id="advancedArea"
style="width: 220px; height: 60px; overflow: hidden;"
style="width: 220px; height: 60px; overflow: hidden; float:left;"
wicket:message="placeholder:SearchPanel.insertFilterXml"></textarea>
<span class="help-block" wicket:id="advancedError"/>
</div>

<div class="form-group" wicket:id="fullTextContainer">
<div class="form-group" wicket:id="fullTextContainer" style="float:left; padding-right: 5px;">
<input wicket:id="fullTextField" type="text" class="form-control input-sm" style="width: 150px; min-width: 150px;">
<!--<div wicket:id="fullTextField" wicket:message="placeholder:SearchPanel.fullTextSearch"></div>-->
</div>

<wicket:container wicket:id="items">
<div wicket:id="item" class="form-group"/>
<div wicket:id="item" class="form-group" style="float:left; padding-right: 5px;"/>
</wicket:container>

<div class="form-group" wicket:id="moreGroup">
<div class="form-group" wicket:id="moreGroup" style="float:left; padding-right: 5px;">
<a wicket:id="more" class="btn btn-sm btn-default">
<wicket:message key="SearchPanel.more"/>
&nbsp;
<span class="caret"></span>
</a>
</div>

<div class="form-group" style="vertical-align: top;" wicket:id="searchContainer">
<div class="form-group" style="vertical-align: top; float:left; padding-right: 5px;" wicket:id="searchContainer">
<a wicket:id="searchSimple" class="btn btn-sm btn-primary" about="searchSimple">
<i class="fa fa-search fa-lg"/>
</a>
Expand All @@ -67,7 +67,7 @@
</div>
</div>

<div class="form-group" wicket:id="linksContainer" style="vertical-align: top; margin-top: -5px;">
<div class="form-group" wicket:id="linksContainer" style="vertical-align: top; margin-top: -5px; float:left;">
<a class="btn btn-sm btn-link" wicket:id="basic" style="display: table-cell; vertical-align: top;"/>
<a class="btn btn-sm btn-link" wicket:id="advanced"/>
<a class="btn btn-sm btn-link" wicket:id="fullText" style=" margin-top: -20px;"/>
Expand Down
Expand Up @@ -490,7 +490,7 @@ public String getObject() {
sb.append(StringUtils.substringAfter(action.getHandlerUri(), "#"));
}
} else {
sb.append("sync"); // TODO i18n
sb.append(getString("SynchronizationStep.label.editorReaction"));
}
}
sb.append(")");
Expand Down
Expand Up @@ -1022,15 +1022,14 @@ private void deleteCampaignsPerformed(AjaxRequestTarget target,
getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task,
result);
} catch (Exception ex) {
result.recordPartialError("Couldn't delete campaign.", ex);
result.recordPartialError(createStringResource("PageCertCampaigns.message.deleteCampaignsPerformed.partialError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete campaign", ex);
}
}

result.recomputeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS,
"The campaign(s) have been successfully deleted."); // todo i18n
result.recordStatus(OperationResultStatus.SUCCESS, createStringResource("PageCertCampaigns.message.deleteCampaignsPerformed.success").getString());
}

Table campaignsTable = getCampaignsTable();
Expand Down Expand Up @@ -1074,7 +1073,7 @@ private void actOnCampaignsPerformed(AjaxRequestTarget target, String operationN
throw new IllegalStateException("Unknown action: " + operationName);
}
} catch (Exception ex) {
result.recordPartialError("Couldn't process campaign.", ex);
result.recordPartialError(createStringResource("PageCertCampaigns.message.actOnCampaignsPerformed.partialError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't process campaign", ex);
}
}
Expand All @@ -1087,8 +1086,7 @@ private void actOnCampaignsPerformed(AjaxRequestTarget target, String operationN

result.recomputeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS,
processed + " campaign(s) have been successfully processed."); // todo i18n
result.recordStatus(OperationResultStatus.SUCCESS, createStringResource("PageCertCampaigns.message.actOnCampaignsPerformed.success", processed).getString());
}
WebComponentUtil.safeResultCleanup(result, LOGGER);
showResult(result);
Expand Down

0 comments on commit 95843f0

Please sign in to comment.