private List<Add> appendAddConfiguration(Operation operation) throws WindowsOperationException {

    List<Add> addList = new ArrayList<Add>();
    Gson gson = new Gson();

    if (SyncmlCommandType.WIFI.getValue().equals(operation.getCode())) {

      Add add = new Add();

      String operationCode = operation.getCode();

      Wifi wifiObject = gson.fromJson((String) operation.getPayLoad(), Wifi.class);

      String data =
          "&lt;?xml version=&quot;1.0&quot;?&gt;&lt;WLANProfile"
              + "xmlns=&quot;http://www.microsoft.com/networking/WLAN/profile/v1&quot;&gt;&lt;name&gt;"
              + wifiObject.getNetworkName()
              + "&lt;/name&gt;&lt;SSIDConfig&gt;&lt;SSID&gt;&lt;name&gt;"
              + wifiObject.getSsid()
              + "&lt;/name&gt;&lt;/SSID&gt;&lt;/SSIDConfig&gt;&lt;connectionType&gt;"
              + wifiObject.getConnectionType()
              + "&lt;/connectionType&gt;&lt;connectionMode&gt;"
              + wifiObject.getConnectionMode()
              + "&lt;/connectionMode&gt;&lt;MSM&gt;&lt;security&gt;&lt;"
              + "authEncryption&gt;&lt;authentication&gt;"
              + wifiObject.getAuthentication()
              + "&lt;/authentication&gt;&lt;encryption&gt;"
              + wifiObject.getEncryption()
              + "&lt;/encryption&gt;&lt;/authEncryption&gt;&lt;sharedKey&gt;&lt;keyType&gt;"
              + wifiObject.getKeyType()
              + "&lt;/keyType&gt;&lt;protected&gt;"
              + wifiObject.getProtection()
              + "&lt;/protected&gt;&lt;keyMaterial&gt;"
              + wifiObject.getKeyMaterial()
              + "&lt;/keyMaterial&gt;&lt;/sharedKey&gt;&lt;/security&gt;&lt;/MSM&gt;&lt;/WLANProfile&gt;";

      Meta meta = new Meta();
      meta.setFormat("chr");
      List<Item> items = new ArrayList<Item>();

      for (Configure configure : Configure.values()) {
        if (operationCode != null && operationCode.equals(configure.name())) {
          Target target = new Target();
          target.setLocURI(configure.getCode());
          items.get(0).setTarget(target);
        }
      }
      items.get(0).setMeta(meta);
      items.get(0).setData(data);

      add.setCommandId(301);
      add.setItems(items);
      addList.add(add);
      return addList;
    }
    return null;
  }
Beispiel #2
0
  public synchronized void sfStart() throws SmartFrogException, RemoteException {
    super.sfStart();

    CheckPrereqs chk = new CheckPrereqs();

    try {
      chk.checkCmd(javaPath, "java", javaVersion, null);
      chk.checkCmd(antPath, "ant", antVersion, null);
      chk.checkCmd("tar", null, tarVendor);
      chk.checkCmd("sed", null, sedVendor);
      chk.checkCmd("cc", cVersion);
      chk.checkCmd("make", null, makeVendor);
      chk.checkCmd("sudo", null, null);
      // chk.checkCmd("postgres", postgresVersion);
      // chk.checkCmd("perl", null, null);
      chk.checkCmd(perlPath, "perl", perlVersion, null);

    } catch (IOException ioe) {
      sfLog().err("Exception in checking pre-requisites", ioe);
      throw new SmartFrogException("Exception in checking pre-requisites", ioe);
    } catch (PrereqException pe) {
      sfLog().err(pe);
      throw new SmartFrogException(pe);
    } catch (InterruptedException ie) {
      sfLog().err(ie);
      throw new SmartFrogException(ie);
    }

    sfLog().info("All pre-requisites for GT4 satisfied");

    Configure configure = new Configure(installerDir, globusLoc);
    Installation gt4 = new Installation(installerDir, globusLoc);

    try {
      configure.runConfigure(confOpts);
      sfLog().info("./configure script executed successfully.");
      sfLog().info("Starting build...");
      gt4.build(targets);
      sfLog().info("Installing in GLOBUS_LOCATION");
      gt4.build("install");
    } catch (GNUBuildException gbe) {
      sfLog().err("Error while installing GT4", gbe);
      throw new SmartFrogException("Error while isntalling GT4", gbe);
    }

    sfLog().info("GT4 Built successfully");

    // terminate synchronously
    if (shouldTerminate) {
      TerminationRecord tr = TerminationRecord.normal("Terminating ...", sfCompleteName());
      sfTerminate(tr);
    }
  }
