You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by as...@apache.org on 2013/01/15 14:10:48 UTC
svn commit: r1433389 - in
/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy:
PolicyServiceProxy.java TaskServiceProxy.java
Author: ashakirin
Date: Tue Jan 15 13:10:48 2013
New Revision: 1433389
URL: http://svn.apache.org/viewvc?rev=1433389&view=rev
Log:
[SYNCOPE-259] Fixed policy service list method.
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java?rev=1433389&r1=1433388&r2=1433389&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java Tue Jan 15 13:10:48 2013
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.services.proxy;
+import java.util.Arrays;
import java.util.List;
import org.apache.syncope.client.to.AccountPolicyTO;
@@ -37,7 +38,7 @@ public class PolicyServiceProxy extends
public <T extends PolicyTO> T create(PolicyType type, final T policyTO) {
@SuppressWarnings("unchecked")
T result = (T) getRestTemplate().postForObject(baseUrl + "policy/{kind}/create", policyTO, policyTO.getClass(),
- typeToUrl(policyTO.getType()));
+ typeToUrl(policyTO.getType()));
return result;
}
@@ -49,10 +50,27 @@ public class PolicyServiceProxy extends
}
@Override
+ @SuppressWarnings("unchecked")
public <T extends PolicyTO> List<T> listByType(PolicyType type) {
- @SuppressWarnings("unchecked")
- List<T> result = getRestTemplate().getForObject(baseUrl + "policy/{kind}/list", List.class, typeToUrl(type));
- return result;
+ switch (type) {
+ case ACCOUNT:
+ case GLOBAL_ACCOUNT:
+ return (List<T>) Arrays.asList(getRestTemplate().getForObject(
+ baseUrl + "policy/{kind}/list", AccountPolicyTO[].class,
+ type));
+ case PASSWORD:
+ case GLOBAL_PASSWORD:
+ return (List<T>) Arrays.asList(getRestTemplate().getForObject(
+ baseUrl + "policy/{kind}/list", PasswordPolicyTO[].class,
+ type));
+ case SYNC:
+ case GLOBAL_SYNC:
+ return (List<T>) Arrays.asList(getRestTemplate().getForObject(
+ baseUrl + "policy/{kind}/list", SyncPolicyTO[].class,
+ type));
+ default:
+ throw new IllegalArgumentException("Policy Type not supported: " + type);
+ }
}
@SuppressWarnings("unchecked")
@@ -70,21 +88,11 @@ public class PolicyServiceProxy extends
return result;
}
- private String typeToUrl(PolicyType type) {
- String url = type.name().toLowerCase();
- int index = url.indexOf("_");
- if (index != -1) {
- return url.substring(index + 1);
- } else {
- return url;
- }
- }
-
@Override
public <T extends PolicyTO> T update(PolicyType type, Long policyId, T policyTO) {
@SuppressWarnings("unchecked")
T result = (T) getRestTemplate().postForObject(baseUrl + "policy/{kind}/update", policyTO, policyTO.getClass(),
- typeToUrl(policyTO.getType()));
+ typeToUrl(policyTO.getType()));
return result;
}
@@ -104,4 +112,14 @@ public class PolicyServiceProxy extends
}
}
+ private String typeToUrl(PolicyType type) {
+ String url = type.name().toLowerCase();
+ int index = url.indexOf("_");
+ if (index != -1) {
+ return url.substring(index + 1);
+ } else {
+ return url;
+ }
+ }
+
}
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java?rev=1433389&r1=1433388&r2=1433389&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java Tue Jan 15 13:10:48 2013
@@ -123,7 +123,7 @@ public class TaskServiceProxy extends Sp
return (List<T>) Arrays.asList(getRestTemplate().getForObject(baseUrl + "task/{type}/list/{page}/{size}.json",
SyncTaskTO[].class, type, page, size));
default:
- throw new IllegalArgumentException("TaskType is not supported.");
+ throw new IllegalArgumentException("TaskType is not supported :" + type);
}
}