Juan Hernandez has uploaded a new change for review.

Change subject: restapi: Remove unused classes
......................................................................

restapi: Remove unused classes

This patch removes unused classes and dependencies from the RESTAPI
"interface-common-jaxrs" module.

Change-Id: Ia28854f308c56e7ca48c127eae30329b3aea6b1c
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M backend/manager/modules/restapi/interface/common/jaxrs/pom.xml
D 
backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/AbstractActionableResource.java
D 
backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/AbstractUpdatableResource.java
D 
backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/BaseActionResource.java
D 
backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/UriInfoProvider.java
M 
backend/manager/modules/restapi/interface/common/jaxrs/src/main/modules/org/ovirt/engine/api/interface-common-jaxrs/main/module.xml
6 files changed, 0 insertions(+), 436 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/28/40328/1

diff --git a/backend/manager/modules/restapi/interface/common/jaxrs/pom.xml 
b/backend/manager/modules/restapi/interface/common/jaxrs/pom.xml
index 52a169d..e673fcb 100644
--- a/backend/manager/modules/restapi/interface/common/jaxrs/pom.xml
+++ b/backend/manager/modules/restapi/interface/common/jaxrs/pom.xml
@@ -40,11 +40,6 @@
     </dependency>
 
     <dependency>
-      <groupId>commons-codec</groupId>
-      <artifactId>commons-codec</artifactId>
-    </dependency>
-
-    <dependency>
       <groupId>commons-collections</groupId>
       <artifactId>commons-collections</artifactId>
     </dependency>
@@ -57,13 +52,6 @@
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpcore</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jboss.spec.javax.security.jacc</groupId>
-      <artifactId>jboss-jacc-api_1.4_spec</artifactId>
-      <version>1.0.1.Final</version>
-      <scope>provided</scope>
     </dependency>
 
     <dependency>
diff --git 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/AbstractActionableResource.java
 
