Example #1
0
  public SwingInstall() {
    installer = new Install();
    osTasks = OperatingSystem.getOperatingSystem().getOSTasks(installer);

    appName = installer.getProperty("app.name");

    setTitle(appName + " installer");

    JPanel content = new JPanel(new WizardLayout());
    setContentPane(content);

    caption = new JLabel();
    caption.setFont(new Font("SansSerif", Font.BOLD, 18));

    ActionHandler actionHandler = new ActionHandler();

    cancelButton = new JButton("Cancel");
    cancelButton.setRequestFocusEnabled(false);
    cancelButton.addActionListener(actionHandler);
    prevButton = new JButton("Previous");
    prevButton.setRequestFocusEnabled(false);
    prevButton.addActionListener(actionHandler);
    nextButton = new JButton();
    nextButton.setRequestFocusEnabled(false);
    nextButton.addActionListener(actionHandler);

    content.add(caption);
    content.add(cancelButton);
    content.add(prevButton);
    content.add(nextButton);

    String clazz = OperatingSystem.getOperatingSystem().getClass().getName();
    String completedInfo = "done-" + clazz.substring(clazz.indexOf('$') + 1) + ".html";

    pages =
        new Component[] {
          chooseDirectory = new ChooseDirectory(),
          progress = new SwingProgress(),
          new TextPanel(completedInfo)
        };

    selectComponents = new SelectComponents();

    for (int i = 0; i < pages.length; i++) content.add(pages[i]);

    pageChanged();

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowHandler());

    Dimension screen = getToolkit().getScreenSize();
    pack();
    setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2);
    setVisible(true);
  }
 /** Eine Seite, die sich im RAM befindet, anhand der pteRAMlist auswählen und zurückgeben */
 public PageTableEntry selectNextRAMpteAndReplace(PageTableEntry newPte) {
   if (os.getReplacementAlgorithm() == OperatingSystem.ImplementedReplacementAlgorithms.CLOCK) {
     return clockAlgorithm(newPte);
   } else {
     if (os.getReplacementAlgorithm() == OperatingSystem.ImplementedReplacementAlgorithms.FIFO) {
       return fifoAlgorithm(newPte);
     } else {
       return randomAlgorithm(newPte);
     }
   }
 }
Example #3
0
  public UserAgent(String userAgentString) {
    String userAgentLowercaseString =
        userAgentString == null ? null : userAgentString.toLowerCase();
    Browser browser = Browser.parseUserAgentLowercaseString(userAgentLowercaseString);

    OperatingSystem operatingSystem = OperatingSystem.UNKNOWN;

    // BOTs don't have an interesting OS for us
    if (browser != Browser.BOT)
      operatingSystem = OperatingSystem.parseUserAgentLowercaseString(userAgentLowercaseString);

    this.operatingSystem = operatingSystem;
    this.browser = browser;
    this.id = ((operatingSystem.getId() << 16) + browser.getId());
    this.userAgentString = userAgentString;
  }
