Skip to content

Commit

Permalink
Handle AlreadyExistsException correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan committed Mar 29, 2019
1 parent 2a276c9 commit ae3019c
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 97 deletions.
10 changes: 5 additions & 5 deletions connector-rest-wordpress/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Supports create, update, schema, test
# search and delete operations for users.

# search has not yet been tested, and
# several create and update error
# handling are a work in progress
# Search has not been tested, and
# some create and update error
# handlings are a work in progress

# Project is currently appropriate for
# POC and testing, but not production
# use. It assumes Wordpress to use the
# use. It assumes Wordpress has the
# JWT authentication plugin for the
# REST API https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api
# That plugin requires that the REST API
# Note that plugin requires that the REST API
# is at /wp-json
175 changes: 131 additions & 44 deletions connector-rest-wordpress/samples/connector-rest-wordpress.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<resource xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" oid="dd683dd5-b7b0-414c-a1d9-7039340ad70b" version="10">
<name>wordpress15</name>
<resource xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" oid="dd683dd5-b7b0-414c-a1d9-7039340ad70b" version="34">
<name>wordpress</name>
<metadata>
<modifyTimestamp>2019-03-19T13:02:44.112Z</modifyTimestamp>
<modifyTimestamp>2019-03-29T16:22:22.388Z</modifyTimestamp>
<modifierRef oid="00000000-0000-0000-0000-000000000002" relation="org:default" type="c:UserType"/>
<modifyChannel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#user</modifyChannel>
</metadata>
<operationExecution id="1">
<timestamp>2019-03-19T13:02:35.004Z</timestamp>
<operationExecution id="3">
<timestamp>2019-03-19T13:02:41.338Z</timestamp>
<operation>
<objectDelta>
<t:changeType>modify</t:changeType>
Expand All @@ -15,16 +15,16 @@
<executionResult>
<operation>com.evolveum.midpoint.model.impl.lens.ChangeExecutor.executeDelta</operation>
<status>success</status>
<token>1000000000000000168</token>
<token>1000000000000000273</token>
</executionResult>
<objectName>wordpress15</objectName>
<objectName>wordpress</objectName>
</operation>
<status>success</status>
<initiatorRef oid="00000000-0000-0000-0000-000000000002" relation="org:default" type="c:UserType"/>
<channel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#user</channel>
</operationExecution>
<operationExecution id="2">
<timestamp>2019-03-19T13:02:39.309Z</timestamp>
<operationExecution id="4">
<timestamp>2019-03-19T13:02:44.233Z</timestamp>
<operation>
<objectDelta>
<t:changeType>modify</t:changeType>
Expand All @@ -33,16 +33,16 @@
<executionResult>
<operation>com.evolveum.midpoint.model.impl.lens.ChangeExecutor.executeDelta</operation>
<status>success</status>
<token>1000000000000000232</token>
<token>1000000000000000314</token>
</executionResult>
<objectName>wordpress15</objectName>
<objectName>wordpress</objectName>
</operation>
<status>success</status>
<initiatorRef oid="00000000-0000-0000-0000-000000000002" relation="org:default" type="c:UserType"/>
<channel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#user</channel>
</operationExecution>
<operationExecution id="3">
<timestamp>2019-03-19T13:02:41.338Z</timestamp>
<operationExecution id="8">
<timestamp>2019-03-28T13:53:37.825Z</timestamp>
<operation>
<objectDelta>
<t:changeType>modify</t:changeType>
Expand All @@ -51,16 +51,16 @@
<executionResult>
<operation>com.evolveum.midpoint.model.impl.lens.ChangeExecutor.executeDelta</operation>
<status>success</status>
<token>1000000000000000273</token>
<token>1000000000000002054</token>
</executionResult>
<objectName>wordpress15</objectName>
<objectName>wordpress</objectName>
</operation>
<status>success</status>
<initiatorRef oid="00000000-0000-0000-0000-000000000002" relation="org:default" type="c:UserType"/>
<channel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#user</channel>
</operationExecution>
<operationExecution id="4">
<timestamp>2019-03-19T13:02:44.233Z</timestamp>
<operationExecution id="10">
<timestamp>2019-03-29T14:12:12.351Z</timestamp>
<operation>
<objectDelta>
<t:changeType>modify</t:changeType>
Expand All @@ -69,9 +69,27 @@
<executionResult>
<operation>com.evolveum.midpoint.model.impl.lens.ChangeExecutor.executeDelta</operation>
<status>success</status>
<token>1000000000000000314</token>
<token>1000000000000002055</token>
</executionResult>
<objectName>wordpress</objectName>
</operation>
<status>success</status>
<initiatorRef oid="00000000-0000-0000-0000-000000000002" relation="org:default" type="c:UserType"/>
<channel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#user</channel>
</operationExecution>
<operationExecution id="11">
<timestamp>2019-03-29T16:22:22.515Z</timestamp>
<operation>
<objectDelta>
<t:changeType>modify</t:changeType>
<t:objectType>c:ResourceType</t:objectType>
</objectDelta>
<executionResult>
<operation>com.evolveum.midpoint.model.impl.lens.ChangeExecutor.executeDelta</operation>
<status>success</status>
<token>1000000000000002018</token>
</executionResult>
<objectName>wordpress15</objectName>
<objectName>wordpress</objectName>
</operation>
<status>success</status>
<initiatorRef oid="00000000-0000-0000-0000-000000000002" relation="org:default" type="c:UserType"/>
Expand All @@ -80,32 +98,31 @@
<operationalState>
<lastAvailabilityStatus>up</lastAvailabilityStatus>
</operationalState>
<connectorRef type="c:ConnectorType">
<filter>
<q:equal>
<q:path>c:connectorType</q:path>
<q:value>edu.unc.polygon.connector.wordpress.WordpressRestConnector</q:value>
</q:equal>
</filter>
</connectorRef>

