Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jan 25, 2019
2 parents 0be9672 + 9bca0aa commit a1b5a90
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 15 deletions.
Expand Up @@ -24,7 +24,7 @@ <h3 class="box-title"><div wicket:id="treeTitle"/></h3>
<div class="cog" wicket:id="treeMenu" about="treeMenu"/>
</div>
</div>
<div wicket:id="treeContainer" class="box-body org-tree-container" style="flex: 100 1 auto;">
<div wicket:id="treeContainer" class="box-body org-tree-container" style="flex: 100 1 auto; max-height: 717px;">
<div wicket:id="tree"/>
</div>
</div>
Expand Down
Expand Up @@ -307,14 +307,6 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep

resourceManager.modifyResourceAvailabilityStatus(resource.asPrismObject(),
AvailabilityStatusType.UP, parentResult);
// try to apply changes to the account only if the resource if UP
if (isCompensate(rootOptions) && repositoryShadow.asObjectable().getObjectChange() != null
&& repositoryShadow.asObjectable().getFailedOperationType() != null
&& resource.getOperationalState() != null && resource.getOperationalState()
.getLastAvailabilityStatus() == AvailabilityStatusType.UP) {
throw new GenericConnectorException(
"Found changes that have been not applied to the resource object yet. Trying to apply them now.");
}

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Shadow from repository:\n{}", repositoryShadow.debugDump(1));
Expand Down
Expand Up @@ -113,7 +113,7 @@ public abstract class AbstractDummyTest extends AbstractProvisioningIntegrationT
protected static final File ACCOUNT_LECHUCK_FILE = new File(TEST_DIR, "account-lechuck.xml");
protected static final String ACCOUNT_LECHUCK_OID = "c0c010c0-d34d-b44f-f11d-444400009aa9";
protected static final String ACCOUNT_LECHUCK_NAME = "lechuck";

protected static final File GROUP_PIRATES_FILE = new File(TEST_DIR, "group-pirates.xml");
protected static final String GROUP_PIRATES_OID = "c0c010c0-d34d-b44f-f11d-3332eeee0000";
protected static final String GROUP_PIRATES_NAME = "pirates";
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum
* Copyright (c) 2010-2019 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 @@ -94,6 +94,11 @@ public class TestDummyConsistency extends AbstractDummyTest {
private static final String ACCOUNT_BETTY_FULLNAME = "Betty Rubble";
private static final String ACCOUNT_ELIZABETH2_FULLNAME = "Her Majesty Queen Elizabeth II";

protected static final File ACCOUNT_SHADOW_MURRAY_LEGACY_FILE = new File(TEST_DIR, "account-shadow-murray-legacy.xml");
protected static final String ACCOUNT_SHADOW_MURRAY_LEGACY_OID = "34132742-2085-11e9-a956-17770b09881b";
private static final String ACCOUNT_MURRAY_USERNAME = "murray";
private static final String ACCOUNT_MURRAY_FULL_NAME = "Murray";

private XMLGregorianCalendar lastRequestStartTs;
private XMLGregorianCalendar lastRequestEndTs;
private XMLGregorianCalendar lastAttemptStartTs;
Expand Down Expand Up @@ -2124,6 +2129,38 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception

// TODO: test no discovery options

/**
* Legacy consistency items.
* MID-5076
*/
@Test
public void test900GetAccountMurrayLegacy() throws Exception {
final String TEST_NAME = "test900GetAccountMurrayLegacy";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
dummyResource.resetBreakMode();

dummyResourceCtl.addAccount(ACCOUNT_MURRAY_USERNAME, ACCOUNT_MURRAY_FULL_NAME);
repoAddObjectFromFile(ACCOUNT_SHADOW_MURRAY_LEGACY_FILE, result);

// WHEN
displayWhen(TEST_NAME);
PrismObject<ShadowType> accountMurray = provisioningService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_LEGACY_OID, null, task, result);

// THEN
displayThen(TEST_NAME);
display("Result", result);
assertSuccess(result);
accountMurray.checkConsistence();

// TODO: assert Murray

assertSteadyResources();
}