Example #4
0
    private JPanel createCompPanel() {
      filesets = new Vector();

      int count = installer.getIntegerProperty("comp.count");
      JPanel panel = new JPanel(new GridLayout(count, 1));

      String osClass = OperatingSystem.getOperatingSystem().getClass().getName();
      osClass = osClass.substring(osClass.indexOf('$') + 1);

      for (int i = 0; i < count; i++) {
        String os = installer.getProperty("comp." + i + ".os");

        if (os != null && !osClass.equals(os)) continue;

        JCheckBox checkBox =
            new JCheckBox(
                installer.getProperty("comp." + i + ".name")
                    + " ("
                    + installer.getProperty("comp." + i + ".disk-size")
                    + "Mb)");
        checkBox.getModel().setSelected(true);
        checkBox.addActionListener(this);
        checkBox.setRequestFocusEnabled(false);

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

      Dimension dim = panel.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      panel.setMaximumSize(dim);

      return panel;
    }
  /**
   * FIFO-Algorithmus: Auswahl = Listenkopf (1. Element) Anschließend Listenkopf löschen, neue Seite
   * (newPte) an Liste anhängen
   */
  private PageTableEntry fifoAlgorithm(PageTableEntry newPte) {
    PageTableEntry pte; // Auswahl

    pte = (PageTableEntry) pteRAMlist.getFirst();
    os.testOut("Prozess " + pid + ": FIFO-Algorithmus hat pte ausgewählt: " + pte.virtPageNum);
    pteRAMlist.removeFirst();
    pteRAMlist.add(newPte);
    return pte;
  }
Example #6
0
 /* (non-Javadoc)
  * @see java.lang.Object#hashCode()
  */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((browser == null) ? 0 : browser.hashCode());
   result = prime * result + id;
   result = prime * result + ((operatingSystem == null) ? 0 : operatingSystem.hashCode());
   return result;
 }
  /**
   * Changes the running state of the process manager.
   *
   * @param running True if the process manager is running, false if not.
   */
  public void setRunning(boolean running) {

    if (running) {
      rootProcess =
          new Process(
              host, null, 0, host.getFileSystemManager().getFile("C:/system/boot/kernel"), null);
    } else {
      rootProcess.interrupt(true);
    }
  }
  /** RANDOM-Algorithmus: Zufällige Auswahl */
  private PageTableEntry randomAlgorithm(PageTableEntry newPte) {
    /* TODO:RANDOM Algorithmus */

    PageTableEntry pte; // Auswahl

    final int randomIndex = new Random().nextInt(pteRAMlist.size());
    pte = (PageTableEntry) pteRAMlist.get(randomIndex);
    os.testOut("Prozess " + pid + ": Random-Algorithmus hat pte ausgewählt: " + pte.virtPageNum);
    pteRAMlist.remove(randomIndex);
    pteRAMlist.add(newPte);
    return pte;
  }
Example #9
0
  /**
   * Returns UserAgent based on combined string representation
   *
   * @param name
   * @return
   */
  public static UserAgent valueOf(String name) {
    if (name == null) throw new NullPointerException("Name is null");

    String[] elements = name.split("-");

    if (elements.length == 2) {
      OperatingSystem operatingSystem = OperatingSystem.valueOf(elements[0]);
      Browser browser = Browser.valueOf(elements[1]);
      return new UserAgent(operatingSystem, browser);
    }

    throw new IllegalArgumentException("Invalid string for userAgent " + name);
  }
  /**
   * CLOCK-Algorithmus (Second-Chance): Nächstes Listenelement, ausgehend vom aktuellen Index, mit
   * Referenced-Bit = 0 (false) auswählen Sonst R-Bit auf 0 setzen und nächstes Element in der
   * pteRAMlist untersuchen. Anschließend die ausgewählte Seite durch die neue Seite (newPte) am
   * selben Listenplatz ersetzen
   */
  private PageTableEntry clockAlgorithm(PageTableEntry newPte) {
    PageTableEntry pte; // Aktuell untersuchter Seitentabelleneintrag

    // Immer ab altem "Uhrzeigerstand" weitersuchen
    pte = (PageTableEntry) pteRAMlist.get(pteRAMlistIndex);

    // Suche den nächsten Eintrag mit referenced == false (R-Bit = 0)
    while (pte.referenced == true) {
      // Seite wurde referenziert, also nicht auswählen, sondern R-Bit
      // zurücksetzen
      os.testOut(
          "Prozess "
              + pid
              + ": CLOCK-Algorithmus! --- pte.vpn: "
              + pte.virtPageNum
              + " ref: "
              + pte.referenced);
      pte.referenced = false;
      incrementPteRAMlistIndex();
      pte = (PageTableEntry) pteRAMlist.get(pteRAMlistIndex);
    }

    // Seite ausgewählt! (--> pteRAMlistIndex)
    // Alte Seite gegen neue in pteRAMlist austauschen
    pteRAMlist.remove(pteRAMlistIndex);
    pteRAMlist.add(pteRAMlistIndex, newPte);
    // Index auf Nachfolger setzen
    incrementPteRAMlistIndex();
    os.testOut(
        "Prozess "
            + pid
            + ": CLOCK-Algorithmus hat pte ausgewählt: "
            + pte.virtPageNum
            + "  Neuer pteRAMlistIndex ist "
            + pteRAMlistIndex);

    return pte;
  }