b/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/AbstractActionableResource.java
deleted file mode 100644
index b3ef56a..0000000
--- 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/AbstractActionableResource.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
-* Copyright (c) 2010 Red Hat, Inc.
-*
-* Licensed 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.ovirt.engine.api.common.resource;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URI;
-import java.text.MessageFormat;
-import java.util.concurrent.Executor;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-
-import org.ovirt.engine.api.common.util.StatusUtils;
-import org.ovirt.engine.api.model.Action;
-import org.ovirt.engine.api.model.BaseResource;
-import org.ovirt.engine.api.model.CreationStatus;
-import org.ovirt.engine.api.model.Fault;
-import org.ovirt.engine.api.resource.ActionResource;
-import org.ovirt.engine.api.utils.LinkHelper;
-import org.ovirt.engine.core.utils.ReapedMap;
-
-public abstract class AbstractActionableResource<R extends BaseResource> 
extends AbstractUpdatableResource<R> {
-
-    private static final long REAP_AFTER = 2 * 60 * 60 * 1000L; // 2 hours
-
-    protected Executor executor;
-    protected ReapedMap<String, ActionResource> actions;
-    protected UriInfoProvider uriProvider;
-
-    public AbstractActionableResource(String id) {
-        this(id, new SimpleExecutor());
-    }
-
-    public AbstractActionableResource(String id, Executor executor) {
-        super(id);
-        this.executor = executor;
-        actions = new ReapedMap<String, ActionResource>(REAP_AFTER);
-    }
-
-    public AbstractActionableResource(String id, Executor executor, 
UriInfoProvider uriProvider) {
-        super(id);
-        this.executor = executor;
-        this.uriProvider = uriProvider;
-        actions = new ReapedMap<String, ActionResource>(REAP_AFTER);
-    }
-
-    protected UriInfo getUriInfo() {
-        return uriProvider.getUriInfo();
-    }
-
-    public UriInfoProvider getUriProvider() {
-        return uriProvider;
-    }
-
-    protected R getModel() {
-        R parent = newModel();
-        parent.setId(getId());
-        return parent;
-    }
-
-    /**
-     * Perform an action, managing asynchrony and returning an appropriate
-     * response.
-     *
-     * @param uriInfo  wraps the URI for the current request
-     * @param action   represents the pending action
-     * @param task     fulfils the action
-     * @return
-     */
-    protected Response doAction(UriInfo uriInfo, final AbstractActionTask 
task) {
-        Action action = task.action;
-        Response.Status status = null;
-        final ActionResource actionResource = new 
BaseActionResource<R>(uriInfo, task.action, getModel());
-        if (action.isSetAsync() && action.isAsync()) {
-            action.setStatus(StatusUtils.create(CreationStatus.PENDING));
-            actions.put(action.getId(), actionResource);
-            executor.execute(new Runnable() {
-                public void run() {
-                    perform(task);
-                    actions.reapable(actionResource.getAction().getId());
-                }
-            });
-            status = Status.ACCEPTED;
-        } else {
-            // no need for self link in action if synchronous (as no querying
-            // will ever be needed)
-            //
-            perform(task);
-            if 
(!action.getStatus().getState().equals(CreationStatus.FAILED.value())) {
-                status = Status.OK;
-            } else {
-                status = Status.BAD_REQUEST;
-            }
-        }
-
-        return Response.status(status).entity(action).build();
-    }
-
-    public ActionResource getActionSubresource(String action, String oid) {
-        // redirect back to the target VM if action no longer cached
-        // REVISIT: ultimately we should look at redirecting
-        // to the event/audit log
-        //
-        ActionResource exists = actions.get(oid);
-        return exists != null
-               ? exists
-               : new ActionResource() {
-                    @Override
-                    public Response get() {
-                        R tmp = newModel();
-                        tmp.setId(getId());
-                        tmp = LinkHelper.addLinks(getUriInfo(), tmp);
-                        Response.Status status = 
Response.Status.MOVED_PERMANENTLY;
-                        return 
Response.status(status).location(URI.create(tmp.getHref())).build();
-                    }
-                    @Override
-                    public Action getAction() {
-                        return null;
-                    }
-                };
-    }
-
-    public Executor getExecutor() {
-        return executor;
-    }
-
-    public void setExecutor(Executor executor) {
-        this.executor = executor;
-    }
-
-    private void perform(AbstractActionTask task) {
-        task.action.setStatus(StatusUtils.create(CreationStatus.IN_PROGRESS));
-        if (task.action.getGracePeriod() != null) {
-            try {
-                Thread.sleep(task.action.getGracePeriod().getExpiry());
-            } catch (Exception e) {
-                // ignore
-            }
-        }
-        task.run();
-    }
-
-    public static abstract class AbstractActionTask implements Runnable {
-        protected Action action;
-        protected String reason;
-
-        public AbstractActionTask(Action action) {
-            this(action, "");
-        }
-
-        public AbstractActionTask(Action action, String reason) {
-            this.action = action;
-            this.reason = reason;
-        }
-
-        public void run() {
-            try {
-                execute();
-                if 
(!action.getStatus().getState().equals(org.ovirt.engine.api.model.CreationStatus.FAILED.value()))
 {
-                    
action.setStatus(StatusUtils.create(org.ovirt.engine.api.model.CreationStatus.COMPLETE));
-                }
-            } catch (Throwable t) {
-                String message = t.getMessage() != null ? t.getMessage() : 
t.getClass().getName();
-                setFault(MessageFormat.format(t.getCause() != null ? 
t.getCause().getMessage()
-                                                                     :
-                                                                     reason,
-                                             message),
-                         t);
-            }
-        }
-
-        protected abstract void execute();
-
-        protected void setFault(String reason, Throwable t) {
-            Fault fault = new Fault();
-            fault.setReason(reason);
-            fault.setDetail(t.getMessage());
-            action.setFault(fault);
-            
action.setStatus(StatusUtils.create(org.ovirt.engine.api.model.CreationStatus.FAILED));
-        }
-
-        protected static String trace(Throwable t) {
-            StringWriter sw = new StringWriter();
-            t.printStackTrace(new PrintWriter(sw, true));
-            return sw.toString();
-        }
-    }
-
-    protected static class DoNothingTask extends AbstractActionTask {
-        public DoNothingTask(Action action) {
-            super(action);
-        }
-        public void execute(){
-        }
-    }
-
-    /**
-     * Fallback executor, starts a new thread for each task.
-     */
-    protected static class SimpleExecutor implements Executor {
-        public void execute(Runnable task) {
-            new Thread(task).start();
-        }
-    }
-}
diff --git 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/AbstractUpdatableResource.java
 
b/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/AbstractUpdatableResource.java
deleted file mode 100644
index 65de958..0000000
--- 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/AbstractUpdatableResource.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-* Copyright (c) 2010 Red Hat, Inc.
-*
-* Licensed 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.ovirt.engine.api.common.resource;
-
-
-import org.ovirt.engine.api.model.BaseResource;
-import org.ovirt.engine.api.model.ObjectFactory;
-import org.ovirt.engine.api.utils.ReflectionHelper;
-
-import org.ovirt.engine.api.common.util.MutabilityAssertor;
-
-
-public abstract class AbstractUpdatableResource<R extends BaseResource> {
-
-    private static final String[] STRICTLY_IMMUTABLE = {"id"};
-
-    protected final ObjectFactory OBJECT_FACTORY = new ObjectFactory();
-
-    protected final R model = newModel();
-
-    /**
-     * Create a new instance of the resource
-     *
-     * @return a newly constructed instance
-     */
-    protected R newModel() {
-        return ReflectionHelper.newModel(this);
-    }
-
-    public AbstractUpdatableResource(String id) {
-        setId(id);
-    }
-
-    /**
-     * Validate update from an immutability point of view.
-     *
-     * @param incoming  the incoming resource representation
-     * @param existing  the existing resource representation
-     * @throws WebApplicationException wrapping an appropriate response
-     * iff an immutability constraint has been broken
-     */
-    protected void validateUpdate(R incoming) {
-        refresh();
-        MutabilityAssertor.validateUpdate(getStrictlyImmutable(), incoming, 
model);
-    }
-
-    public void setId(String id) {
-        model.setId(id);
-    }
-
-    public String getId() {
-        return model.getId();
-    }
-
-    /**
-     * Override this method if any additional resource-specific fields are
-     * strictly immutable
-     *
-     * @return array of strict immutable field names
-     */
-    protected String[] getStrictlyImmutable() {
-        return STRICTLY_IMMUTABLE;
-    }
-
-    protected String[] addStrictlyImmutable(String... fields) {
-        String[] immutable = new String[STRICTLY_IMMUTABLE.length + 
fields.length];
-        System.arraycopy(STRICTLY_IMMUTABLE, 0, immutable, 0, 
STRICTLY_IMMUTABLE.length);
-        System.arraycopy(fields, 0, immutable, STRICTLY_IMMUTABLE.length, 
fields.length);
-        return immutable;
-    }
-
-    /**
-     * Refresh the current model state for update validity checking.
-     *
-     * Override this method if any additional resource-specific fields
-     * are strictly immutable by the client but may change in the backend.
-     */
-    protected void refresh() {}
-}
diff --git 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/BaseActionResource.java
 
