Package org.apache.marmotta.platform.core.api.task

Examples of org.apache.marmotta.platform.core.api.task.Task


        // TODO: need to figure out format automatically!
        RDFFormat f = getFormat(format);

        final String taskName = String.format("RDF Importer Task %d (%s)", ++taskCounter, f.getName());
        Task task = taskManagerService.createSubTask(taskName,"Importer");
        task.updateMessage("importing data into Apache Marmotta repository");
        task.updateDetailMessage("format", f.getDefaultMIMEType());
        task.updateDetailMessage("baseUri", baseUri);

        int count = 0;

        try {
            if (is != null) {
View Full Code Here


        // TODO: need to figure out format automatically!
        RDFFormat f = getFormat(format);

        String baseUri = configurationService.getBaseUri() + "resource/";
        final String taskName = String.format("RDF Importer Task %d (%s)", ++taskCounter, f.getName());
        Task task = taskManagerService.createSubTask(taskName, "Importer");
        task.updateMessage("importing data into Apache Marmotta repository");
        task.updateDetailMessage("format", f.getDefaultMIMEType());
        task.updateDetailMessage("baseURI", baseUri);

        int count = 0;

        try {
            if (reader != null) {
View Full Code Here

        }
        if (type == null || !importService.getAcceptTypes().contains(type)) return Response.status(412).entity("define a valid content-type (types: "+importService.getAcceptTypes()+")").build();
        final String finalType = type;
        final InputStream in = request.getInputStream();

        Task t = taskManagerService.createTask(String.format("Upload-Import from %s (%s)", request.getRemoteHost(), finalType), TASK_GROUP_NAME);
        t.updateMessage("preparing import...");
        t.updateDetailMessage("type", finalType);
        try {
            //create context
            URI context = getContext(context_string);
            if (context != null) {
                t.updateDetailMessage("context", context.toString());
            }

            t.updateMessage("importing data...");
            importService.importData(in,finalType, userService.getCurrentUser(), context);
            t.updateMessage("import complete");

            return Response.ok().entity("import of content successful\n").build();
        } catch(Exception ex) {
            log.error("error while importing", ex);
            return Response.status(500).entity("error while importing: " + ex.getMessage()).build();
View Full Code Here

            final String finalType = type;
            Runnable r = new Runnable() {

                @Override
                public void run() {
                    Task task = taskManagerService.createTask("Import from external source", TASK_GROUP_NAME);
                    task.updateDetailMessage("source", finalUrl.toExternalForm());
                    task.updateDetailMessage("type", finalType);
                    if (context != null) {
                        task.updateDetailMessage("context", context.toString());
                    }
                    try {
                        importService.importData(finalUrl,finalType,userService.getCurrentUser(),context);
                    } catch(Exception e) {
                        log.error("exception while asynchronously importing data",e);
View Full Code Here

    @Override
    public void endTask(TaskInfo task) {
        final Stack<TaskImpl> stack = getStack();
        if (stack.contains(task)) {
            while (!stack.isEmpty()) {
                Task t = stack.pop();
                if (t.equals(task)) {
                    log.debug("Ending task {}.{}", t.getGroup(), t.getName());
                    break;
                } else {
                    log.debug("Ending task {}.{} because it's a sub-task", t.getGroup(), t.getName());
                    t.endTask();
                }
            }
            if (!stack.isEmpty()) {
                stack.peek().subTaskEnded();
            }
View Full Code Here

     * @see xx.test.taks.TaskManagerService#createTask(java.lang.String)
     */
    @Override
    public Task createTask(String name, String group) {
        final Stack<TaskImpl> stack = getStack();
        final Task task;
        if (stack.isEmpty())
            return createSubTask(name, group);
        else {
            task = stack.peek();
            task.updateName(name);
            if (group != null) {
                task.updateGroup(group);
            }
        }
        return task;
    }
View Full Code Here

        @Override
        public void run() {
            running = true;
            log.trace("Watchdog: starting up");
            final Task task = getTask();
            int count = 0;
            while (running) {
                task.updateMessage("cleaning up");
                task.updateProgress(++count);
                try {
                    HashSet<Thread> dead = new HashSet<Thread>();
                    for (Thread t : tasks.keySet()) {
                        if (!t.isAlive()) {
                            dead.add(t);
                        }
                    }
                    for (Thread t : dead) {
                        log.debug("Watchdog: cleaning up dead thread " + t.getName());
                        tasks.remove(t);
                        t = null;
                    }
                    dead.clear();
                    dead = null;
                    task.updateMessage("sleeping");
                    synchronized (ThreadWatchdog.this) {
                        this.wait(millis);
                    }
                } catch (InterruptedException e) {
                    // ignore
                }
            }
            task.endTask();
            log.trace("Watchdog: shutdown");
        }
View Full Code Here

TOP

Related Classes of org.apache.marmotta.platform.core.api.task.Task

Copyright © 2018 www.massapicom. 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.