Example #11
0
 /* (non-Javadoc)
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   final UserAgent other = (UserAgent) obj;
   if (browser == null) {
     if (other.browser != null) return false;
   } else if (!browser.equals(other.browser)) return false;
   if (id != other.id) return false;
   if (operatingSystem == null) {
     if (other.operatingSystem != null) return false;
   } else if (!operatingSystem.equals(other.operatingSystem)) return false;
   return true;
 }
Example #12
0
    ChooseDirectory() {
      super(new BorderLayout());

      osTaskDirs = new HashMap();

      JPanel directoryPanel =
          new JPanel(new VariableGridLayout(VariableGridLayout.FIXED_NUM_COLUMNS, 3, 12, 12));

      installDir =
          addField(
              directoryPanel,
              "Install program in:",
              OperatingSystem.getOperatingSystem().getInstallDirectory(appName));

      for (int i = 0; i < osTasks.length; i++) {
        OperatingSystem.OSTask osTask = osTasks[i];
        String label = osTask.getLabel();
        if (label != null) {
          JTextField field = addField(directoryPanel, label, osTask.getDirectory());
          osTaskDirs.put(osTask, field);
        }
      }
      ChooseDirectory.this.add(BorderLayout.NORTH, directoryPanel);
    }
Example #13
0
  /**
   * Parses the input row String into a Java object. For performance reasons this works in-place
   * updating the fields within this SnowPlowEventStruct, rather than creating a new one.
   *
   * @param row The raw String containing the row contents
   * @return true if row was successfully parsed, false otherwise
   * @throws SerDeException For any exception during parsing
   */
  public boolean updateByParsing(String row) throws SerDeException {

    // First we reset the object's fields
    nullify();

    // We have to handle any header rows
    if (row.startsWith("#Version:") || row.startsWith("#Fields:")) {
      return false; // Empty row will be discarded by Hive
    }

    final Matcher m = cfRegex.matcher(row);

    // 0. First check our row is kosher

    // -> is row from a CloudFront log? Will throw an exception if not
    if (!m.matches())
      throw new SerDeException("Row does not match expected CloudFront regexp pattern");

    // -> was generated by sp.js? If not (e.g. favicon.ico request), then silently return
    final String object = m.group(8);
    final String querystring = m.group(12);
    if (!(object.startsWith("/ice.png") || object.equals("/i") || object.startsWith("/i?"))
        || isNullField(querystring)) { // Also works if Forward Query String = yes
      return false;
    }

    // 1. Now we retrieve the fields which get directly passed through
    this.dt = m.group(1);
    this.tm = m.group(2); // CloudFront date format matches Hive's
    this.user_ipaddress = m.group(5);

    // 2. Now grab the user agent
    final String ua = m.group(11);
    try {
      this.useragent = decodeSafeString(ua);
    } catch (Exception e) {
      getLog().warn(e.getClass().getSimpleName() + " on { useragent: " + ua + " }");
    }

    // 3. Next we dis-assemble the user agent...
    final UserAgent userAgent = UserAgent.parseUserAgentString(ua);

    // -> browser fields
    final Browser b = userAgent.getBrowser();
    this.br_name = b.getName();
    this.br_family = b.getGroup().getName();
    final Version v = userAgent.getBrowserVersion();
    this.br_version = (v == null) ? null : v.getVersion();
    this.br_type = b.getBrowserType().getName();
    this.br_renderengine = b.getRenderingEngine().toString();

    // -> OS-related fields
    final OperatingSystem os = userAgent.getOperatingSystem();
    this.os_name = os.getName();
    this.os_family = os.getGroup().getName();
    this.os_manufacturer = os.getManufacturer().getName();

    // -> device/hardware-related fields
    this.dvce_type = os.getDeviceType().getName();
    this.dvce_ismobile = os.isMobileDevice();
    this.dvce_ismobile_bt = (byte) (this.dvce_ismobile ? 1 : 0);

    // 4. Now for the versioning (tracker versioning is handled below)
    this.v_collector = collectorVersion;
    this.v_etl = "serde-" + ProjectSettings.VERSION;

    // 5. Now we generate the event ID
    this.event_id = generateEventId();

    // 6. Now we dis-assemble the querystring.
    String qsUrl = null; // We use this in the block below, and afterwards
    List<NameValuePair> params = null; // We re-use this for efficiency
    try {
      params = URLEncodedUtils.parse(URI.create("http://localhost/?" + querystring), cfEncoding);

      // For performance, don't convert to a map, just loop through and match to our variables as we
      // go
      for (NameValuePair pair : params) {

        final String name = pair.getName();
        final String value = pair.getValue();

        final QuerystringFields field;
        try {
          field =
              QuerystringFields.valueOf(
                  name.toUpperCase()); // Java pre-7 can't switch on a string, so hash the string
        } catch (IllegalArgumentException e) {
          getLog().warn("Unexpected params { " + name + ": " + value + " }");
          continue;
        }

        try {
          switch (field) {
              // Common fields
            case E:
              this.event = asEventType(value);
              break;
            case IP:
              this.user_ipaddress = value;
              break;
            case AID:
              this.app_id = value;
              break;
            case P:
              this.platform = value;
              break;
            case TID:
              this.txn_id = value;
              break;
            case UID:
              this.user_id = value;
              break;
            case FP:
              this.user_fingerprint = value;
              break;
            case VID:
              this.visit_id = Integer.parseInt(value);
              break;
            case TSTAMP:
              // Replace our timestamp fields with the client's timestamp
              String[] timestamp = value.split(" ");
              this.dt = timestamp[0];
              this.tm = timestamp[1];
              break;
            case TV:
              this.v_tracker = value;
              break;
            case LANG:
              this.br_lang = value;
              break;
            case F_PDF:
              if ((this.br_features_pdf = stringToByte(value)) == 1) this.br_features.add("pdf");
              break;
            case F_FLA:
              if ((this.br_features_flash = stringToByte(value)) == 1) this.br_features.add("fla");
              break;
            case F_JAVA:
              if ((this.br_features_java = stringToByte(value)) == 1) this.br_features.add("java");
              break;
            case F_DIR:
              if ((this.br_features_director = stringToByte(value)) == 1)
                this.br_features.add("dir");
              break;
            case F_QT:
              if ((this.br_features_quicktime = stringToByte(value)) == 1)
                this.br_features.add("qt");
              break;
            case F_REALP:
              if ((this.br_features_realplayer = stringToByte(value)) == 1)
                this.br_features.add("realp");
              break;
            case F_WMA:
              if ((this.br_features_windowsmedia = stringToByte(value)) == 1)
                this.br_features.add("wma");
              break;
            case F_GEARS:
              if ((this.br_features_gears = stringToByte(value)) == 1)
                this.br_features.add("gears");
              break;
            case F_AG:
              if ((this.br_features_silverlight = stringToByte(value)) == 1)
                this.br_features.add("ag");
              break;
            case COOKIE:
              this.br_cookies = stringToBoolean(value);
              this.br_cookies_bt = (byte) (this.br_cookies ? 1 : 0);
              break;
            case RES:
              String[] resolution = value.split("x");
              if (resolution.length != 2) throw new Exception("Couldn't parse res field");
              this.dvce_screenwidth = Integer.parseInt(resolution[0]);
              this.dvce_screenheight = Integer.parseInt(resolution[1]);
              break;
            case CD:
              this.br_colordepth = value;
              break;
            case TZ:
              this.os_timezone = decodeSafeString(value);
              break;
            case REFR:
              this.page_referrer = decodeSafeString(value);
              break;
            case URL:
              qsUrl = pair.getValue(); // We might use this later for the page URL
              break;

              // Page-view only
            case PAGE:
              this.page_title = decodeSafeString(value);
              break;

              // Event only
            case EV_CA:
              this.ev_category = decodeSafeString(value);
              break;
            case EV_AC:
              this.ev_action = decodeSafeString(value);
              break;
            case EV_LA:
              this.ev_label = decodeSafeString(value);
              break;
            case EV_PR:
              this.ev_property = decodeSafeString(value);
              break;
            case EV_VA:
              this.ev_value = decodeSafeString(value);
              break;

              // Ecommerce
            case TR_ID:
              this.tr_orderid = decodeSafeString(value);
              break;
            case TR_AF:
              this.tr_affiliation = decodeSafeString(value);
              break;
            case TR_TT:
              this.tr_total = decodeSafeString(value);
              break;
            case TR_TX:
              this.tr_tax = decodeSafeString(value);
              break;
            case TR_SH:
              this.tr_shipping = decodeSafeString(value);
              break;
            case TR_CI:
              this.tr_city = decodeSafeString(value);
              break;
            case TR_ST:
              this.tr_state = decodeSafeString(value);
              break;
            case TR_CO:
              this.tr_country = decodeSafeString(value);
              break;
            case TI_ID:
              this.ti_orderid = decodeSafeString(value);
              break;
            case TI_SK:
              this.ti_sku = decodeSafeString(value);
              break;
            case TI_NA:
              this.ti_name = decodeSafeString(value);
              break;
            case TI_CA:
              this.ti_category = decodeSafeString(value);
              break;
            case TI_PR:
              this.ti_price = decodeSafeString(value);
              break;
            case TI_QU:
              this.ti_quantity = decodeSafeString(value);
              break;
          }
        } catch (Exception e) {
          getLog().warn(e.getClass().getSimpleName() + " on { " + name + ": " + value + " }");
        }
      }
    } catch (IllegalArgumentException e) {
      getLog().warn("Corrupted querystring { " + querystring + " }");
    }

    // 7. Choose the page_url
    final String cfUrl = m.group(10);
    if (!isNullField(cfUrl)) { // CloudFront didn't provide the URL as cs(Referer)
      this.page_url = cfUrl; // The CloudFront cs(Referer) URL
    } else {
      try {
        this.page_url =
            decodeSafeString(
                qsUrl); // Use the decoded querystring URL. Might be null (returned as null)
      } catch (Exception e) {
        getLog().warn(e.getClass().getSimpleName() + " on { qsUrl: " + qsUrl + " }");
      }
    }

    // 8. Finally handle the marketing fields in the page_url
    // Re-use params to avoid creating another object
    if (this.page_url != null) {
      params = null;
      try {
        params = URLEncodedUtils.parse(URI.create(this.page_url), "UTF-8");
      } catch (IllegalArgumentException e) {
        getLog().warn("Couldn't parse page_url: " + page_url);
      }
      if (params != null) {
        // For performance, don't convert to a map, just loop through and match to our variables as
        // we go
        for (NameValuePair pair : params) {

          final String name = pair.getName();
          final String value = pair.getValue();

          final MarketingFields field;
          try {
            field =
                MarketingFields.valueOf(
                    name.toUpperCase()); // Java pre-7 can't switch on a string, so hash the string
          } catch (IllegalArgumentException e) {
            // Do nothing: non-marketing related querystring fields are not an issue.
            continue;
          }

          try {
            switch (field) {
                // Marketing fields
              case UTM_MEDIUM:
                this.mkt_medium = decodeSafeString(value);
                break;
              case UTM_SOURCE:
                this.mkt_source = decodeSafeString(value);
                break;
              case UTM_TERM:
                this.mkt_term = decodeSafeString(value);
                break;
              case UTM_CONTENT:
                this.mkt_content = decodeSafeString(value);
                break;
              case UTM_CAMPAIGN:
                this.mkt_campaign = decodeSafeString(value);
                break;
            }
          } catch (Exception e) {
            getLog().warn(e.getClass().getSimpleName() + " on { " + name + ": " + value + " }");
          }
        }
      }
    }

    return true; // Successfully updated the row.
  }
 /** Pte in pteRAMlist eintragen, wenn sich die Zahl der RAM-Seiten des Prozesses erhöht hat. */
 public void pteRAMlistInsert(PageTableEntry pte) {
   os.testOut(
       "pteRAMlistInsert in Prozess " + pid + ": pte mit vpn " + pte.virtPageNum + " angefügt!");
   pteRAMlist.add(pte);
 }
Example #15
0
 public UserAgent(OperatingSystem operatingSystem, Browser browser) {
   this.operatingSystem = operatingSystem;
   this.browser = browser;
   this.id = ((operatingSystem.getId() << 16) + browser.getId());
 }
Example #16
0
 /**
  * Returns UserAgent based on specified unique id
  *
  * @param id
  * @return
  */
 public static UserAgent valueOf(int id) {
   OperatingSystem operatingSystem = OperatingSystem.valueOf((short) (id >> 16));
   Browser browser = Browser.valueOf((short) (id & 0x0FFFF));
   return new UserAgent(operatingSystem, browser);
 }