Examples of EmptyResponseContext


Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

 
  /**
   * Return a 204 No Content response
   */
  public static ResponseContext nocontent(String reason) {
    return new EmptyResponseContext(204,reason);
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

 
  public static ResponseContext notmodified(
    RequestContext request,
    String reason) {
      log.debug(Localizer.get("NOT.MODIFIED"));
      return new EmptyResponseContext(304,reason);
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

   * is returned.  The Etag header will be set.
   */ 
  protected ResponseContext buildHeadEntryResponse(RequestContext request,
                                                   String id,
                                                   Date updated) throws ResponseContextException {
    EmptyResponseContext rc = new EmptyResponseContext(200);
    rc.setEntityTag(EntityTag.generate(id, AtomDate.format(updated)));
    return rc;
  }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

  protected Node mapEntryToNode(Node entry, String title, String summary, Date updated, List<Person> authors,
                              Content content, Session session)
    throws ResponseContextException, RepositoryException {
    if (title == null) {
      EmptyResponseContext ctx = new EmptyResponseContext(500);
      ctx.setStatusText("Entry title cannot be empty.");
      throw new ResponseContextException(ctx);
    }

    entry.setProperty(TITLE, title);
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

                if (tenantDomain != null) {
                    if (RegistryContext.getBaseInstance().getRealmService() == null) {
                        String msg = "Error in getting the tenant manager. " +
                                "The realm service is not available.";
                        log.error(msg);
                        return new ResponseTarget(context, new EmptyResponseContext(400, msg));
                    }
                    TenantManager tenantManager =
                            RegistryContext.getBaseInstance().getRealmService().
                                    getTenantManager();
                    try {
                        calledTenantId = tenantManager.getTenantId(tenantDomain);
                    } catch (org.wso2.carbon.user.api.UserStoreException e) {
                        String msg =
                                "Error in converting tenant domain to the id for tenant domain: " +
                                        tenantDomain + ".";
                        log.error(msg, e);
                        return new ResponseTarget(context, new EmptyResponseContext(400, msg));
                    }
                    try {
                        if (!tenantManager.isTenantActive(calledTenantId)) {
                            // the tenant is not active.
                            String msg =
                                    "The tenant is not active. tenant domain: " + tenantDomain +
                                            ".";
                            log.error(msg);
                            return new ResponseTarget(context, new EmptyResponseContext(400, msg));
                        }
                    } catch (org.wso2.carbon.user.api.UserStoreException e) {
                        String msg =
                                "Error in converting tenant domain to the id for tenant domain: " +
                                        tenantDomain + ".";
                        log.error(msg, e);
                        return new ResponseTarget(context, new EmptyResponseContext(400, msg));
                    }
                    RegistryContext.getBaseInstance().
                            getRealmService().getBootstrapRealmConfiguration();

                }
                String anonUser = CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME;
                try {
                    registry = embeddedRegistryService.getRegistry(anonUser, calledTenantId);
                } catch (RegistryException e) {
                    String msg = "Error in creating the registry.";
                    log.error(msg, e);
                    return new ResponseTarget(context, new EmptyResponseContext(400, msg));
                }
            }
        }

        // Squirrel this away so the adapter can get it later (after all that work we just did!)
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

            try {
                getSecureRegistry(request).restoreVersion(resource.getPermanentPath());
            } catch (RegistryException e) {
                return new StackTraceResponseContext(e);
            }
            return new EmptyResponseContext(200);
        }
        if (type.equals(RegistryResolver.ASPECT_TYPE)) {
            return processAspectRequest(request, path);
        }
        if (type.equals(RegistryResolver.CHECKPOINT_TYPE)) {
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

            secureRegistry.put(path, resource);
        } catch (Exception e) {
            return new StackTraceResponseContext(e);
        }

        EmptyResponseContext response = new EmptyResponseContext(200);
        try {
            response.setLocation(
                    URLDecoder.decode(getAtomURI(path, request), "UTF-8").replaceAll(" ", "+"));
        } catch (UnsupportedEncodingException e) {
            // no action
        }
        return response;
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

                    String aspect = readToString(request.getInputStream());
                    registry.associateAspect(path, aspect);
                } catch (Exception e) {
                    return new StackTraceResponseContext(e);
                }
                return new EmptyResponseContext(200);
            }
            return null;
        }
        // There should be an aspect name - parse it out
        assert (discriminator.charAt(7) == '(');
        int right = discriminator.indexOf(')');
        assert (right > -1);
        String aspectName = discriminator.substring(7, right);
        String action;
        if (discriminator.length() > right + 1) {
            // Got an action too?
            assert (method.equals("POST"));
            action = discriminator.substring(right + 1);
            try {
                registry.invokeAspect(path, aspectName, action);
            } catch (RegistryException e) {
                return new StackTraceResponseContext(e);
            }
            // TODO - do we have to read the request fully?
            return new EmptyResponseContext(200);
        }
        assert (method.equals("GET"));

        // Return list of available actions.
        Feed feed = getNewFeed("tag:aspectActions"); // TODO - fix ID
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

                        InputStream is = request.getInputStream();
                        String text = readToString(is);
                        comment.setText(text);
                    }
                    String commentPath = secureRegistry.addComment(path, comment);
                    EmptyResponseContext responseContext = new EmptyResponseContext(200);
                    try {
                        responseContext.setLocation(URLDecoder
                                .decode(getAtomURI(commentPath, request), "UTF-8").replaceAll(" ",
                                "+"));
                    } catch (UnsupportedEncodingException e) {
                        // no action
                    }
                    return responseContext;
                } else if (method.equals("PUT")) {
                    Entry entry = (Entry) request.getDocument().getRoot();
                    String text = entry.getContent();
                    secureRegistry.editComment(path, text);
                    return new EmptyResponseContext(200);
                } else if (method.equals("DELETE")) {
                    secureRegistry.delete(path);
                    return new EmptyResponseContext(200);
                }
            } catch (Exception e) {
                return new StackTraceResponseContext(e);
            }
        }
        return new EmptyResponseContext(405)// unsupported method
    }
View Full Code Here

Examples of org.apache.abdera.protocol.server.context.EmptyResponseContext

            // Adding an association, expecting XML that looks like
            // <reg:association type="type">http://associationPath</reg:association>
            try {
                Element assocEl = request.getDocument().getRoot();
                if (!APPConstants.QN_ASSOC.equals(assocEl.getQName())) {
                    return new EmptyResponseContext(400, "Bad association element");
                }
                String type = assocEl.getAttributeValue(APPConstants.ASSOC_TYPE);
                String assocPath = assocEl.getText();
                getSecureRegistry(request).addAssociation(path, assocPath, type);
                return new EmptyResponseContext(200);
            } catch (Exception e) {
                return new StackTraceResponseContext(e);
            }
        }
        if (request.getMethod().equals("DELETE")) {
            String destinationPath = request.getHeader("Destination");
            String type = request.getHeader("AssociationType");
            try {
                getSecureRegistry(request).removeAssociation(path, destinationPath, type);
                return new EmptyResponseContext(200);
            } catch (Exception e) {
                return new StackTraceResponseContext(e);
            }
        }
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.