src/org/ohmage/cache/AsyncImageProcessor.java
private void processImage(final Image image) {
			boolean markAsProcessed = true;
			
			try {
				// validate that the image data is valid
				if (image.validate()) {
					// Create the sub-images.
					try {
						for(Size size : Image.getSizes()) {
							// If the size of the image does not exist, create it.
							if(! image.sizeExists(size)) {
								image.saveImage(size);
							}
						}
					}
					catch(DomainException e) {
						LOGGER.error(
							"One of the sizes of the image could not be created: " + 
								image.getId().toString(),
							e);
						// Will retry later
						markAsProcessed = false; 
					}
				} 
			} finally { 
				// close the stream
				image.closeImageStreams();				
			}
			
			if (markAsProcessed) {
				// Mark the image as processed.
				try {
					ImageServices.instance().markImageAsProcessed(image.getId());
				}
				catch(ServiceException e) {
					LOGGER.error(
						"The image could not be marked as processed: " + 
							image.getId().toString(),
						e);
					return;
				}
			}
		}
/**
		 * Reads the original data, creates the sub-images and saves them.
		 * 
		 * @param image
		 *        The image that should be validated and have its variants
		 *        saved and processed.
		 */
Reads the original data, creates the sub-images and saves them.

@param image
The image that should be validated and have its variants
saved and processed.
Reads the original data creates the sub - images and saves them . @param image The image that should be validated and have its variants saved and processed .
private void processImage(final Image image) {
			boolean markAsProcessed = true;
			try {
				if (image.validate()) {
					try {
						for(Size size : Image.getSizes()) {
							if(! image.sizeExists(size)) {
								image.saveImage(size);
							}
						}
					}
					catch(DomainException e) {
						LOGGER.error(
							"One of the sizes of the image could not be created: " + 
								image.getId().toString(),
							e);
						markAsProcessed = false; 
					}
				} 
			} finally { 
				image.closeImageStreams();				
			}
			if (markAsProcessed) {
				try {
					ImageServices.instance().markImageAsProcessed(image.getId());
				}
				catch(ServiceException e) {
					LOGGER.error(
						"The image could not be marked as processed: " + 
							image.getId().toString(),
						e);
					return;
				}
			}
		}
private void processImage ( final Image image ) { boolean markAsProcessed = true ; try { if ( image . validate ( ) ) { try { for ( Size size : Image . getSizes ( ) ) { if ( ! image . sizeExists ( size ) ) { image . saveImage ( size ) ; } } } catch ( DomainException e ) { LOGGER . error ( "One of the sizes of the image could not be created: " + image . getId ( ) . toString ( ) , e ) ; markAsProcessed = false ; } } } finally { image . closeImageStreams ( ) ; } if ( markAsProcessed ) { try { ImageServices . instance ( ) . markImageAsProcessed ( image . getId ( ) ) ; } catch ( ServiceException e ) { LOGGER . error ( "The image could not be marked as processed: " + image . getId ( ) . toString ( ) , e ) ; return ; } } }
Reads the original data, creates the sub-images and saves them.
Reads the original data creates the sub - images and saves them .
// validate that the image data is valid // Create the sub-images. // If the size of the image does not exist, create it. // Will retry later // close the stream // Mark the image as processed.