Search in sources :

Example 1 with Current

use of org.ovirt.engine.api.restapi.invocation.Current in project ovirt-engine by oVirt.

the class AbstractBackendActionableResource method actionAsync.

protected Response actionAsync(ActionReturnValue actionResult, Action action) {
    action.setAsync(true);
    String ids = asString(actionResult.getVdsmTaskIdList());
    action.setId(ids);
    Current current = CurrentManager.get();
    String path = current.getRelativePath();
    action.setHref(path + "/" + ids);
    addOrUpdateLink(action, "parent", path.substring(0, path.lastIndexOf("/")));
    addOrUpdateLink(action, "replay", path);
    CreationStatus status = getAsynchronousStatus(actionResult);
    if (status != null) {
        action.setStatus(status.value());
    }
    return Response.status(ACCEPTED_STATUS).entity(action).build();
}
Also used : Current(org.ovirt.engine.api.restapi.invocation.Current) CreationStatus(org.ovirt.engine.api.model.CreationStatus)

Example 2 with Current

use of org.ovirt.engine.api.restapi.invocation.Current in project ovirt-engine by oVirt.

the class UsageFinder method getLinkPrefix.

private String getLinkPrefix(ServiceTreeNode node) {
    Current current = CurrentManager.get();
    StringBuilder buffer = new StringBuilder();
    buffer.append(current.getRoot());
    buffer.append("/ovirt-engine/apidoc#services/");
    buffer.append(processNodeName(node));
    buffer.append("/methods/");
    return buffer.toString();
}
Also used : Current(org.ovirt.engine.api.restapi.invocation.Current)

Example 3 with Current

use of org.ovirt.engine.api.restapi.invocation.Current in project ovirt-engine by oVirt.

the class AbstractBackendBaseTest method setUp.

@Before
public void setUp() {
    interactions.clear();
    DbUser currentUser = new DbUser();
    currentUser.setFirstName(USER);
    currentUser.setLastName(USER);
    currentUser.setDomain(DOMAIN);
    currentUser.setNamespace(NAMESPACE);
    currentUser.setId(GUIDS[0]);
    Current current = new Current();
    current.setUser(currentUser);
    current.setSessionId(SESSION_ID);
    current.setRoot(URI_ROOT);
    current.setPrefix(BASE_PATH);
    current.setPath("");
    current.setVersion("4");
    current.setVersionSource(VersionSource.DEFAULT);
    current.setBackend(backend);
    CurrentManager.put(current);
    locales = new ArrayList<>();
    when(httpHeaders.getAcceptableLanguages()).thenReturn(locales);
    accepts = new ArrayList<>();
    when(httpHeaders.getRequestHeader("Accept")).thenReturn(accepts);
    List<String> filterValue = new ArrayList<>();
    filterValue.add("false");
    when(httpHeaders.getRequestHeader(USER_FILTER_HEADER)).thenReturn(filterValue);
    mapperLocator = new MappingLocator();
    mapperLocator.populate();
    locale = Locale.getDefault();
    Locale.setDefault(Locale.GERMANY);
    messageBundle = new MessageBundle();
    messageBundle.setPath(BUNDLE_PATH);
    messageBundle.populate();
    init();
}
Also used : MessageBundle(org.ovirt.engine.api.restapi.logging.MessageBundle) ArrayList(java.util.ArrayList) Current(org.ovirt.engine.api.restapi.invocation.Current) MappingLocator(org.ovirt.engine.api.restapi.types.MappingLocator) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Before(org.junit.Before)

Example 4 with Current

use of org.ovirt.engine.api.restapi.invocation.Current in project ovirt-engine by oVirt.

the class BackendApiResourceTest method setUp.

@Before
public void setUp() {
    backend = mock(BackendLocal.class);
    currentUser = new DbUser();
    currentUser.setLoginName(USER);
    currentUser.setDomain(DOMAIN);
    current = new Current();
    current.setUser(currentUser);
    current.setSessionId(SESSION_ID);
    current.setRoot(URI_ROOT);
    current.setPrefix(BASE_PATH);
    current.setPath("");
    current.setVersion("4");
    current.setVersionSource(VersionSource.DEFAULT);
    current.setBackend(backend);
    CurrentManager.put(current);
    MessageBundle messageBundle = new MessageBundle();
    messageBundle.setPath(BUNDLE_PATH);
    messageBundle.populate();
    resource.setMessageBundle(messageBundle);
    httpHeaders = mock(HttpHeaders.class);
    List<Locale> locales = new ArrayList<>();
    when(httpHeaders.getAcceptableLanguages()).thenReturn(locales);
    List<String> filterValue = new ArrayList<>();
    filterValue.add("false");
    when(httpHeaders.getRequestHeader(USER_FILTER_HEADER)).thenReturn(filterValue);
    resource.setHttpHeaders(httpHeaders);
}
Also used : MessageBundle(org.ovirt.engine.api.restapi.logging.MessageBundle) Locale(java.util.Locale) HttpHeaders(javax.ws.rs.core.HttpHeaders) BackendLocal(org.ovirt.engine.core.common.interfaces.BackendLocal) ArrayList(java.util.ArrayList) Current(org.ovirt.engine.api.restapi.invocation.Current) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Before(org.junit.Before)

Example 5 with Current

use of org.ovirt.engine.api.restapi.invocation.Current in project ovirt-engine by oVirt.

the class V3ApiOutAdapter method makeCapabilitiesLink.

private V3Link makeCapabilitiesLink() {
    // Calculate the href:
    Current current = CurrentManager.get();
    String href = current.getAbsolutePath("capabilities");
    // Make the link:
    V3Link link = new V3Link();
    link.setRel("capabilities");
    link.setHref(href);
    return link;
}
Also used : V3Link(org.ovirt.engine.api.v3.types.V3Link) Current(org.ovirt.engine.api.restapi.invocation.Current)

Aggregations

Current (org.ovirt.engine.api.restapi.invocation.Current)14 Before (org.junit.Before)4 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DOMSource (javax.xml.transform.dom.DOMSource)2 XPath (javax.xml.xpath.XPath)2 MessageBundle (org.ovirt.engine.api.restapi.logging.MessageBundle)2 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)2 Document (org.w3c.dom.Document)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 IOException (java.io.IOException)1 URI (java.net.URI)1 Locale (java.util.Locale)1 GET (javax.ws.rs.GET)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 HttpHeaders (javax.ws.rs.core.HttpHeaders)1 PathSegment (javax.ws.rs.core.PathSegment)1 UriInfo (javax.ws.rs.core.UriInfo)1