001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package pt.ua.dicoogle.server.queryretrieve; 020 021import java.io.IOException; 022import org.dcm4che2.data.DicomObject; 023import org.dcm4che2.net.Association; 024import org.dcm4che2.net.DicomServiceException; 025import org.dcm4che2.net.service.CMoveSCP; 026import org.dcm4che2.net.service.DicomService; 027import java.util.concurrent.Executor; 028import org.dcm4che2.net.CommandUtils; 029import org.dcm4che2.net.DimseRSP; 030import org.dcm4che2.net.SingleDimseRSP; 031import org.dcm4che2.net.Status; 032/** 033 * 034 * @author Luís A. Bastião Silva <bastiao@ua.pt> 035 */ 036public class CMoveService extends DicomService implements CMoveSCP 037{ 038 039 040 private final Executor executor; 041 042 public CMoveService(String[] sopClasses, Executor executor) 043 { 044 super(sopClasses); 045 this.executor = executor; 046 } 047 048 public CMoveService(String sopClass, Executor executor) 049 { 050 super(sopClass); 051 this.executor = executor; 052 } 053 054@Override 055 public void cmove(Association as, int pcid, DicomObject rq, 056 DicomObject data) throws DicomServiceException, IOException 057 { 058 //DebugManager.getInstance().debug("just cmove"); 059 060 //DebugManager.getInstance().debug(CommandUtils.toString(rq, pcid, "1.2.2.2.2.2.2.0")); 061 DicomObject cmdrsp = CommandUtils.mkRSP(rq, CommandUtils.SUCCESS); 062 DimseRSP rsp = doCMove(as, pcid, rq, data, cmdrsp); 063 try { 064 rsp.next(); 065 } catch (InterruptedException e) { 066 throw new DicomServiceException(rq, Status.ProcessingFailure); 067 } 068 cmdrsp = rsp.getCommand(); 069 if (CommandUtils.isPending(cmdrsp)) 070 { 071 as.registerCancelRQHandler(rq, rsp); 072 //executor.execute(new WriteMultiDimseRsp(as, pcid, rsp)); 073 } 074 else 075 { 076 as.writeDimseRSP(pcid, cmdrsp, rsp.getDataset()); 077 } 078 } 079 protected DimseRSP doCMove(Association as, int pcid, DicomObject cmd, 080 DicomObject data, DicomObject rsp) throws DicomServiceException 081 { 082 return new SingleDimseRSP(rsp); 083 } 084 085}