You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2013/01/22 16:21:00 UTC
svn commit: r1436993 - in /syncope/branches/1_0_X/core/src:
main/java/org/apache/syncope/core/propagation/
test/java/org/apache/syncope/core/rest/
Author: fmartelli
Date: Tue Jan 22 15:21:00 2013
New Revision: 1436993
URL: http://svn.apache.org/viewvc?rev=1436993&view=rev
Log:
SYNCOPE-279 - little refactoring
Modified:
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/AsyncConnectorFacade.java
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/ConnectorFacadeProxy.java
syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
Modified: syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/AsyncConnectorFacade.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/AsyncConnectorFacade.java?rev=1436993&r1=1436992&r2=1436993&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/AsyncConnectorFacade.java (original)
+++ syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/AsyncConnectorFacade.java Tue Jan 22 15:21:00 2013
@@ -147,12 +147,11 @@ public class AsyncConnectorFacade {
Attribute attribute = null;
- try {
- final ConnectorObject object = connector.getObject(objectClass, uid, options);
- attribute = object.getAttributeByName(attributeName);
- } catch (NullPointerException e) {
- // ignore exception
+ final ConnectorObject object = connector.getObject(objectClass, uid, options);
+ if (object == null) {
LOG.debug("Object for '{}' not found", uid.getUidValue());
+ } else {
+ attribute = object.getAttributeByName(attributeName);
}
return new AsyncResult<Attribute>(attribute);
@@ -167,15 +166,14 @@ public class AsyncConnectorFacade {
final Set<Attribute> attributes = new HashSet<Attribute>();
- try {
- final ConnectorObject object = connector.getObject(objectClass, uid, options);
+ final ConnectorObject object = connector.getObject(objectClass, uid, options);
+ if (object == null) {
+ LOG.debug("Object for '{}' not found", uid.getUidValue());
+ } else {
for (String attribute : options.getAttributesToGet()) {
attributes.add(object.getAttributeByName(attribute));
}
- } catch (NullPointerException e) {
- // ignore exception
- LOG.debug("Object for '{}' not found", uid.getUidValue());
}
return new AsyncResult<Set<Attribute>>(attributes);
Modified: syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/ConnectorFacadeProxy.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/ConnectorFacadeProxy.java?rev=1436993&r1=1436992&r2=1436993&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/ConnectorFacadeProxy.java (original)
+++ syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/ConnectorFacadeProxy.java Tue Jan 22 15:21:00 2013
@@ -24,10 +24,8 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
import javassist.NotFoundException;
import org.apache.syncope.core.persistence.beans.ConnInstance;
import org.apache.syncope.core.persistence.beans.ExternalResource;
@@ -487,17 +485,9 @@ public class ConnectorFacadeProxy {
*/
public Attribute getObjectAttribute(final ObjectClass objectClass, final Uid uid, final OperationOptions options,
final String attributeName) {
-
- Attribute attribute = null;
-
try {
- final Future<Attribute> future =
- asyncFacade.getObjectAttribute(connector, objectClass, uid, options, attributeName);
-
- attribute = future.get(timeout, TimeUnit.SECONDS);
- } catch (NullPointerException e) {
- // ignore exception
- LOG.debug("Object for '{}' not found", uid.getUidValue());
+ return asyncFacade.getObjectAttribute(connector, objectClass, uid, options, attributeName).
+ get(timeout, TimeUnit.SECONDS);
} catch (java.util.concurrent.TimeoutException e) {
throw new TimeoutException("Request timeout");
} catch (Exception e) {
@@ -508,8 +498,6 @@ public class ConnectorFacadeProxy {
throw new IllegalArgumentException(e.getCause());
}
}
-
- return attribute;
}
/**
@@ -523,14 +511,8 @@ public class ConnectorFacadeProxy {
public Set<Attribute> getObjectAttributes(final ObjectClass objectClass, final Uid uid,
final OperationOptions options) {
- final Set<Attribute> attributes = new HashSet<Attribute>();
-
try {
- final Future<Set<Attribute>> future = asyncFacade.getObjectAttributes(connector, objectClass, uid, options);
- attributes.addAll(future.get(timeout, TimeUnit.SECONDS));
- } catch (NullPointerException e) {
- // ignore exception
- LOG.debug("Object for '{}' not found", uid.getUidValue());
+ return asyncFacade.getObjectAttributes(connector, objectClass, uid, options).get(timeout, TimeUnit.SECONDS);
} catch (java.util.concurrent.TimeoutException e) {
throw new TimeoutException("Request timeout");
} catch (Exception e) {
@@ -541,8 +523,6 @@ public class ConnectorFacadeProxy {
throw new IllegalArgumentException(e.getCause());
}
}
-
- return attributes;
}
/**
@@ -552,12 +532,8 @@ public class ConnectorFacadeProxy {
* @return a list of schema names.
*/
public Set<String> getSchema(final boolean showall) {
- final Set<String> resourceSchemaNames = new HashSet<String>();
-
- final Future<Set<String>> future = asyncFacade.getSchema(connector, showall);
-
try {
- resourceSchemaNames.addAll(future.get(timeout, TimeUnit.SECONDS));
+ return asyncFacade.getSchema(connector, showall).get(timeout, TimeUnit.SECONDS);
} catch (java.util.concurrent.TimeoutException e) {
throw new TimeoutException("Request timeout");
} catch (Exception e) {
@@ -568,9 +544,6 @@ public class ConnectorFacadeProxy {
throw new IllegalArgumentException(e.getCause());
}
}
-
- return resourceSchemaNames;
-
}
/**
Modified: syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1436993&r1=1436992&r2=1436993&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Tue Jan 22 15:21:00 2013
@@ -2210,7 +2210,7 @@ public class UserTestITCase extends Abst
@Test(expected = SyncopeClientCompositeErrorException.class)
public void issueSYNCOPE279() {
- UserTO userTO = getSampleTO("syncope260@apache.org");
+ UserTO userTO = getSampleTO("syncope279@apache.org");
userTO.getResources().clear();
userTO.addResource("ws-target-resource-3");
restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);