Exemple #1
0
  /**
   * Update the Image metadata associated with this named photo
   *
   * @throws InvalidImageDataException
   * @throws PersistenceMechanismException
   */
  public boolean updateMediaInfo(MediaData oldData, MediaData newData)
      throws InvalidImageDataException, PersistenceMechanismException {
    boolean success = false;
    RecordStore infoStore = null;
    try {
      // Parse the Data store name to get the Info store name
      String infoStoreName = oldData.getParentAlbumName();
      infoStoreName = info_label + infoStoreName.substring(album_label.length());
      infoStore = RecordStore.openRecordStore(infoStoreName, false);
      byte[] mediaDataBytes = getByteFromMediaInfo(newData);
      infoStore.setRecord(oldData.getRecordId(), mediaDataBytes, 0, mediaDataBytes.length);

    } catch (RecordStoreException rse) {
      throw new PersistenceMechanismException(rse);
    }
    // Update the Hashtable 'cache'
    setMediaInfo(oldData.getMediaLabel(), newData);
    try {
      infoStore.closeRecordStore();
    } catch (RecordStoreNotOpenException e) {
      // No problem if the RecordStore is not Open
    } catch (RecordStoreException e) {
      throw new PersistenceMechanismException(e);
    }
    return success;
  }
Exemple #2
0
  /**
   * This will populate the imageInfo hashtable with the ImageInfo object, referenced by label name
   * and populate the imageTable hashtable with Image objects referenced by the RMS record Id
   *
   * @throws PersistenceMechanismException
   */
  public MediaData[] loadMediaDataFromRMS(String recordName)
      throws PersistenceMechanismException, InvalidImageDataException {
    Vector mediaVector = new Vector();

    try {
      String infoStoreName = info_label + recordName;
      RecordStore infoStore = RecordStore.openRecordStore(infoStoreName, false);
      RecordEnumeration isEnum = infoStore.enumerateRecords(null, null, false);

      while (isEnum.hasNextElement()) {
        // Get next record
        int currentId = isEnum.nextRecordId();
        byte[] data = infoStore.getRecord(currentId);

        // Convert the data from a byte array into our ImageData
        // (metadata) object
        MediaData iiObject = getMediaFromBytes(data);

        // Add the info to the metadata hashtable
        String label = iiObject.getMediaLabel();
        mediaVector.addElement(iiObject);
        getMediaInfoTable().put(label, iiObject);
      }
      infoStore.closeRecordStore();

    } catch (RecordStoreException rse) {
      throw new PersistenceMechanismException(rse);
    }

    // Re-copy the contents into a smaller array
    MediaData[] labelArray = new MediaData[mediaVector.size()];
    mediaVector.copyInto(labelArray);
    return labelArray;
  }
Exemple #3
0
  /**
   * @param photoname
   * @param albumname
   * @param data1
   * @throws RecordStoreException
   * @throws RecordStoreFullException
   * @throws RecordStoreNotFoundException
   * @throws RecordStoreNotOpenException
   * @throws InvalidImageDataException
   */
  protected void addMediaArrayOfBytes(String photoname, String albumname, byte[] data1)
      throws RecordStoreException, RecordStoreFullException, RecordStoreNotFoundException,
          RecordStoreNotOpenException, InvalidImageDataException {

    mediaRS = RecordStore.openRecordStore(album_label + albumname, true);
    mediaInfoRS = RecordStore.openRecordStore(info_label + albumname, true);

    int rid; // new record ID for Image (bytes)
    int rid2; // new record ID for ImageData (metadata)
    rid = mediaRS.addRecord(data1, 0, data1.length);
    MediaData ii = new MediaData(rid, album_label + albumname, photoname);
    rid2 = mediaInfoRS.getNextRecordID();
    ii.setRecordId(rid2);
    data1 = getByteFromMediaInfo(ii);
    mediaInfoRS.addRecord(data1, 0, data1.length);
    mediaRS.closeRecordStore();
    mediaInfoRS.closeRecordStore();
  }
Exemple #4
0
  /**
   * Delete a single (specified) image from the (specified) record store. This will permanently
   * delete the image data and metadata from the device.
   *
   * @throws PersistenceMechanismException
   * @throws NullAlbumDataReference
   * @throws ImageNotFoundException
   */
  public boolean deleteSingleMediaFromRMS(String storeName, String mediaName)
      throws PersistenceMechanismException, ImageNotFoundException {
    boolean success = false;

    // Open the record stores containing the byte data and the meta data
    // (info)
    try {
      // Verify storeName is name without pre-fix
      mediaRS = RecordStore.openRecordStore(album_label + storeName, true);
      mediaInfoRS = RecordStore.openRecordStore(info_label + storeName, true);
      MediaData mediaData = getMediaInfo(mediaName);
      int rid = mediaData.getForeignRecordId();

      mediaRS.deleteRecord(rid);
      mediaInfoRS.deleteRecord(rid);

      mediaRS.closeRecordStore();
      mediaInfoRS.closeRecordStore();
    } catch (RecordStoreException rse) {
      throw new PersistenceMechanismException(rse);
    }
    return success;
  }
Exemple #5
0
 /**
  * [EF] Add in scenario 05
  *
  * @param photoname
  * @param imageData
  * @param albumname
  * @throws InvalidImageDataException
  * @throws PersistenceMechanismException
  */
 public void addMediaData(MediaData mediaData, String albumname)
     throws InvalidImageDataException, PersistenceMechanismException {
   try {
     mediaRS = RecordStore.openRecordStore(album_label + albumname, true);
     mediaInfoRS = RecordStore.openRecordStore(info_label + albumname, true);
     int rid2; // new record ID for ImageData (metadata)
     rid2 = mediaInfoRS.getNextRecordID();
     mediaData.setRecordId(rid2);
     byte[] data1 = getByteFromMediaInfo(mediaData);
     mediaInfoRS.addRecord(data1, 0, data1.length);
   } catch (RecordStoreException e) {
     throw new PersistenceMechanismException();
   } finally {
     try {
       mediaRS.closeRecordStore();
       mediaInfoRS.closeRecordStore();
     } catch (RecordStoreNotOpenException e) {
       e.printStackTrace();
     } catch (RecordStoreException e) {
       e.printStackTrace();
     }
   }
 }
  private void init() {
    pageMain = loaded.getWidget("back").copy();

    List<Media> installedMedias = data.getInstalledMediaList();

    player.updatePlayerMedias(installedMedias);

    {
      Widget area = pageMain.getWidget("area");
      ElementList list = new ElementList();

      for (Media m : installedMedias) {
        list.addWidget(createMedia(m));
      }

      area.addComponent(list);
    }

    EventLoader.load(pageMain, this);
    gui.addWidget(pageMain);

    gui.postEvent(new UpdateMediaEvent());
  }
Exemple #7
0
 /** Update the hashtable with new ImageInfo data */
 public void setMediaInfo(String mediaName, MediaData newData) {
   getMediaInfoTable().put(newData.getMediaLabel(), newData);
 }
  public GuiMediaPlayer() {
    data = MediaData.get(Minecraft.getMinecraft().thePlayer);
    player = MediaPlayer.instance;

    init();
  }