private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception {

assertRepoShadow(shadowMorganOid)
Expand Down
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 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.
-->

<!-- MID-5076 -->
<account oid="34132742-2085-11e9-a956-17770b09881b"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance/ef2bc95b-76e0-59e2-86d6-9999dddddddd">
<name>murray</name>
<resourceRef oid="ef2bc95b-76e0-59e2-86d6-9999dddddddd" />
<objectClass>ri:AccountObjectClass</objectClass>
<kind>account</kind>

<!-- Legacy consistency items -->
<objectChange>
<t:changeType>modify</t:changeType>
<t:objectType>c:ShadowType</t:objectType>
<t:oid>34132742-2085-11e9-a956-17770b09881b</t:oid>
<t:itemDelta>
<t:modificationType>add</t:modificationType>
<t:path>c:attributes/ri:fullname</t:path>
<t:value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">Evil Devil Murray</t:value>
</t:itemDelta>
</objectChange>
<attemptNumber>0</attemptNumber>
<failedOperationType>modify</failedOperationType>

<attributes>
<icfs:name>murray</icfs:name>
<icfs:uid>murray</icfs:uid>
</attributes>
</account>
Expand Up @@ -93,7 +93,7 @@ public Session beginTransaction(boolean readOnly) {

if (getConfiguration().getTransactionIsolation() == TransactionIsolation.SNAPSHOT) {
LOGGER.trace("Setting transaction isolation level SNAPSHOT.");
session.doWork(connection -> connection.createStatement().execute("SET TRANSACTION ISOLATION LEVEL SNAPSHOT"));
session.doWork(connection -> RUtil.executeStatement(connection,"SET TRANSACTION ISOLATION LEVEL SNAPSHOT"));
}

if (readOnly) {
Expand All @@ -102,7 +102,7 @@ public Session beginTransaction(boolean readOnly) {
session.setHibernateFlushMode(FlushMode.MANUAL);

LOGGER.trace("Marking transaction as read only.");
session.doWork(connection -> connection.createStatement().execute("SET TRANSACTION READ ONLY"));
session.doWork(connection -> RUtil.executeStatement(connection, "SET TRANSACTION READ ONLY"));
}
return session;
}
Expand Down
Expand Up @@ -19,11 +19,11 @@
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ReferenceDelta;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration;
import com.evolveum.midpoint.repo.sql.data.common.ROrgClosure;
import com.evolveum.midpoint.repo.sql.data.common.other.RObjectType;
import com.evolveum.midpoint.repo.sql.util.RUtil;
import com.evolveum.midpoint.schema.ResultHandler;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
Expand Down Expand Up @@ -953,7 +953,7 @@ private String computeDeltaTable(List<Edge> edges, Context context, Session sess
"PRIMARY KEY (descendant_oid, ancestor_oid))";
// NativeQuery createTableQuery = session.createNativeQuery(createTableSql);
// createTableQuery.executeUpdate(); <--- this does not work because the temporary table gets deleted when the command terminates (preparedStatement issue - maybe something like this: https://support.microsoft.com/en-us/kb/280134 ?)
session.doWork(connection -> connection.createStatement().execute(createTableSql));
session.doWork(connection -> RUtil.executeStatement(connection, createTableSql));
LOGGER.trace("Empty delta table created in {} ms", System.currentTimeMillis() - start);

NativeQuery insertQuery = session.createNativeQuery("insert into " + deltaTempTableName + " " + selectClause);
Expand Down
Expand Up @@ -65,6 +65,9 @@
import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
Expand Down Expand Up @@ -564,4 +567,16 @@ public static String fixDBSchemaObjectNameLength(String input) {

return result;
}

public static void executeStatement(Connection connection, String sql) throws SQLException {
Statement stmt = null;
try {
stmt = connection.createStatement();
stmt.execute(sql);
} finally {
if (stmt != null && !stmt.isClosed()) {
stmt.close();
}
}
}
}

0 comments on commit a1b5a90

Please sign in to comment.