/*******************************************************************************
 *  Copyright 2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.services.basicmediastorageapplicationprofiles;

import java.io.IOException;
import java.util.Locale;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.services.dicomdir.DICOMDIR;
import cdac.medinfo.sdk.dcm30_04.services.minquirefile.MInquireFile;
import cdac.medinfo.sdk.dcm30_04.services.mread.MRead;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
import cdac.medinfo.sdk.dcm30_04.utils.ResourceBundleWrapper;
/**
 * This class is implemented to use DIMSE_M-Services.
 * The MediaStorage_FSR supports the Media Storage Operations M-Read and M-INQUIRE FILE.
 * It reads data set from DICOMDIR.
 * It display data set.
 * */
public class MediaStorage_FSR
{
	/**
	 * This function reads data set from DICOMDIR.
	 * It displays data set.
	 */
	public IDataSet process(String strStoragePath) throws IOException  
	{
		IDataSet objIdataset1;
		/**
		 *  Creates the object of MRead and MInquire File.
		 * call the function to read & display DICOM DIR File Set
		 */	
		DICOMDIR objDICOMDIR = new DICOMDIR(strStoragePath);
		if(strStoragePath == null||strStoragePath == "" ||strStoragePath == "null"||!objDICOMDIR.isDICOMDIRExist()||strStoragePath.isEmpty())
		{
			DicomLogger.getLogger().log(ResourceBundleWrapper.getValue("warning", "PrimaryAttributeMissing", new Locale(DicomConfig.createInstance().getLocale())));
			DicomLogger.getLogger().log(ResourceBundleWrapper.getValue("warning", "DICOMDIR.FileNotFound", new Locale(DicomConfig.createInstance().getLocale())));
			objIdataset1= null;
		}
		else
		{
			MRead objMRead = new MRead();
			objIdataset1 = objMRead.process(strStoragePath);
			MInquireFile objMInquireFile= new MInquireFile();
			objMInquireFile.processTime(strStoragePath);
		}
		return objIdataset1;
	}
}