b/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/BaseActionResource.java
deleted file mode 100644
index 33a1446..0000000
--- 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/BaseActionResource.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-* Copyright (c) 2010 Red Hat, Inc.
-*
-* Licensed 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.ovirt.engine.api.common.resource;
-
-import java.util.UUID;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriInfo;
-
-import org.ovirt.engine.api.model.Action;
-import org.ovirt.engine.api.model.BaseResource;
-import org.ovirt.engine.api.model.Link;
-import org.ovirt.engine.api.resource.ActionResource;
-import org.ovirt.engine.api.utils.LinkHelper;
-
-
-public class BaseActionResource<R extends BaseResource> implements 
ActionResource {
-
-    private Action action;
-    private R parent;
-
-    public BaseActionResource(UriInfo uriInfo, Action action, R parent) {
-        this.action = action;
-        this.parent = parent;
-        action.setId(UUID.randomUUID().toString());
-        addLinks(uriInfo);
-    }
-
-    @Override
-    public Response get() {
-        return Response.ok(action).build();
-    }
-
-    @Override
-    public Action getAction() {
-        return action;
-    }
-
-    private String getPath(UriInfo uriInfo) {
-        return combine(uriInfo.getBaseUri().getPath(), uriInfo.getPath());
-    }
-
-    private void addLink(String rel, String href) {
-        Link link = new Link();
-        link.setRel(rel);
-        link.setHref(href);
-        action.getLinks().add(link);
-    }
-
-    private void addLinks(UriInfo uriInfo) {
-        
action.setHref(UriBuilder.fromPath(getPath(uriInfo)).path(action.getId()).build().toString());
-
-        String parentHref = LinkHelper.addLinks(uriInfo, parent).getHref();
-        if (parentHref != null) {
-            addLink("parent", parentHref);
-        }
-        addLink("replay", getPath(uriInfo));
-    }
-
-    private String combine(String head, String tail) {
-        if (head.endsWith("/")) {
-            head = head.substring(0, head.length() - 1);
-        }
-        if (tail.startsWith("/")) {
-            tail = tail.substring(1);
-        }
-        return head + "/" + tail;
-    }
-}
diff --git 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/UriInfoProvider.java
 
b/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/UriInfoProvider.java
deleted file mode 100644
index 11435fa..0000000
--- 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/java/org/ovirt/engine/api/common/resource/UriInfoProvider.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2010 Red Hat, Inc.
-*
-* Licensed 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.ovirt.engine.api.common.resource;
-
-import javax.ws.rs.core.UriInfo;
-
-public interface UriInfoProvider {
-
-    UriInfo getUriInfo();
-
-}
diff --git 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/modules/org/ovirt/engine/api/interface-common-jaxrs/main/module.xml
 
b/backend/manager/modules/restapi/interface/common/jaxrs/src/main/modules/org/ovirt/engine/api/interface-common-jaxrs/main/module.xml
index 7a98bcd..8e7a464 100644
--- 
a/backend/manager/modules/restapi/interface/common/jaxrs/src/main/modules/org/ovirt/engine/api/interface-common-jaxrs/main/module.xml
+++ 
b/backend/manager/modules/restapi/interface/common/jaxrs/src/main/modules/org/ovirt/engine/api/interface-common-jaxrs/main/module.xml
@@ -28,7 +28,6 @@
     <module name="javax.servlet.api"/>
     <module name="javax.ws.rs.api"/>
     <module name="javax.xml.bind.api"/>
-    <module name="org.apache.commons.codec"/>
     <module name="org.apache.commons.collections"/>
     <module name="org.apache.commons.lang"/>
     <module name="org.apache.httpcomponents"/>


-- 
To view, visit https://gerrit.ovirt.org/40328
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia28854f308c56e7ca48c127eae30329b3aea6b1c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to