<connectorRef type="c:ConnectorType">
<filter>
<q:equal>
<q:path>c:connectorType</q:path>
<q:value>edu.unc.polygon.connector.wordpress.WordpressRestConnector</q:value>
</q:equal>
</filter>
</connectorRef>
<connectorConfiguration xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">
<icfc:configurationProperties xmlns:gen298="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/edu.unc.polygon.connector-rest-wordpress/edu.unc.polygon.connector.wordpress.WordpressRestConnector">
<gen298:wordpressPassword>54y6RxN7GfC7aes3</gen298:wordpressPassword>
<gen298:trustAllCertificates>true</gen298:trustAllCertificates>
<gen298:wordpressUniqueAttribute>id</gen298:wordpressUniqueAttribute>
<gen298:wordpressRestUrl>http://wordpress_server/wp-json</gen298:wordpressRestUrl>
<gen298:wordpressPasswordAttribute>password</gen298:wordpressPasswordAttribute>
<gen298:wordpressNameAttribute>username</gen298:wordpressNameAttribute>
<gen298:wordpressUsername>admin</gen298:wordpressUsername>
<gen298:wordpressRecyclebinUser>1</gen298:wordpressRecyclebinUser>
<gen298:wordpressSoftUserDelete>true</gen298:wordpressSoftUserDelete>
<icfc:configurationProperties xmlns:gen774="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/edu.unc.polygon.connector-rest-wordpress/edu.unc.polygon.connector.wordpress.WordpressRestConnector">
<gen774:wordpressPassword>54y6RxN7GfC7aes3</gen774:wordpressPassword>
<gen774:trustAllCertificates>true</gen774:trustAllCertificates>
<gen774:wordpressUniqueAttribute>id</gen774:wordpressUniqueAttribute>
<gen774:wordpressRestUrl>http://wordpress_server/wp-json</gen774:wordpressRestUrl>
<gen774:wordpressPasswordAttribute>password</gen774:wordpressPasswordAttribute>
<gen774:wordpressNameAttribute>username</gen774:wordpressNameAttribute>
<gen774:wordpressUsername>admin</gen774:wordpressUsername>
<gen774:wordpressRecyclebinUser>1</gen774:wordpressRecyclebinUser>
<gen774:wordpressSoftUserDelete>true</gen774:wordpressSoftUserDelete>
</icfc:configurationProperties>
</connectorConfiguration>
<schema>
<cachingMetadata>
<retrievalTimestamp>2019-03-19T13:02:35.235Z</retrievalTimestamp>
<serialNumber>db5b306ee09fcbbd-63313e1ea25f76e9</serialNumber>
<retrievalTimestamp>2019-03-29T16:22:22.861Z</retrievalTimestamp>
<serialNumber>318be2268b91039f-c8d8c12096d6f0bf</serialNumber>
</cachingMetadata>
<definition>
<xsd:schema xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3" xmlns:ra="http://midpoint.evolveum.com/xml/ns/public/resource/annotation-3" xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">
Expand Down Expand Up @@ -216,18 +233,29 @@
<kind>account</kind>
<intent>default</intent>
<default>true</default>
<objectClass>ri:MESSAGE_OBJECT_CLASS___ACCOUNT__</objectClass>
<objectClass>MESSAGE_OBJECT_CLASS___ACCOUNT__</objectClass>
<attribute id="1">
<c:ref>ri:username</c:ref>
<limitations>
<minOccurs>0</minOccurs>
</limitations>
<matchingRule xmlns:mr="http://prism.evolveum.com/xml/ns/public/matching-rule-3">mr:stringIgnoreCase</matchingRule>
<outbound>
<strength>strong</strength>
<source>
<c:path>$user/name</c:path>
</source>
</outbound>
<inbound id="9">
<target>
<c:path>$user/name</c:path>
</target>
</inbound>
</attribute>
<attribute id="2">
<c:ref>ri:email</c:ref>
<outbound>
<strength>strong</strength>
<source>
<c:path>$user/emailAddress</c:path>
</source>
Expand All @@ -240,6 +268,11 @@
<c:path>$user/fullName</c:path>
</source>
</outbound>
<inbound id="12">
<target>
<c:path>$user/fullName</c:path>
</target>
</inbound>
</attribute>
<attribute id="4">
<c:ref>ri:first_name</c:ref>
Expand All @@ -259,11 +292,21 @@
</attribute>
<attribute id="6">
<c:ref>icfs:name</c:ref>
<limitations>
<minOccurs>0</minOccurs>
</limitations>
<matchingRule xmlns:mr="http://prism.evolveum.com/xml/ns/public/matching-rule-3">mr:stringIgnoreCase</matchingRule>
<outbound>
<strength>strong</strength>
<source>
<c:path>$user/name</c:path>
</source>
</outbound>
<inbound id="13">
<target>
<c:path>$user/name</c:path>
</target>
</inbound>
</attribute>
<credentials>
<password xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ResourcePasswordDefinitionType">
Expand All @@ -274,8 +317,8 @@
</schemaHandling>
<capabilities>
<cachingMetadata>
<retrievalTimestamp>2019-03-19T13:02:35.229Z</retrievalTimestamp>
<serialNumber>2859b764880a952d-7fb0628b3129443b</serialNumber>
<retrievalTimestamp>2019-03-29T16:22:22.854Z</retrievalTimestamp>
<serialNumber>5b1c4a484a81371-d0dffd979b34680e</serialNumber>
</cachingMetadata>
<native xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:CapabilityCollectionType">
<cap:schema/>
Expand Down Expand Up @@ -321,6 +364,50 @@
</cap:read>
</configured>
</capabilities>
<synchronization/>
<synchronization>
<objectSynchronization>
<name>Account sync policy</name>
<objectClass>MESSAGE_OBJECT_CLASS___ACCOUNT__</objectClass>
<kind>account</kind>
<intent>default</intent>
<focusType>c:UserType</focusType>
<enabled>true</enabled>
<correlation>
<q:equal>
<q:matching>polyStringNorm</q:matching>
<q:path>c:name</q:path>
<expression>
<description>Matches using Name</description>
<path> declare namespace ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"; $account/attributes/icfs:name </path>
</expression>
</q:equal>
</correlation>
<reaction>
<situation>linked</situation>
<synchronize>true</synchronize>
</reaction>
<reaction>
<situation>deleted</situation>
<synchronize>true</synchronize>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#deleteFocus</handlerUri>
</action>
</reaction>
<reaction>
<situation>unlinked</situation>
<synchronize>true</synchronize>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#link</handlerUri>
</action>
</reaction>
<reaction>
<situation>unmatched</situation>
<synchronize>true</synchronize>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addFocus</handlerUri>
</action>
</reaction>
</objectSynchronization>
</synchronization>
</resource>

Loading

0 comments on commit ae3019c

Please sign in to comment.