/**
   * Handles the getCapabilities request and gives the XML formated server capabilities to the
   * outputStream
   *
   * @param output servlet outputStream
   * @param wmsResponse HttpServletResponse modified for WMS use
   * @throws WMSException
   * @throws UnsupportedEncodingException
   */
  public void getCap(OutputStream output, WMSResponse wmsResponse)
      throws WMSException, UnsupportedEncodingException {
    PrintStream pr = new PrintStream(output, false, "UTF-8");
    WMSCapabilities cap = new WMSCapabilities();
    // Setting service WMS metadata
    cap.setService(getService());
    // Setting Capability parameters
    // Setting Layers capabilities
    Capability c = new Capability();
    // Bounding box of the highest layer is dummy
    Envelope dummy = new Envelope(WEST, EAST, SOUTH, NORTH);
    EXGeographicBoundingBox bb = getGeographicBoundingBox(dummy, "EPSG:4326");
    Layer availableLayers = new Layer();
    availableLayers.setEXGeographicBoundingBox(bb);
    BoundingBox bBox = new BoundingBox();
    bBox.setCRS("EPSG:4326");
    bBox.setMaxx(EAST);
    bBox.setMinx(WEST);
    bBox.setMaxy(NORTH);
    bBox.setMiny(SOUTH);
    availableLayers.getBoundingBox().add(bBox);
    for (Layer e : layerMap.values()) {
      availableLayers.getLayer().add(e);
    }
    // Server supported CRS
    availableLayers.getCRS().addAll(authCRS);
    availableLayers.setName("Available_layers");
    availableLayers.setTitle("Server available layers");
    c.setLayer(availableLayers);
    // Setting the request capabilities
    // GetMap capabilities
    Request req = new Request();
    req.setGetMap(getMapOperation(wmsResponse));
    // GetCap capabilities
    req.setGetCapabilities(getCapOperation(wmsResponse));
    // GetFeatureInfo capabilities
    req.setGetFeatureInfo(getFeatureOperation(wmsResponse));
    c.setRequest(req);
    cap.setCapability(c);

    try {
      // Marshalling the WMS Capabilities into an XML response
      Marshaller marshaller = jaxbContext.createMarshaller();
      NamespacePrefixMapper mapper = new NamespaceMapper();
      marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);

      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

      wmsResponse.setContentType("text/xml;charset=UTF-8");
      marshaller.marshal(cap, pr);

    } catch (JAXBException ex) {
      wmsResponse.setContentType("text/xml;charset=UTF-8");
      wmsResponse.setResponseCode(500);
      pr.append(
          "<?xml version='1.0' encoding=\"UTF-8\"?><ServiceExceptionReport xmlns=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"1.3.0\" xsi:schemaLocation=\"http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd\"><ServiceException>Something went wrong</ServiceException></ServiceExceptionReport>");
      pr.append(ex.toString());
      ex.printStackTrace(pr);
    }
  }
Ejemplo n.º 2
0
 public Set<Participant> resolveParticipantsFromResourceName(String anyName) {
   Set<Participant> pSet = new HashSet<Participant>();
   Participant p = getParticipantFromUserID(anyName);
   if (p != null) {
     pSet.add(p);
     return pSet;
   }
   Role r = getRoleByName(anyName);
   if (r != null) {
     pSet.addAll(getRoleParticipants(r.getID()));
     return pSet;
   }
   Position pos = getPositionByLabel(anyName);
   if (pos != null) {
     pSet.addAll(getPositionParticipants(pos.getID()));
     return pSet;
   }
   OrgGroup o = getOrgGroupByLabel(anyName);
   if (o != null) {
     pSet.addAll(getOrgGroupParticipants(o.getID()));
     return pSet;
   }
   Capability c = getCapabilityByLabel(anyName);
   if (c != null) {
     pSet.addAll(getCapabilityParticipants(c.getID()));
   }
   return pSet;
 }
Ejemplo n.º 3
0
 public Map<String, String> getCapabilityIdentifiers() {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (Capability c : getCapabilities()) {
     idMap.put(c.getID(), c.getCapability());
   }
   return idMap;
 }
Ejemplo n.º 4
0
 public Capability getCapabilityByLabel(String label) {
   for (Capability c : capabilityMap.values()) {
     if (c.getCapability().equals(label)) {
       return c;
     }
   }
   return null;
 }
Ejemplo n.º 5
0
  public String getCapabilitiesAsXML() {
    ArrayList<Capability> cList = new ArrayList<Capability>(capabilityMap.values());
    Collections.sort(cList);

    StringBuilder xml = new StringBuilder("<capabilities>");
    for (Capability c : cList) xml.append(c.toXML());
    xml.append("</capabilities>");
    return xml.toString();
  }
Ejemplo n.º 6
0
 public String getParticipantCapabilitiesAsXML(String pid) {
   Set<Capability> capSet = getParticipantCapabilities(pid);
   if (capSet != null) {
     String header = String.format("<capabilities participantid=\"%s\">", pid);
     StringBuilder xml = new StringBuilder(header);
     for (Capability c : capSet) xml.append(c.toXML());
     xml.append("</capabilities>");
     return xml.toString();
   } else return ("<capabilities/>");
 }
