You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ma...@apache.org on 2011/09/02 15:06:22 UTC

svn commit: r1164519 - /incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java

Author: marrs
Date: Fri Sep  2 13:06:22 2011
New Revision: 1164519

URL: http://svn.apache.org/viewvc?rev=1164519&view=rev
Log:
ACE-151 reformatted the source to better comply with our style guide

Modified:
    incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java

Modified: incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java?rev=1164519&r1=1164518&r2=1164519&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java (original)
+++ incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java Fri Sep  2 13:06:22 2011
@@ -31,7 +31,6 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.RepositoryAdmin;
 import org.apache.ace.client.repository.RepositoryObject;
 import org.apache.ace.client.repository.SessionFactory;
-import org.apache.ace.client.repository.object.ArtifactObject;
 import org.apache.ace.client.repository.repository.Artifact2GroupAssociationRepository;
 import org.apache.ace.client.repository.repository.ArtifactRepository;
 import org.apache.ace.client.repository.repository.GatewayRepository;
@@ -145,189 +144,155 @@ public class Workspace {
         m_repositoryAdmin.commit();
     }
 
-	public RepositoryObject getRepositoryObject(String entityType,
-			String entityId) {
-		return getObjectRepository(entityType).get(entityId);
-	}
-
-	public static String getRepositoryObjectIdentity(RepositoryObject object) {
-		return object.getDefinition();
-	}
-
-	public List<RepositoryObject> getRepositoryObjects(String entityType) {
-		List list = getObjectRepository(entityType).get();
-		if (list != null) {
-			return list;
-		} else {
-			return Collections.EMPTY_LIST;
-		}
-	}
-
-	public RepositoryObject addRepositoryObject(String entityType,
-			Map<String, String> attributes, Map<String, String> tags)
-			throws IllegalArgumentException {
-		if (TARGET.equals(entityType)) {
-			return ((StatefulGatewayRepository) getObjectRepository(TARGET))
-					.preregister(attributes, tags);
-		} else {
-			if (ARTIFACT2FEATURE.equals(entityType)
-					|| FEATURE2DISTRIBUTION.equals(entityType)
-					|| DISTRIBUTION2TARGET.equals(entityType)) {
-				RepositoryObject left = getLeft(entityType,
-						attributes.get("left"));
-				RepositoryObject right = getRight(entityType,
-						attributes.get("right"));
-				if (left != null) {
-					if (left instanceof StatefulGatewayObject) {
-						if (((StatefulGatewayObject) left).isRegistered()) {
-							attributes.put("leftEndpoint",
-									((StatefulGatewayObject) left)
-											.getGatewayObject()
-											.getAssociationFilter(attributes));
-						}
-					} else {
-						attributes.put("leftEndpoint",
-								left.getAssociationFilter(attributes));
-					}
-				}
-				if (right != null) {
-					if (right instanceof StatefulGatewayObject) {
-						if (((StatefulGatewayObject) right).isRegistered()) {
-							attributes.put("rightEndpoint",
-									((StatefulGatewayObject) right)
-											.getGatewayObject()
-											.getAssociationFilter(attributes));
-						}
-					} else {
-						attributes.put("rightEndpoint",
-								right.getAssociationFilter(attributes));
-					}
-				}
-			}
-			return getObjectRepository(entityType).create(attributes, tags);
-		}
-	}
-
-	public void updateObjectWithData(String entityType, String entityId,
-			RepositoryValueObject valueObject) {
-		RepositoryObject repositoryObject = getRepositoryObject(entityType,
-				entityId);
-		// first handle the attributes
-		for (Entry<String, String> attribute : valueObject.attributes
-				.entrySet()) {
-			String key = attribute.getKey();
-			String value = attribute.getValue();
-			// only add/update the attribute if it actually changed
-			if (!value.equals(repositoryObject.getAttribute(key))) {
-				repositoryObject.addAttribute(key, value);
-			}
-		}
-		Enumeration<String> keys = repositoryObject.getAttributeKeys();
-		while (keys.hasMoreElements()) {
-			String key = keys.nextElement();
-			if (!valueObject.attributes.containsKey(key)) {
-				// TODO since we cannot remove keys right now, we null them
-				repositoryObject.addAttribute(key, null);
-			}
-		}
-		if (ARTIFACT2FEATURE.equals(entityType)
-				|| FEATURE2DISTRIBUTION.equals(entityType)
-				|| DISTRIBUTION2TARGET.equals(entityType)) {
-			RepositoryObject left = getLeft(entityType,
-					repositoryObject.getAttribute("left"));
-			RepositoryObject right = getRight(entityType,
-					repositoryObject.getAttribute("right"));
-			if (left != null) {
-				if (left instanceof StatefulGatewayObject) {
-					if (((StatefulGatewayObject) left).isRegistered()) {
-						repositoryObject
-								.addAttribute(
-										"leftEndpoint",
-										((StatefulGatewayObject) left)
-												.getGatewayObject()
-												.getAssociationFilter(
-														getAttributes(((StatefulGatewayObject) left)
-																.getGatewayObject())));
-					}
-				} else {
-					repositoryObject.addAttribute("leftEndpoint",
-							left.getAssociationFilter(getAttributes(left)));
-				}
-			}
-			if (right != null) {
-				if (right instanceof StatefulGatewayObject) {
-					if (((StatefulGatewayObject) right).isRegistered()) {
-						repositoryObject
-								.addAttribute(
-										"rightEndpoint",
-										((StatefulGatewayObject) right)
-												.getGatewayObject()
-												.getAssociationFilter(
-														getAttributes(((StatefulGatewayObject) right)
-																.getGatewayObject())));
-					}
-				} else {
-					repositoryObject.addAttribute("rightEndpoint",
-							right.getAssociationFilter(getAttributes(right)));
-				}
-			}
-		}
-		// now handle the tags in a similar way
-		for (Entry<String, String> attribute : valueObject.tags.entrySet()) {
-			String key = attribute.getKey();
-			String value = attribute.getValue();
-			// only add/update the tag if it actually changed
-			if (!value.equals(repositoryObject.getTag(key))) {
-				repositoryObject.addTag(key, value);
-			}
-		}
-		keys = repositoryObject.getTagKeys();
-		while (keys.hasMoreElements()) {
-			String key = keys.nextElement();
-			if (!valueObject.tags.containsKey(key)) {
-				// TODO since we cannot remove keys right now, we null them
-				repositoryObject.addTag(key, null);
-			}
-		}
-	}
-
-	private Map getAttributes(RepositoryObject object) {
-		Map result = new HashMap();
-		for (Enumeration<String> keys = object.getAttributeKeys(); keys
-				.hasMoreElements();) {
-			String key = keys.nextElement();
-			result.put(key, object.getAttribute(key));
-		}
-		return result;
-	}
-
-	public RepositoryObject getLeft(String entityType, String entityId) {
-		ObjectRepository repo = getObjectRepository(entityType);
-		if (ARTIFACT2FEATURE.equals(entityType)) {
-			return getObjectRepository(ARTIFACT).get(entityId);
-		}
-		if (FEATURE2DISTRIBUTION.equals(entityType)) {
-			return getObjectRepository(FEATURE).get(entityId);
-		}
-		if (DISTRIBUTION2TARGET.equals(entityType)) {
-			return getObjectRepository(DISTRIBUTION).get(entityId);
-		}
-		return null;
-	}
-
-	public RepositoryObject getRight(String entityType, String entityId) {
-		ObjectRepository repo = getObjectRepository(entityType);
-		if (ARTIFACT2FEATURE.equals(entityType)) {
-			return getObjectRepository(FEATURE).get(entityId);
-		}
-		if (FEATURE2DISTRIBUTION.equals(entityType)) {
-			return getObjectRepository(DISTRIBUTION).get(entityId);
-		}
-		if (DISTRIBUTION2TARGET.equals(entityType)) {
-			return getObjectRepository(TARGET).get(entityId);
-		}
-		return null;
-	}
+    public RepositoryObject getRepositoryObject(String entityType, String entityId) {
+        return getObjectRepository(entityType).get(entityId);
+    }
+
+    public static String getRepositoryObjectIdentity(RepositoryObject object) {
+        return object.getDefinition();
+    }
+
+    public List<RepositoryObject> getRepositoryObjects(String entityType) {
+        List list = getObjectRepository(entityType).get();
+        if (list != null) {
+            return list;
+        }
+        else {
+            return Collections.EMPTY_LIST;
+        }
+    }
+
+    public RepositoryObject addRepositoryObject(String entityType, Map<String, String> attributes, Map<String, String> tags) throws IllegalArgumentException {
+        if (TARGET.equals(entityType)) {
+            return ((StatefulGatewayRepository) getObjectRepository(TARGET)).preregister(attributes, tags);
+        }
+        else {
+            if (ARTIFACT2FEATURE.equals(entityType) || FEATURE2DISTRIBUTION.equals(entityType) || DISTRIBUTION2TARGET.equals(entityType)) {
+                RepositoryObject left = getLeft(entityType, attributes.get("left"));
+                RepositoryObject right = getRight(entityType, attributes.get("right"));
+                if (left != null) {
+                    if (left instanceof StatefulGatewayObject) {
+                        if (((StatefulGatewayObject) left).isRegistered()) {
+                            attributes.put("leftEndpoint", ((StatefulGatewayObject) left).getGatewayObject().getAssociationFilter(attributes));
+                        }
+                    }
+                    else {
+                        attributes.put("leftEndpoint", left.getAssociationFilter(attributes));
+                    }
+                }
+                if (right != null) {
+                    if (right instanceof StatefulGatewayObject) {
+                        if (((StatefulGatewayObject) right).isRegistered()) {
+                            attributes.put("rightEndpoint", ((StatefulGatewayObject) right).getGatewayObject().getAssociationFilter(attributes));
+                        }
+                    }
+                    else {
+                        attributes.put("rightEndpoint", right.getAssociationFilter(attributes));
+                    }
+                }
+            }
+            return getObjectRepository(entityType).create(attributes, tags);
+        }
+    }
+
+    public void updateObjectWithData(String entityType, String entityId, RepositoryValueObject valueObject) {
+        RepositoryObject repositoryObject = getRepositoryObject(entityType, entityId);
+        // first handle the attributes
+        for (Entry<String, String> attribute : valueObject.attributes.entrySet()) {
+            String key = attribute.getKey();
+            String value = attribute.getValue();
+            // only add/update the attribute if it actually changed
+            if (!value.equals(repositoryObject.getAttribute(key))) {
+                repositoryObject.addAttribute(key, value);
+            }
+        }
+        Enumeration<String> keys = repositoryObject.getAttributeKeys();
+        while (keys.hasMoreElements()) {
+            String key = keys.nextElement();
+            if (!valueObject.attributes.containsKey(key)) {
+                // TODO since we cannot remove keys right now, we null them
+                repositoryObject.addAttribute(key, null);
+            }
+        }
+        if (ARTIFACT2FEATURE.equals(entityType) || FEATURE2DISTRIBUTION.equals(entityType) || DISTRIBUTION2TARGET.equals(entityType)) {
+            RepositoryObject left = getLeft(entityType, repositoryObject.getAttribute("left"));
+            RepositoryObject right = getRight(entityType, repositoryObject.getAttribute("right"));
+            if (left != null) {
+                if (left instanceof StatefulGatewayObject) {
+                    if (((StatefulGatewayObject) left).isRegistered()) {
+                        repositoryObject.addAttribute("leftEndpoint", ((StatefulGatewayObject) left).getGatewayObject().getAssociationFilter(getAttributes(((StatefulGatewayObject) left).getGatewayObject())));
+                    }
+                }
+                else {
+                    repositoryObject.addAttribute("leftEndpoint", left.getAssociationFilter(getAttributes(left)));
+                }
+            }
+            if (right != null) {
+                if (right instanceof StatefulGatewayObject) {
+                    if (((StatefulGatewayObject) right).isRegistered()) {
+                        repositoryObject.addAttribute("rightEndpoint", ((StatefulGatewayObject) right).getGatewayObject().getAssociationFilter(getAttributes(((StatefulGatewayObject) right).getGatewayObject())));
+                    }
+                }
+                else {
+                    repositoryObject.addAttribute("rightEndpoint", right.getAssociationFilter(getAttributes(right)));
+                }
+            }
+        }
+        // now handle the tags in a similar way
+        for (Entry<String, String> attribute : valueObject.tags.entrySet()) {
+            String key = attribute.getKey();
+            String value = attribute.getValue();
+            // only add/update the tag if it actually changed
+            if (!value.equals(repositoryObject.getTag(key))) {
+                repositoryObject.addTag(key, value);
+            }
+        }
+        keys = repositoryObject.getTagKeys();
+        while (keys.hasMoreElements()) {
+            String key = keys.nextElement();
+            if (!valueObject.tags.containsKey(key)) {
+                // TODO since we cannot remove keys right now, we null them
+                repositoryObject.addTag(key, null);
+            }
+        }
+    }
+
+    private Map getAttributes(RepositoryObject object) {
+        Map result = new HashMap();
+        for (Enumeration<String> keys = object.getAttributeKeys(); keys.hasMoreElements();) {
+            String key = keys.nextElement();
+            result.put(key, object.getAttribute(key));
+        }
+        return result;
+    }
+
+    public RepositoryObject getLeft(String entityType, String entityId) {
+        ObjectRepository repo = getObjectRepository(entityType);
+        if (ARTIFACT2FEATURE.equals(entityType)) {
+            return getObjectRepository(ARTIFACT).get(entityId);
+        }
+        if (FEATURE2DISTRIBUTION.equals(entityType)) {
+            return getObjectRepository(FEATURE).get(entityId);
+        }
+        if (DISTRIBUTION2TARGET.equals(entityType)) {
+            return getObjectRepository(DISTRIBUTION).get(entityId);
+        }
+        return null;
+    }
+
+    public RepositoryObject getRight(String entityType, String entityId) {
+        ObjectRepository repo = getObjectRepository(entityType);
+        if (ARTIFACT2FEATURE.equals(entityType)) {
+            return getObjectRepository(FEATURE).get(entityId);
+        }
+        if (FEATURE2DISTRIBUTION.equals(entityType)) {
+            return getObjectRepository(DISTRIBUTION).get(entityId);
+        }
+        if (DISTRIBUTION2TARGET.equals(entityType)) {
+            return getObjectRepository(TARGET).get(entityId);
+        }
+        return null;
+    }
     
     public void deleteRepositoryObject(String entityType, String entityId) {
         RepositoryObject result = null;