/******************************************************************************* * Copyright (c) 2013, Perforce Software * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package com.perforce.p4java.extension.operation; import java.util.ArrayList; import java.util.List; import java.util.Map; import com.perforce.p4java.extension.command.PerforceDomain; import com.perforce.p4java.extension.exception.ServerAccessException; import com.perforce.p4java.extension.exception.ServerConnectionException; import com.perforce.p4java.extension.exception.ServerErrorException; import com.perforce.p4java.extension.server.Server; /** * */ public class DepotsCommand extends Command<Map<String, Object>[]> { public static String tagType = "type"; public static String tagName = "name"; public static String tagTypeLocal = "local"; public static String tagTypeStream = "stream"; public static String[] getDepotsOfType(String type, Server server) throws ServerConnectionException, ServerAccessException, ServerErrorException { Map<String, Object>[] depots = getDepots(server); List<String> depotNames = new ArrayList<String>(); for (Map<String, Object> depot : depots) { if (!depot.containsKey("type") || !depot.containsKey("name")) continue; if (type.equals((String) depot.get("type"))) depotNames.add((String) depot.get("name")); } return depotNames.toArray(new String[depotNames.size()]); } public static Map<String, Object>[] getDepots(Server server) throws ServerConnectionException, ServerAccessException, ServerErrorException { DepotsCommand cmd = new DepotsCommand(); return cmd.executeModelRequest(server); } public DepotsCommand() { super(PerforceDomain.DEPOTS); } /** * @see com.perforce.p4java.extension.command.Request#getInputString() */ public String getInputString() { return null; } /** * @see * com.perforce.nuapi.operation.Command#process(java.util.Map<java.lang. * String,java.lang.Object>[]) */ @Override protected Map<String, Object>[] process(Map<String, Object>[] maps) { return maps; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 18866 | Sven Erik Knop | Updated with latest version | ||
#1 | 9795 | Sven Erik Knop |
Populate //guest/sven_erik_knop/p4search/... from //guest/perforce_software/p4search/.... |
||
//guest/perforce_software/p4search/search/webapp/src/main/java/com/perforce/p4java/extension/operation/DepotsCommand.java | |||||
#1 | 8975 | Matt Attaway | Populate official version of p4-search from the original Doug Scheirer source |