Return-Path: X-Original-To: apmail-ace-commits-archive@www.apache.org Delivered-To: apmail-ace-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7A0E410D97 for ; Mon, 15 Jul 2013 13:40:10 +0000 (UTC) Received: (qmail 81100 invoked by uid 500); 15 Jul 2013 13:40:10 -0000 Delivered-To: apmail-ace-commits-archive@ace.apache.org Received: (qmail 81074 invoked by uid 500); 15 Jul 2013 13:40:10 -0000 Mailing-List: contact commits-help@ace.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ace.apache.org Delivered-To: mailing list commits@ace.apache.org Received: (qmail 81065 invoked by uid 99); 15 Jul 2013 13:40:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jul 2013 13:40:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jul 2013 13:40:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8B9D7238889B; Mon, 15 Jul 2013 13:39:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1503240 - in /ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest: Activator.java CollectionCommands.java Workspace.java Date: Mon, 15 Jul 2013 13:39:48 -0000 To: commits@ace.apache.org From: marrs@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130715133948.8B9D7238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 lt(String filter) throws Exception { return getObjectRepository(TARGET).get(m_context.createFilter(filter)); } - - public void ct(String name) { + + public RepositoryObject ct(String name) { Map attrs = new HashMap(); attrs.put(StatefulTargetObject.KEY_ID, name); - ct(attrs); + return ct(attrs); } - public void ct(Map attrs) { - ct(attrs, new HashMap()); + public RepositoryObject ct(Map attrs) { + return ct(attrs, new HashMap()); } - public void ct(Map attrs, Map tags) { - addRepositoryObject(TARGET, attrs, tags); + public RepositoryObject ct(Map attrs, Map tags) { + return addRepositoryObject(TARGET, attrs, tags); }