Examples of ApiClient


Examples of common.api.ApiClient

  public static void sortingFolder(@Required String folder) {
        User u = Login.getUser();
        folder = RuleUtils.normalize(folder, false);

      try {
          ApiClient api = ApiClientFactory.create(u);
          boolean createdFolder = false;
            if (! api.exists(folder)) {
                Logger.info("Folder does not exist attempting to create %s", folder);
                if (api.mkdir(folder)) {
                    Logger.info("Successfully created folder %s", folder);
                    createdFolder = true;
                } else {
                    Logger.error("Failed to create folder '%s'", folder);
                    flash.error("Error: folder %s is missing and we couldn't create it.", folder);
View Full Code Here

Examples of common.api.ApiClient

     *
     * @return list of file moves performed
     */
    public static List<FileMove> runRules(User user) {
        List<FileMove> fileMoves = Lists.newArrayList();
        ApiClient client = ApiClientFactory.create(user);
        try {
            Set<String> files = client.listDir(user.sortingFolder)

            if (files.isEmpty()) {
                Logger.info("Ran rules for %s, no files to process.", user);
                return fileMoves;
            }

            user.updateLastSyncDate();

            List<Rule> rules = Rule.findByUserId(user.getKey());
            Logger.info("Running rules for %s with files %s", user, files);

            for (String file : files) {
                String base = basename(file);
                for (Rule r : rules) {
                    if (r.matches(base)) {
                        Logger.info("Moving file '%s' to '%s'. Rule id: %s",
                                    file, r.dest, r.id);
                        boolean hasCollision = false;
                        String resolvedName = null;
                        for (int tries = 0; tries < MAX_TRIES; tries++) {
                            try {
                                String suffix = null;
                                if (hasCollision) {
                                    suffix = " conflict"
                                            + (tries > 1 ? " " + tries : "");
                                }

                                resolvedName = removeInvalidChars(insertIntoName(base, suffix));

                                String dest = r.dest +
                                              (r.dest.endsWith("/") ? "" : "/") +
                                              resolvedName;
                                client.move(file, dest);
                                break;
                            } catch (FileMoveCollisionException e) {
                                hasCollision = true;
                                resolvedName = null;
                            }
View Full Code Here

Examples of org.graylog2.restclient.lib.ApiClient

        });
        modules.add(new ModelFactoryModule());
        injector = Guice.createInjector(modules);

        // start the services that need starting
        final ApiClient api = injector.getInstance(ApiClient.class);
        api.start();
        injector.getInstance(ServerNodesRefreshService.class).start();
        // TODO replace with custom AuthenticatedAction filter
        RedirectAuthenticator.userService = injector.getInstance(UserService.class);
        RedirectAuthenticator.sessionService = injector.getInstance(SessionService.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.