/** * Specialized parameter processing method for commands with 'fromFile' and * 'toFiles' parameters. */ public static String[] processParameters(final Options opts, final IFileSpec fromFileSpec, final List<IFileSpec> toFileSpecs, final String[] stringParams, final IServer server) throws P4JavaException { List<String> args = new ArrayList<>(); addOpts(args, opts, server); if (nonNull(stringParams)) { for (String param : stringParams) { if (isNotBlank(param)) { args.add(param); } } } addFileSpec(args, fromFileSpec); return addFileSpecs(args, toFileSpecs); }
addOpts(args, opts, server); addFileSpecIfValidFileSpec(args, fromFiles); addFileSpecIfValidFileSpec(args, toFiles); return args.toArray(new String[args.size()]);
final IServer server) throws P4JavaException { List<String> args = new ArrayList<>(); addOpts(args, opts, server); return addFileSpecs(args, fileSpecs); } else { return addUnannotatedFileSpecs(args, fileSpecs);
/** * Version of processParameters for those rare methods that have no * non-Options arguments. * * @param opts possibly-null Options object; if null, no options are set. * @param server possibly-null server object; default behaviour when this is * null is to ignore it, and no parameter validation will be * done. * @return non-null but possibly empty array of strings suitable for using * as-is with the IServer.execMapCmd etc. methods. * @throws P4JavaException thrown if any error is detected. */ public static String[] processParameters(final Options opts, final IServer server) throws P4JavaException { return processParameters(opts, null, null, true, server); }
private static String[] addFileSpecs(@Nonnull final List<String> args, @Nullable final List<IFileSpec> fileSpecs) { Validate.notNull(args); if (nonNull(fileSpecs)) { for (IFileSpec fSpec : fileSpecs) { addFileSpec(args, fSpec); } } return args.toArray(new String[args.size()]); }
/** * Version of processParameters for those rare methods that have no * non-Options arguments. * * @param opts possibly-null Options object; if null, no options are set. * @param server possibly-null server object; default behaviour when this is * null is to ignore it, and no parameter validation will be * done. * @return non-null but possibly empty array of strings suitable for using * as-is with the IServer.execMapCmd etc. methods. * @throws P4JavaException thrown if any error is detected. */ public static String[] processParameters(final Options opts, final IServer server) throws P4JavaException { return processParameters(opts, null, null, true, server); }
private static String[] addFileSpecs(@Nonnull final List<String> args, @Nullable final List<IFileSpec> fileSpecs) { Validate.notNull(args); if (nonNull(fileSpecs)) { for (IFileSpec fSpec : fileSpecs) { addFileSpec(args, fSpec); } } return args.toArray(new String[args.size()]); }
@Override public List<Map<String, Object>> login2(Login2Options opts, String user) throws P4JavaException { String[] params; if (user == null || user.isEmpty()) { params = processParameters(opts, server); } else { params = processParameters(opts, null, user, server); } List<Map<String, Object>> resultMaps = execMapCmdList(LOGIN2, params, null); return resultMaps; }
/** * Specialized parameter processing method for commands with 'fromFile' and * 'toFiles' parameters. */ public static String[] processParameters(final Options opts, final IFileSpec fromFileSpec, final List<IFileSpec> toFileSpecs, final String[] stringParams, final IServer server) throws P4JavaException { List<String> args = new ArrayList<>(); addOpts(args, opts, server); if (nonNull(stringParams)) { for (String param : stringParams) { if (isNotBlank(param)) { args.add(param); } } } addFileSpec(args, fromFileSpec); return addFileSpecs(args, toFileSpecs); }
final IServer server) throws P4JavaException { List<String> args = new ArrayList<>(); addOpts(args, opts, server); return addFileSpecs(args, fileSpecs); } else { return addUnannotatedFileSpecs(args, fileSpecs);
addOpts(args, opts, server); addFileSpecIfValidFileSpec(args, fromFiles); addFileSpecIfValidFileSpec(args, toFiles); return args.toArray(new String[args.size()]);
@Override public List<Map<String, Object>> login2(Login2Options opts, String user) throws P4JavaException { String[] params; if (user == null || user.isEmpty()) { params = processParameters(opts, server); } else { params = processParameters(opts, null, user, server); } List<Map<String, Object>> resultMaps = execMapCmdList(LOGIN2, params, null); return resultMaps; }
@Override public InputStream getBlobObject(String repo, String sha) throws P4JavaException { InputStream inputStream = execStreamCmd( GRAPH, Parameters.processParameters( null, null, new String[]{"cat-file", "-n", repo, "blob", sha}, server) ); return inputStream; }
@Override public InputStream getChangelistDiffs(final int changelistId, final GetChangelistDiffsOptions opts) throws P4JavaException { return execStreamCmd(DESCRIBE, processParameters(opts, null, String.valueOf(changelistId), server)); }
@Override public InputStream getChangelistDiffs(final int changelistId, final GetChangelistDiffsOptions opts) throws P4JavaException { return execStreamCmd(DESCRIBE, processParameters(opts, null, String.valueOf(changelistId), server)); }
@Override public InputStream getBlobObject(String repo, String sha) throws P4JavaException { InputStream inputStream = execStreamCmd( GRAPH, Parameters.processParameters( null, null, new String[]{"cat-file", "-n", repo, "blob", sha}, server) ); return inputStream; }
@Override public InputStream getFileDiffsStream( final IFileSpec file1, final IFileSpec file2, final String branchSpecName, final GetFileDiffsOptions opts) throws P4JavaException { return execStreamCmd( DIFF2, processParameters( opts, file1, file2, branchSpecName, server) ); }
@Override public InputStream getFileDiffsStream( final IFileSpec file1, final IFileSpec file2, final String branchSpecName, final GetFileDiffsOptions opts) throws P4JavaException { return execStreamCmd( DIFF2, processParameters( opts, file1, file2, branchSpecName, server) ); }
@Override public List<IChangelist> getInterchanges(final IFileSpec fromFile, final IFileSpec toFile, final GetInterchangesOptions opts) throws P4JavaException { List<IFileSpec> files = new ArrayList<>(); files.add(fromFile); files.add(toFile); List<Map<String, Object>> resultMaps = execMapCmdList(INTERCHANGES, processParameters(opts, files, server), null); return processInterchangeMaps(resultMaps, InterchangesDelegatorHidden.isListIndividualFilesThatRequireIntegration(opts)); }
@Override public String deleteStream( @Nonnull final String streamPath, final StreamOptions opts) throws P4JavaException { Validate.notBlank(streamPath, "Stream name shouldn't null or empty."); List<Map<String, Object>> resultMaps = execMapCmdList( STREAM, processParameters(opts, null, new String[]{"-d", streamPath}, server), null); return parseCommandResultMapIfIsInfoMessageAsString(resultMaps); } }