Author: marrs
Date: Mon Jul 15 13:39:48 2013
New Revision: 1503240
URL: http://svn.apache.org/r1503240
Log:
ACE-366 Added a few generic commands to handle collections. Added and changed a
few commands in the workspace.
Added:
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/CollectionCommands.java
Modified:
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Activator.java
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java
Modified:
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Activator.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Activator.java?rev=1503240&r1=1503239&r2=1503240&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Activator.java
(original)
+++
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Activator.java
Mon Jul 15 13:39:48 2013
@@ -53,6 +53,13 @@ public class Activator extends Dependenc
.setRequired(false)
)
);
+ Properties listProps = new Properties();
+ listProps.put(CommandProcessor.COMMAND_SCOPE, "coll");
+ listProps.put(CommandProcessor.COMMAND_FUNCTION, new String[] {
"first", "rest" });
+ manager.add(createComponent()
+ .setInterface(Object.class.getName(), listProps)
+ .setImplementation(CollectionCommands.class)
+ );
}
@Override
Added:
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/CollectionCommands.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/CollectionCommands.java?rev=1503240&view=auto
==============================================================================
---
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/CollectionCommands.java
(added)
+++
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/CollectionCommands.java
Mon Jul 15 13:39:48 2013
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.client.rest;
+
+import java.util.List;
+
+public class CollectionCommands {
+ /** Returns the first object in a list. */
+ public Object first(List list) {
+ if (list != null && !list.isEmpty()) {
+ return list.get(0);
+ }
+ return null;
+ }
+
+ /** Returns the rest of the list, meaning everything but the first object.
*/
+ public List rest(List list) {
+ if (list != null && !list.isEmpty() && list.size() > 1) {
+ return list.subList(1, list.size());
+ }
+ return null;
+ }
+}
Modified:
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java?rev=1503240&r1=1503239&r2=1503240&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java
(original)
+++
ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java
Mon Jul 15 13:39:48 2013
@@ -575,19 +575,19 @@ public class Workspace {
public List<RepositoryObject> lt(String filter) throws Exception {
return getObjectRepository(TARGET).get(m_context.createFilter(filter));
}
-
- public void ct(String name) {
+
+ public RepositoryObject ct(String name) {
Map<String, String> attrs = new HashMap<String, String>();
attrs.put(StatefulTargetObject.KEY_ID, name);
- ct(attrs);
+ return ct(attrs);
}
- public void ct(Map<String, String> attrs) {
- ct(attrs, new HashMap<String, String>());
+ public RepositoryObject ct(Map<String, String> attrs) {
+ return ct(attrs, new HashMap<String, String>());
}
- public void ct(Map<String, String> attrs, Map<String, String> tags) {
- addRepositoryObject(TARGET, attrs, tags);
+ public RepositoryObject ct(Map<String, String> attrs, Map<String, String>
tags) {
+ return addRepositoryObject(TARGET, attrs, tags);
}