diff --git a/connector-federation-manager/pom.xml b/connector-federation-manager/pom.xml
index 45a2572..71b4fe8 100644
--- a/connector-federation-manager/pom.xml
+++ b/connector-federation-manager/pom.xml
@@ -27,7 +27,7 @@
edu.unc.polygon
connector-federation-manager
- .2-SNAPSHOT
+ .3-SNAPSHOT
jar
Federation Manager Connector
diff --git a/connector-federation-manager/samples/connector-federation-manager.xml b/connector-federation-manager/samples/connector-federation-manager.xml
index 48f62d2..d59f677 100644
--- a/connector-federation-manager/samples/connector-federation-manager.xml
+++ b/connector-federation-manager/samples/connector-federation-manager.xml
@@ -126,7 +126,7 @@
-
+
@@ -134,7 +134,7 @@
icfs:name
icfs:name
icfs:name
- MESSAGE_OBJECT_CLASS___ACCOUNT__
+ AccountObjectClass
@@ -254,7 +254,7 @@
account
default
true
- MESSAGE_OBJECT_CLASS___ACCOUNT__
+ AccountObjectClass
icfs:uid
@@ -349,7 +349,7 @@
Account sync policy
- MESSAGE_OBJECT_CLASS___ACCOUNT__
+ AccountObjectClass
account
default
c:UserType
diff --git a/connector-federation-manager/src/main/java/edu/unc/polygon/connector/federationManager/FederationManagerConnector.java b/connector-federation-manager/src/main/java/edu/unc/polygon/connector/federationManager/FederationManagerConnector.java
index 326b967..55f89c5 100644
--- a/connector-federation-manager/src/main/java/edu/unc/polygon/connector/federationManager/FederationManagerConnector.java
+++ b/connector-federation-manager/src/main/java/edu/unc/polygon/connector/federationManager/FederationManagerConnector.java
@@ -80,6 +80,13 @@ public class FederationManagerConnector extends AbstractRestConnector entityAttributes = new HashSet();
+ AttributeInfoBuilder entity_id = new AttributeInfoBuilder();
+ entity_id.setName(ENTITY_ATTR_ID);
+ entity_id.setCreateable(true);
+ entity_id.setUpdateable(true);
+ entity_id.setReadable(true);
+ entity_id.setRequired(false);
+ entity_id.setMultiValued(false);
+ entityAttributes.add(entity_id.build());
+ AttributeInfoBuilder entity_name = new AttributeInfoBuilder();
+ entity_name.setName(ENTITY_ATTR_ENTITY_NAME);
+ entity_name.setCreateable(true);
+ entity_name.setUpdateable(true);
+ entity_name.setReadable(true);
+ entity_name.setRequired(false);
+ entity_name.setMultiValued(false);
+ entityAttributes.add(entity_name.build());
+ AttributeInfoBuilder entity_type = new AttributeInfoBuilder();
+ entity_type.setName(ENTITY_ATTR_TYPE);
+ entity_type.setCreateable(true);
+ entity_type.setUpdateable(true);
+ entity_type.setReadable(true);
+ entity_type.setRequired(false);
+ entity_type.setMultiValued(false);
+ entityAttributes.add(entity_type.build());
+ AttributeInfoBuilder entity_organization_id = new AttributeInfoBuilder();
+ entity_organization_id.setName(ENTITY_ATTR_ORGANIZATION_ID);
+ entity_organization_id.setCreateable(true);
+ entity_organization_id.setUpdateable(true);
+ entity_organization_id.setReadable(true);
+ entity_organization_id.setRequired(false);
+ entity_organization_id.setMultiValued(false);
+ entityAttributes.add(entity_organization_id.build());
+ AttributeInfoBuilder entity_organization_name = new AttributeInfoBuilder();
+ entity_organization_name.setName(ENTITY_ATTR_ORGANIZATION_NAME);
+ entity_organization_name.setCreateable(true);
+ entity_organization_name.setUpdateable(true);
+ entity_organization_name.setReadable(true);
+ entity_organization_name.setRequired(false);
+ entity_organization_name.setMultiValued(false);
+ entityAttributes.add(entity_organization_name.build());
+ AttributeInfoBuilder entity_status = new AttributeInfoBuilder();
+ entity_status.setName(ENTITY_ATTR_STATUS);
+ entity_status.setCreateable(true);
+ entity_status.setUpdateable(true);
+ entity_status.setReadable(true);
+ entity_status.setRequired(false);
+ entity_status.setMultiValued(false);
+ entityAttributes.add(entity_status.build());
+ accountAttributes.add(OperationalAttributeInfos.ENABLE);
+ schemaBuilder.defineObjectClass(ENTITY_OBJECT_CLASS,entityAttributes);
LOG.info(">>> schema finished");
return schemaBuilder.build();
@@ -244,8 +302,10 @@ public FilterTranslator createFilterTranslator(ObjectCl
@Override
public void executeQuery(ObjectClass oc, FederationManagerFilter filter, ResultsHandler handler, OperationOptions oo) {
LOG.info("starting executeQuery");
+ LOG.info("ObjectClass.ACCOUNT_NAME is " + ObjectClass.ACCOUNT_NAME);
+ LOG.info("executeQuery ObjectClass is " + oc.getObjectClassValue() + "--");
if ( oc.is(ObjectClass.ACCOUNT_NAME)) {
- LOG.info("executeQuery ObjectClass.ACCOUNT_NAME");
+ LOG.info("executeQuery ObjectClass.ACCOUNT_NAME");
/* Filtered searches aren't supported by this API yet, so we'll skip over these for now
if (filter != null && filter.byUid != null) {
//not sure if this use case exists yet
@@ -262,8 +322,6 @@ else if (filter != null && filter.byEmailAddress != null) {
//wide open search
}
*/
- }
- else {
try {
CloseableHttpClient client = HttpClients.createDefault();
HttpRequestBase restGet;
@@ -294,9 +352,57 @@ else if (filter != null && filter.byEmailAddress != null) {
} catch (IOException IOE) {
throw new ConnectorIOException(IOE.getMessage(), IOE);
+ }
+ }
+ if ( oc.is(ENTITY_OBJECT_CLASS)) {
+ LOG.info("executeQuery ObjectClass.EntityObjectClass");
+ /* Filtered searches aren't supported by this API yet, so we'll skip over these for now
+ if (filter != null && filter.byUid != null) {
+ //not sure if this use case exists yet
+ }
+
+ else if (filter != null && filter.byName != null) {
+ //not sure if this use case exists yet
}
+ else if (filter != null && filter.byEmailAddress != null) {
+ //not sure if this use case exists yet
+ }
+ else {
+ //wide open search
+ }
+ */
+ try {
+ CloseableHttpClient client = HttpClients.createDefault();
+ HttpRequestBase restGet;
+ restGet = new HttpGet(configuration.getServiceAddress() + "/siteadmin/api/entities");
+ authHeader(restGet);
+ //CloseableHttpResponse getResponse = client.execute(restGet);
+ //processResponseErrors(getResponse);
+ JSONObject searchResponseJson = new JSONObject();
+ searchResponseJson = callRequest(restGet);
+ FileWriter file9 = new FileWriter("/tmp/file9.txt");
+ file9.write(searchResponseJson.toString());
+ System.out.println("Successfully Copied JSON Object to File...");
+ System.out.println("\nJSON Object: " + searchResponseJson);
+ file9.flush();
+ file9.close();
+ JSONArray entityArray = new JSONArray();
+ if ( searchResponseJson.has("data") && searchResponseJson.get("data") != null ) {
+ entityArray = searchResponseJson.getJSONArray("data");
+ for ( int i = 0; i < entityArray.length(); i++ ) {
+ JSONObject entityJson = entityArray.getJSONObject(i);
+ LOG.info(">>> processing ID " + i);
+ handleEntity( handler, entityJson );
+ }
+ }
+ else {
+ LOG.info("No data object found in response");
+ }
+ } catch (IOException IOE) {
+ throw new ConnectorIOException(IOE.getMessage(), IOE);
+ }
}
}
@@ -377,22 +483,6 @@ private void handleUserId ( ResultsHandler handler, JSONObject uidSearchResponse
}
//builder.setUid(new Uid(String.valueOf(id)));
String [] potentialAttributes = { ATTR_NAME, ATTR_MAIL, ATTR_FIRST_NAME, ATTR_LAST_NAME, ATTR_MIDDLE_NAME, ATTR_ORGANIZATION_ID, ATTR_FAX_NUMBER, ATTR_MOBILE_NUMBER, ATTR_PHONE_NUMBER, ATTR_INFORMAL_NAME, ATTR_WEBSITE};
- /*
- private static final String ATTR_ID = "id"; //__UID__
- private static final String ATTR_ORGANIZATION_ID = "organization_id";
- public static final String ATTR_NAME = "email"; //hope to change this to username later __NAME__
- public static final String ATTR_MAIL = "email";
- public static final String ATTR_FAX_NUMBER = "faxnumber";
- public static final String ATTR_MOBILE_NUMBER = "mobilenumber";
- public static final String ATTR_PHONE_NUMBER = "phonenumber";
- //public static final String ATTR_ROLES = "roles";
- public static final String ATTR_FIRST_NAME = "firstname";
- public static final String ATTR_LAST_NAME = "lastname";
- public static final String ATTR_MIDDLE_NAME = "middlename";
- public static final String ATTR_INFORMAL_NAME = "informalname";
- public static final String ATTR_WEBSITE = "website";
- public static final String CONTENT_TYPE = "application/json";
- */
for ( String potentialAttribute: potentialAttributes ) {
LOG.info(">>> checking for attribute " + potentialAttribute );
if ( attributes.has(potentialAttribute) && attributes.get(potentialAttribute) != null && !JSONObject.NULL.equals(attributes.get(potentialAttribute)) ) {
@@ -413,5 +503,35 @@ else if ( potentialAttribute.equals(ATTR_ORGANIZATION_ID) ) {
handler.handle(connectorObject);
}
+ private void handleEntity ( ResultsHandler handler, JSONObject uidSearchResponseJson ) {
+ LOG.info("inside handleEntity " + String.valueOf(uidSearchResponseJson.getInt(ENTITY_ATTR_ID)));
+ ConnectorObjectBuilder builder = new ConnectorObjectBuilder();
+ builder.setUid(new Uid(String.valueOf(uidSearchResponseJson.getInt(ENTITY_ATTR_ID))));
+ JSONObject attributes = new JSONObject();
+ if ( uidSearchResponseJson.has("attributes") && uidSearchResponseJson.get("attributes") != null ) {
+ attributes = (JSONObject) uidSearchResponseJson.get("attributes");
+ }
+ //builder.setUid(new Uid(String.valueOf(id)));
+ String [] potentialAttributes = { ENTITY_ATTR_ENTITY_NAME,ENTITY_ATTR_TYPE,ENTITY_ATTR_ORGANIZATION_ID,ENTITY_ATTR_ORGANIZATION_NAME,ENTITY_ATTR_STATUS};
+ for ( String potentialAttribute: potentialAttributes ) {
+ LOG.info(">>> checking for attribute " + potentialAttribute );
+ if ( attributes.has(potentialAttribute) && attributes.get(potentialAttribute) != null && !JSONObject.NULL.equals(attributes.get(potentialAttribute)) ) {
+ LOG.info(">>> found attribute " + potentialAttribute );
+ if ( potentialAttribute.equals(ENTITY_ATTR_ENTITY_NAME) ) {
+ builder.setName(attributes.getString(potentialAttribute));
+ //builder.setName(String.valueOf(uidSearchResponseJson.getInt(ATTR_ID))); //Temp work around to use "id" as __NAME__ until we get username
+ }
+ else if ( potentialAttribute.equals(ENTITY_ATTR_ORGANIZATION_ID) ) {
+ addAttr(builder, potentialAttribute, attributes.getInt(potentialAttribute));
+ }
+ else {
+ addAttr(builder, potentialAttribute, attributes.getString(potentialAttribute));
+ }
+ }
+ }
+ ConnectorObject connectorObject = builder.build();
+ handler.handle(connectorObject);
+ }
+
}