summaryrefslogblamecommitdiffstats
path: root/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImageInfos.java
blob: 547916f0750b3849c7e4da9f95903c69aca471a0 (plain) (tree)
1
2
3
4
5
6
7
8
9






                                                 

                                          


                                                                                           
                                
 
 














                                                                                

                                                                              
 
                                                                                                                                   




                                                       
                                 










                                                               


                                                              

                                           


                                                   
















                                                  


                                          

                               







                                                                      
 
package org.openslx.imagemaster.serverconnection;

import java.sql.Timestamp;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import org.openslx.imagemaster.db.DbImage;

/**
 * Helper class for ImageProcessor to save some infos about the images in the process list.
 */
public class UploadingImageInfos
{

	/**
	 * Token for the satellite.
	 */
	private String token;
	/**
	 * The missing blocks that need to be uploaded by the satellite.
	 */
	private List<Integer> missingBlocks;
	/**
	 * The list of blocks that the satellite received last.
	 * (This could be used to tell the CRCChecker to check these blocks.
	 */
	private List<Integer> lastSentBlocks = new LinkedList<>();
	private String serverSessionId;
	private Timestamp ts; // when did the server something for the last time
	private DbImage dbImage = null;	// the DB representation of this image
	private String uuid;

	protected UploadingImageInfos(String token, List<Integer> missingBlocks, String serverSessionId, Timestamp ts, String uuid)
	{
		this.token = token;
		this.missingBlocks = missingBlocks;
		this.serverSessionId = serverSessionId;
		this.ts = ts;
		this.uuid = uuid;
	}

	protected void removeBlock( int number )
	{
		this.missingBlocks.remove( number );
	}

	protected void removeBlocks( Collection<Integer> list )
	{
		this.missingBlocks.removeAll( list );
	}

	protected void setLastSentBlocks( List<Integer> list )
	{
		this.lastSentBlocks = list;
	}

	protected List<Integer> getLastSentBlocks()
	{
		return this.lastSentBlocks;
	}

	protected String getToken()
	{
		return this.token;
	}

	protected List<Integer> getMissingBlocks()
	{
		return this.missingBlocks;
	}

	protected String getServerSessionId()
	{
		return this.serverSessionId;
	}

	protected Timestamp getTimestamp()
	{
		return this.ts;
	}

	protected DbImage getDbImage()
	{
		if ( dbImage == null ) {
			dbImage = DbImage.getImageByUUID( this.uuid );
		}
		return this.dbImage;
	}
}