Beispiel #3
0
  /**
   * 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;
  }
Beispiel #4
0
  /**
   * 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. <br>
   * TODO: This is buggy and always puts the coveragestore in the default workspace. Therefore we
   * set the default workspace defore every command, and reset it afterwards. This will change the
   * default workspace for a moment!
   *
   * @param relpath A path to the file, relative to gsdata dir, e.g. "file:data/water.shp"
   */
  public boolean createCoverageGeoTiff(
      String wsName, String csName, String csNamespace, String relpath, Configure autoConfig)
      throws IOException {

    String oldDefault = getDefaultWs();

    try {
      setDefaultWs(wsName);

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

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

      String urlParamter = "<url>" + relpath + "</url>";

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

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

      String xml =
          "<coverageStore><name>"
              + csName
              + "</name><enabled>true</enabled>"
              + typeParamter
              + urlParamter
              + "</coverageStore>";

      int returnCode =
          sendRESTint(
              METHOD_POST,
              "/workspaces/" + wsName + "/coveragestores?configure=" + autoConfig.toString(),
              xml);
      return 201 == returnCode;
    } catch (IOException e) {
      setDefaultWs(oldDefault);
      throw e;
    } finally {
      reload();
    }
  }
Beispiel #5
0
 private void end() {
   Session currSession = SessionData.currentSession(this);
   // Return to a new ticket edit
   switch (Configure.getTicketsMode(this)) {
     case Configure.SIMPLE_MODE:
       TicketInput.requestTicketSwitch(currSession.newTicket());
       this.finish();
       break;
     case Configure.STANDARD_MODE:
       if (!currSession.hasTicket()) {
         TicketInput.requestTicketSwitch(currSession.newTicket());
         this.finish();
         break;
       } // else open ticket input like in restaurant mode
     case Configure.RESTAURANT_MODE:
       Intent i = new Intent(this, TicketSelect.class);
       i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
       this.startActivityForResult(i, TicketSelect.CODE_TICKET);
       break;
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
   */
  public void afterPropertiesSet() throws Exception {
    File configFile = new File(Configure.getConfigFilename());
    lastFileModifiedTime = configFile.lastModified();

    scheduledExecutorService.scheduleWithFixedDelay(
        new Runnable() {

          public void run() {
            File configFile = new File(Configure.getConfigFilename());
            // When two files' last modify time not equal, we consider it is
            // changed.
            synchronized (this) {
              if (configFile.lastModified() != lastFileModifiedTime) {
                lastFileModifiedTime = configFile.lastModified();
                configFileLoader.reload();
              }
            }
          }
        },
        500,
        500,
        TimeUnit.MILLISECONDS);
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    context = this.getApplicationContext();
    configure = new Configure();
    preferences = context.getApplicationContext().getSharedPreferences("setting", 0);

    configure.psize.width = preferences.getInt("picture_width", 0);
    configure.psize.height = preferences.getInt("picture_height", 0);
    configure.autoFocus = preferences.getBoolean("autofocus", true);
    this.setContentView(R.layout.new_setting_layout);

    final Spinner photo_size_spinner = new Spinner(configActivity.this);
    ArrayAdapter<String> photo_size_adt =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, configure.sizes);
    photo_size_adt.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    photo_size_spinner.setAdapter(photo_size_adt);
    // photo_size_spinner.setVisibility(View.INVISIBLE);
    photo_size_spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            configure.psize.setSize(configure.sizes[position]);
            Editor editor = preferences.edit();
            editor.putInt("picture_width", configure.psize.width);
            editor.putInt("picture_height", configure.psize.height);
            editor.commit();
          }

          public void onNothingSelected(AdapterView<?> parent) {}
        });
    // photo_size_spinner.setSelection(0);
    for (int i = 0; i < configure.sizes.length; i++) {
      if (configure.sizes[i].equals(configure.psize.getText())) photo_size_spinner.setSelection(i);
    }

    final Spinner autofocus_spinner = new Spinner(configActivity.this);
    ArrayAdapter<String> autofocus_adt =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, Configure.focus);
    autofocus_adt.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    autofocus_spinner.setAdapter(autofocus_adt);

    autofocus_spinner.setOnItemSelectedListener(
        new Spinner.OnItemSelectedListener() {
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            configure.autoFocus = Configure.focus[position].equals("Yes");
            preferences.edit().putBoolean("autofocus", configure.autoFocus).commit();
          }

          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
          }
        });
    // autofocus_spinner.setSelection(0);
    for (int i = 0; i < Configure.focus.length; i++) {
      if (Configure.focus[i].equals(configure.autoFocus ? "Yes" : "No"))
        autofocus_spinner.setSelection(i);
    }

    TableRow clickable_photosize = (TableRow) this.findViewById(R.id.row_photosize);
    clickable_photosize.addView(photo_size_spinner);

    TableRow clickable_autofocus = (TableRow) this.findViewById(R.id.row_autofocus);
    clickable_autofocus.addView(autofocus_spinner);
  }
