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