Ejemplo n.º 7
0
 public Set<Participant> getParticipantsWithCapability(String capabilityName) {
   Set<Participant> result = null;
   if (capabilityName != null) {
     Capability c = getCapabilityByLabel(capabilityName);
     if (c != null) {
       result = getCapabilityParticipants(c.getID());
     }
   }
   return result;
 }
Ejemplo n.º 8
0
 public String getParticpantsWithCapabilityAsXML(String capabilityName) {
   String result = "<participants/>";
   if (capabilityName != null) {
     Capability c = getCapabilityByLabel(capabilityName);
     if (c != null) {
       result = getCapabilityParticipantsAsXML(c.getID());
     }
   }
   return result;
 }
Ejemplo n.º 9
0
  void setCapabilities(List<Capability> capabilities) {
    allCapabilities = capabilities;

    capabilityMap = new HashMap<String, List<Capability>>();
    for (Capability capability : capabilities) {
      List<Capability> list = capabilityMap.get(capability.getNamespace());
      if (list == null) {
        list = new LinkedList<Capability>();
        capabilityMap.put(capability.getNamespace(), list);
      }
      list.add(capability);
    }
  }
Ejemplo n.º 10
0
  /**
   * returns all other capabilities, besides class and attribute related ones
   *
   * @return all other capabilities, besides class and attribute related ones
   */
  public Capabilities getOtherCapabilities() {
    Capabilities result;

    result = new Capabilities(getOwner());

    for (Capability cap : Capability.values()) {
      if (cap.isOtherCapability()) {
        if (handles(cap)) result.m_Capabilities.add(cap);
      }
    }

    return result;
  }
Ejemplo n.º 11
0
 public String addCapability(Capability c) {
   if (isDataEditable(ResUnit.Capability)) {
     String newID = getDataSource(ResUnit.Capability).insert(c); // persist it
     if (!hasDefaultDataSource(ResUnit.Capability)) c.setID(newID);
     putCapability(c); // ...and add it to the data set
     return newID;
   } else return fail("External Capability dataset is read-only");
 }
Ejemplo n.º 12
0
  /**
   * turns the capabilities object into source code. The returned source code is a block that
   * creates a Capabilities object named 'objectname' and enables all the capabilities of this
   * Capabilities object.
   *
   * @param objectname the name of the Capabilities object being instantiated
   * @param indent the number of blanks to indent
   * @return the generated source code
   */
  public String toSource(String objectname, int indent) {
    StringBuffer result;
    String capsName;
    String capName;
    String indentStr;
    int i;

    result = new StringBuffer();

    capsName = Capabilities.class.getName();
    capName = Capabilities.Capability.class.getName().replaceAll("\\$", ".");

    indentStr = "";
    for (i = 0; i < indent; i++) indentStr += " ";

    // object name
    result.append(indentStr + capsName + " " + objectname + " = new " + capsName + "(this);\n");

    // capabilities
    result.append("\n");
    for (Capability cap : Capability.values()) {
      // capability
      if (handles(cap))
        result.append(indentStr + objectname + ".enable(" + capName + "." + cap.name() + ");\n");
      // dependency
      if (hasDependency(cap))
        result.append(
            indentStr + objectname + ".enableDependency(" + capName + "." + cap.name() + ");\n");
    }

    // other
    result.append("\n");
    result.append(
        indentStr
            + objectname
            + ".setMinimumNumberInstances("
            + getMinimumNumberInstances()
            + ");\n");

    result.append("\n");

    return result.toString();
  }
Ejemplo n.º 13
0
  @Override
  public String toString() {
    final StringBuilder builder = new StringBuilder();
    List<Capability> identities = getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
    if (identities != null && identities.size() == 1) {
      Capability idCap = identities.get(0);
      Object id = idCap.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE);
      Object version = idCap.getAttributes().get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);

      builder.append(id).append(" ver=").append(version);
    } else {
      // Generic toString
      builder.append("ResourceImpl [caps=");
      builder.append(allCapabilities);
      builder.append(", reqs=");
      builder.append(allRequirements);
      builder.append("]");
    }
    return builder.toString();
  }
Ejemplo n.º 14
0
  /**
   * retrieves the data from the given Capabilities object
   *
   * @param c the capabilities object to initialize with
   */
  public void assign(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (c.handles(cap)) enable(cap);
      else disable(cap);
      // dependency
      if (c.hasDependency(cap)) enableDependency(cap);
      else disableDependency(cap);
    }

    setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