Beispiel #8
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle state) {
    super.onCreate(state);
    boolean open = false;
    if (state != null) {
      this.ticket = (Ticket) state.getSerializable("ticket");
      this.payments = new ArrayList<Payment>();
      int count = state.getInt("payCount");
      for (int i = 0; i < count; i++) {
        Payment p = (Payment) state.getSerializable("payment" + i);
        this.payments.add(p);
      }
      open = state.getBoolean("drawerOpen");
      this.printEnabled = state.getBoolean("printEnabled");
    } else {
      this.ticket = ticketInit;
      ticketInit = null;
      this.payments = new ArrayList<Payment>();
      this.printEnabled = true;
    }
    setContentView(R.layout.payments);
    this.scroll = (ScrollView) this.findViewById(R.id.scroll);
    this.scrollHandler = new Handler(this);
    this.keyboard = (NumKeyboard) this.findViewById(R.id.numkeyboard);
    keyboard.setKeyHandler(new Handler(this));
    this.input = (EditText) this.findViewById(R.id.input);
    this.giveBack = (TextView) this.findViewById(R.id.give_back);
    this.ticketTotal = (TextView) this.findViewById(R.id.ticket_total);
    this.ticketRemaining = (TextView) this.findViewById(R.id.ticket_remaining);
    this.paymentModes = (Gallery) this.findViewById(R.id.payment_modes);
    PaymentModesAdapter adapt = new PaymentModesAdapter(PaymentMode.defaultModes(this));
    this.paymentModes.setAdapter(adapt);
    this.paymentModes.setOnItemSelectedListener(this);
    this.paymentModes.setSelection(0, false);
    this.currentMode = PaymentMode.defaultModes(this).get(0);
    String total = this.getString(R.string.ticket_total, this.ticket.getTotalPrice());

    this.slidingHandle = (ImageView) this.findViewById(R.id.handle);
    this.slidingDrawer = (SlidingDrawer) this.findViewById(R.id.drawer);
    this.slidingDrawer.setOnDrawerOpenListener(
        new OnDrawerOpenListener() {
          @Override
          public void onDrawerOpened() {
            slidingHandle.setImageResource(R.drawable.slider_close);
          }
        });
    slidingDrawer.setOnDrawerCloseListener(
        new OnDrawerCloseListener() {
          @Override
          public void onDrawerClosed() {
            slidingHandle.setImageResource(R.drawable.slider_open);
          }
        });
    if (open) {
      this.slidingDrawer.open();
    }

    this.paymentsList = (ListView) this.findViewById(R.id.payments_list);
    PaymentsAdapter padapt = new PaymentsAdapter(this.payments, this);
    this.paymentsList.setAdapter(padapt);

    this.ticketTotal.setText(total);
    this.updateDisplayToMode();
    this.refreshRemaining();
    this.refreshGiveBack();
    this.refreshInput();
    // Init printer connection
    this.printer = new PrinterConnection(new Handler(this));
    try {
      if (!this.printer.connect(this)) {
        this.printer = null;
      }
    } catch (IOException e) {
      Log.w(LOG_TAG, "Unable to connect to printer", e);
      Error.showError(R.string.print_no_connexion, this);
      // Set null to cancel printing
      this.printer = null;
    }
    // Init Payleven API
    PaylevenApi.configure("edaffb929bd34aa78122b2d15a36a5c7");
    // Update UI based upon settings
    View paylevenBtn = this.findViewById(R.id.btnPayleven);
    if (Configure.getPayleven(this)) {
      paylevenBtn.setVisibility(View.VISIBLE);
    } else {
      paylevenBtn.setVisibility(View.INVISIBLE);
    }
  }
 /** Handle TrytonCall feedback. */
 @SuppressWarnings("unchecked")
 public boolean handleMessage(Message msg) {
   // Process message
   switch (msg.what) {
     case TrytonCall.CALL_SAVE_OK:
       this.callId = 0;
       this.hideLoadingDialog();
       Toast t = Toast.makeText(this, R.string.data_send_done, Toast.LENGTH_SHORT);
       t.show();
       // Update data with fresh one
       Model m = (Model) msg.obj;
       if (Session.current.isCreatingModel()) {
         this.postCreate(m);
       } else {
         this.postUpdate(m);
       }
       break;
     case TrytonCall.CALL_DELETE_OK:
       this.callId = 0;
       this.hideLoadingDialog();
       this.postDelete();
       break;
     case TrytonCall.CALL_SAVE_NOK:
     case TrytonCall.CALL_DELETE_NOK:
     case DataLoader.DATA_NOK:
     case DataLoader.VIEWS_NOK:
       this.callId = 0;
       this.hideLoadingDialog();
       Exception e = (Exception) msg.obj;
       if (!AlertBuilder.showUserError(e, this) && !AlertBuilder.showUserError(e, this)) {
         if (Configure.getOfflineUse(this)) {
           // Generic error, queue call and continue
           t = Toast.makeText(this, R.string.data_send_queued, Toast.LENGTH_SHORT);
           t.show();
           if (msg.what == TrytonCall.CALL_DELETE_NOK) {
             this.queueDelete();
           } else {
             if (!Session.current.isCreatingModel()) {
               this.queueUpdate();
             } else {
               this.queueCreate();
             }
           }
         } else {
           // Show the error
           AlertDialog.Builder b = new AlertDialog.Builder(this);
           b.setTitle(R.string.error);
           b.setMessage(R.string.network_error);
           ((Exception) msg.obj).printStackTrace();
           b.show();
         }
       }
       break;
     case DataLoader.VIEWS_OK:
       this.callId = 0;
       this.view = (ModelView) ((Object[]) msg.obj)[1];
       this.loadDataAndMeta();
       break;
     case DataLoader.RELFIELDS_OK:
       this.callId = 0;
       this.relFields = (List<RelField>) ((Object[]) msg.obj)[1];
       this.loadData();
       break;
     case DataLoader.DATA_OK:
       this.callId = 0;
       List<Model> dataList = (List<Model>) ((Object[]) msg.obj)[1];
       if (dataList.size() > 0) {
         // Refresh edited model (not done when creating
         // as data is not loaded)
         Session.current.updateEditedModel(dataList.get(0));
       }
       this.initView();
       this.refreshDisplay();
       this.hideLoadingDialog();
       break;
     case TrytonCall.NOT_LOGGED:
       this.callId = 0;
       // Ask for relog
       this.lastFailMessage = (Integer) msg.obj;
       this.hideLoadingDialog();
       AlertBuilder.showRelog(this, new Handler(this));
       break;
     case AlertBuilder.RELOG_CANCEL:
       if (this.lastFailMessage == TrytonCall.CALL_DELETE_NOK) {
         // Nothing
       } else if (this.lastFailMessage == TrytonCall.CALL_SAVE_NOK) {
         // Nothing
       } else {
         this.finish();
       }
       break;
     case AlertBuilder.RELOG_OK:
       if (this.lastFailMessage == TrytonCall.CALL_DELETE_NOK) {
         this.sendDelete();
       } else if (this.lastFailMessage == TrytonCall.CALL_SAVE_NOK) {
         this.sendSave();
       } else {
         this.loadViewAndData();
       }
       break;
   }
   return true;
 }