コード例 #1
0
ファイル: GsRest.java プロジェクト: mixun/gsrcj
  /**
   * This method does not upload a shapefile via zip. It rather creates a reference to a Shapefile
   * that has already exists in the GS data directory.
   *
   * @param charset defaults to UTF-8 if not set. Charset, that any text content is stored in.
   * @param relpath A path to the file, relative to gsdata dir, e.g. "file:data/water.shp"
   */
  public boolean createDatastoreShapefile(
      String workspace,
      String dsName,
      String dsNamespace,
      String relpath,
      String charset,
      Boolean memoryMappedBuffer,
      Boolean createSpatialIndex,
      Configure autoConfig)
      throws IOException {

    if (autoConfig == Configure.first) autoConfig = null;

    if (relpath == null) throw new IllegalArgumentException("parameter relpath may not be null");

    String createSpatialIndexParam = RestUtil.entryKey("create spatial index", createSpatialIndex);

    String memoryMappedBufferParamter =
        RestUtil.entryKey("memory mapped buffer", memoryMappedBuffer);

    String charsetParamter =
        "<entry key=\"charset\">" + (charset == null ? "UTF-8" : charset) + "</entry>";

    String urlParamter = "<entry key=\"url\">" + relpath + "</entry>";

    String namespaceParamter = "<entry key=\"namespace\">" + dsName + "</entry>";

    String typeParamter = "<type>Shapefile</type>";

    String xml =
        "<dataStore><name>"
            + dsName
            + "</name><enabled>true</enabled>"
            + typeParamter
            + "<connectionParameters>"
            + createSpatialIndexParam
            + memoryMappedBufferParamter
            + charsetParamter
            + urlParamter
            + namespaceParamter
            + typeParamter
            + "</connectionParameters></dataStore>";

    String configureParam = autoConfig == null ? "" : "?configure=" + autoConfig.toString();

    int returnCode =
        sendRESTint(
            METHOD_POST, "/workspaces/" + workspace + "/datastores.xml" + configureParam, xml);
    return 201 == returnCode;
  }
コード例 #2
0
 protected void executeURL(URL url, String s, String s1, String s2, String s3, int i)
 {
     url = new Request(RestUtil.prepareConnectionUrl(s1, url, s), s2, true);
     if (s3 != null)
     {
         url.addBody(s3);
     }
     _requestExecuter.execute(url, i, _onRequestCallbackListener);
 }
コード例 #3
0
 public final void changePort(int i)
 {
     this;
     JVM INSTR monitorenter ;
     RestUtil.changePort(i);
     this;
     JVM INSTR monitorexit ;
     return;
     Exception exception;
     exception;
     throw exception;
 }
コード例 #4
0
 public void postImage(URL url, HashMap hashmap, String s, String s1, byte abyte0[])
 {
     if (isConnected())
     {
         url = new Request(RestUtil.preparePostUrl("http://IP_ADDRESS:PORT/ws/app/WIDGET_ID/queue", url, "interactivity_Button_label"), "POST", "image/png");
         url.addHeaders(hashmap);
         url.makeFileRequest(s1);
         _requestExecuter.execute(url, 9002, _onRequestCallbackListener);
         return;
     } else
     {
         Log.w("RestClient", "Application not connected!");
         return;
     }
 }
コード例 #5
0
 public void get(URL url, HashMap hashmap, String s)
 {
     if (isConnected())
     {
         url = new Request(RestUtil.prepareGetUrl("http://IP_ADDRESS:PORT/ws/app/WIDGET_ID/queue/device/DEVICE_ID", url, "interactivity_Button_label", DeviceInfo.getDeviceId()), "GET", true);
         url.addHeaders(hashmap);
         url.addBody(s);
         _requestExecuter.execute(url, 9003, _onRequestCallbackListener);
         return;
     } else
     {
         Log.w("RestClient", "Application not connected!");
         return;
     }
 }
コード例 #6
0
  @Test(
      description = "Measure the time to load the Calendar, month view, 100 appointment",
      groups = {"performance"})
  public void ZmCalendarApp_03() throws HarnessException {

    // What is today?
    Calendar today = Calendar.getInstance();

    // Import 100 appointments using Calendar.ics and REST
    String filename =
        ZimbraSeleniumProperties.getBaseDirectory() + "/data/public/ics/calendar05/Calendar.ics";
    File file = null;

    // Modify the ICS in two ways:
    // 1. Make the current account the organizer
    // 2. Make the dates equal to this month
    file =
        RestUtil.FileUtils.replaceInFile(
            "*****@*****.**", app.zGetActiveAccount().EmailAddress, new File(filename));
    file =
        RestUtil.FileUtils.replaceInFile(
            "201111", (new SimpleDateFormat("yyyyMM")).format(today.getTime()), file);

    RestUtil rest = new RestUtil();
    rest.setAuthentication(app.zGetActiveAccount());
    rest.setPath("/service/home/~/Calendar");
    rest.setQueryParameter("fmt", "ics");
    rest.setUploadFile(file);
    rest.doPost();

    // Start the perf token
    PerfToken token =
        PerfMetrics.startTimestamp(
            PerfKey.ZmCalendarApp, "Load the calendar app, month view, 100 appointment");

    // Go to calendar
    // app.zPageCalendar.zNavigateTo();
    app.zPageCalendar.zClickAt("css=td[id='zb__App__Calendar_title']", "");

    PerfMetrics.waitTimestamp(token);

    // Wait for the app to load
    app.zPageCalendar.zWaitForActive();
  }