Ejemplo n.º 15
0
  /**
   * performs an OR conjunction with the capabilities of the given Capabilities object and updates
   * itself
   *
   * @param c the capabilities to OR with
   */
  public void or(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (handles(cap) || c.handles(cap)) m_Capabilities.add(cap);
      else m_Capabilities.remove(cap);
      // dependency
      if (hasDependency(cap) || c.hasDependency(cap)) m_Dependencies.add(cap);
      else m_Dependencies.remove(cap);
    }

    if (c.getMinimumNumberInstances() < getMinimumNumberInstances())
      setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
Ejemplo n.º 16
0
  /**
   * Returns true if the currently set capabilities support (or have a dependency) at least all of
   * the capabilities of the given Capabilities object (checks only the enum!)
   *
   * @param c the capabilities (or dependencies) to support at least
   * @return true if all the requested capabilities are supported (or at least have a dependency)
   */
  public boolean supportsMaybe(Capabilities c) {
    boolean result;

    result = true;

    for (Capability cap : Capability.values()) {
      if (c.handles(cap) && !(handles(cap) || hasDependency(cap))) {
        result = false;
        break;
      }
    }

    return result;
  }
Ejemplo n.º 17
0
  /**
   * Returns true if the currently set capabilities support at least all of the capabiliites of the
   * given Capabilities object (checks only the enum!)
   *
   * @param c the capabilities to support at least
   * @return true if all the requested capabilities are supported
   */
  public boolean supports(Capabilities c) {
    boolean result;

    result = true;

    for (Capability cap : Capability.values()) {
      if (c.handles(cap) && !handles(cap)) {
        result = false;
        break;
      }
    }

    return result;
  }
Ejemplo n.º 18
0
  /**
   * performs an AND conjunction with the capabilities of the given Capabilities object and updates
   * itself
   *
   * @param c the capabilities to AND with
   */
  public void and(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (handles(cap) && c.handles(cap)) m_Capabilities.add(cap);
      else m_Capabilities.remove(cap);
      // dependency
      if (hasDependency(cap) && c.hasDependency(cap)) m_Dependencies.add(cap);
      else m_Dependencies.remove(cap);
    }

    // minimum number of instances that both handlers need at least to work
    if (c.getMinimumNumberInstances() > getMinimumNumberInstances())
      setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
Ejemplo n.º 19
0
  public ThreadGroupReferenceProxyImpl getThreadGroupReferenceProxy(ThreadGroupReference group) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    if (group == null) {
      return null;
    }

    ThreadGroupReferenceProxyImpl proxy = myThreadGroups.get(group);
    if (proxy == null) {
      if (!myIsJ2ME.isAvailable()) {
        proxy = new ThreadGroupReferenceProxyImpl(this, group);
        myThreadGroups.put(group, proxy);
      }
    }

    return proxy;
  }
Ejemplo n.º 20
0
 /**
  * enables all attribute types
  *
  * @see #disableAllAttributes()
  * @see #getAttributeCapabilities()
  */
 public void enableAllAttributes() {
   for (Capability cap : Capability.values()) {
     if (cap.isAttribute()) enable(cap);
   }
 }
Ejemplo n.º 21
0
 public boolean canRequestVMDeathEvent() {
   return myRequestVMDeathEvent.isAvailable();
 }
Ejemplo n.º 22
0
 public boolean canGetMethodReturnValues() {
   return myGetMethodReturnValues.isAvailable();
 }
Ejemplo n.º 23
0
 public boolean canGetSourceDebugExtension() {
   return myGetSourceDebugExtension.isAvailable();
 }
Ejemplo n.º 24
0
 /**
  * disables all attribute type dependencies
  *
  * @see #enableAllAttributeDependencies()
  * @see #getAttributeCapabilities()
  */
 public void disableAllAttributeDependencies() {
   for (Capability cap : Capability.values()) {
     if (cap.isAttribute()) disableDependency(cap);
   }
 }
Ejemplo n.º 25
0
 /**
  * disables all class types
  *
  * @see #enableAllClasses()
  * @see #getClassCapabilities()
  */
 public void disableAllClasses() {
   for (Capability cap : Capability.values()) {
     if (cap.isClass()) disable(cap);
   }
 }
Ejemplo n.º 26
0
 public Set<Participant> getCapabilityParticipants(String cid) {
   Capability c = capabilityMap.get(cid);
   return (c != null) ? castToParticipantSet(c.getResources()) : null;
 }
Ejemplo n.º 27
0
 /**
  * disables all class type dependencies
  *
  * @see #enableAllClassDependencies()
  * @see #getClassCapabilities()
  */
 public void disableAllClassDependencies() {
   for (Capability cap : Capability.values()) {
     if (cap.isClass()) disableDependency(cap);
   }
 }
Ejemplo n.º 28
0
 public void putCapability(Capability c) {
   capabilityMap.put(c.getID(), c);
   setChangeStamp(ResUnit.Capability);
 }
Ejemplo n.º 29
0
 public void delCapability(Capability c) {
   capabilityMap.remove(c.getID());
   setChangeStamp(ResUnit.Capability);
 }
Ejemplo n.º 30
0
 public boolean canGetInstanceInfo() {
   return myCanGetInstanceInfo.isAvailable();
 }