public psidev.psi.mi.jami.model.Publication fetchByIdentifier(String identifier, String source) throws BridgeFailedException { if(identifier == null) throw new IllegalArgumentException("Cannot fetch null identifier"); if(source == null) throw new IllegalArgumentException("Cannot fetch null source. Cane be IMEX, DOI or PUBMED"); try { Publication pub = port.getPublicationById(buildIdentifier(identifier, source)); if (pub != null){ return new ImexPublication(pub); } } catch ( IcentralFault f ) { switch( f.getFaultInfo().getFaultCode() ) { case NO_RECORD: // simply no data found, return null return null; } throw new BridgeFailedException("Impossible to find the publication " + identifier, f); } return null; }
public psidev.psi.mi.jami.model.Publication updatePublicationAdminUser( String identifier, String source, Operation operation, String user ) throws BridgeFailedException { psidev.psi.mi.jami.model.Publication p = fetchByIdentifier(identifier, source); if (p != null && p instanceof ImexPublication){ if (user != null && (user.equalsIgnoreCase(intact_user) || user.equalsIgnoreCase(phantom_user))){ ((ImexPublication) p).getCurators().add(user.toLowerCase()); } // user not recognized, throw exception as in the real webservice else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(10); IcentralFault fault = new IcentralFault("User not recognized", imexFault); throw new BridgeFailedException(fault); } } else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6); IcentralFault fault = new IcentralFault("No publication record found", imexFault); throw new BridgeFailedException(fault); } return p; }
e.printStackTrace( ); final int code = ( ( IcentralFault ) e.getCause() ).getFaultInfo().getFaultCode(); final String msg = ( ( IcentralFault ) e.getCause() ).getFaultInfo().getMessage(); System.out.println( "\n\n" + code + " - " + msg );
public psidev.psi.mi.jami.model.Publication updatePublicationStatus(String identifier, String source, PublicationStatus status) throws BridgeFailedException { psidev.psi.mi.jami.model.Publication p = fetchByIdentifier(identifier, source); if (p != null && p instanceof ImexPublication){ ((ImexPublication) p).setStatus(status); } else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6); IcentralFault fault = new IcentralFault("No publication record found", imexFault); throw new BridgeFailedException(fault); } return p; }
private void processImexCentralException(String publication, Exception e, IcentralFault f, ImexCentralManager imexCentralManager) { if( f.getFaultInfo().getFaultCode() == ImexCentralClient.USER_NOT_AUTHORIZED ) { ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.user_not_authorized, publication, null, null, null, "missing/unknown user and/or missing/invalid password provided : " + e.getMessage()); imexCentralManager.fireOnImexError(errorEvt); else if( f.getFaultInfo().getFaultCode() == ImexCentralClient.OPERATION_NOT_VALID ) { ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.operation_not_valid, publication, null, null, null, "invalid operation : " + e.getMessage()); imexCentralManager.fireOnImexError(errorEvt); else if( f.getFaultInfo().getFaultCode() == ImexCentralClient.IDENTIFIER_MISSING ) { ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.identifier_missing, publication, null, null, null, "missing identifier : " + e.getMessage()); imexCentralManager.fireOnImexError(errorEvt); else if( f.getFaultInfo().getFaultCode() == ImexCentralClient.IDENTIFIER_UNKNOWN ) { ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.identifier_unknown, publication, null, null, null, "unrecognized identifier : " + e.getMessage()); imexCentralManager.fireOnImexError(errorEvt); else if( f.getFaultInfo().getFaultCode() == ImexCentralClient.NO_RECORD ) { ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.no_record, publication, null, null, null, "query returned no records : " + e.getMessage()); imexCentralManager.fireOnImexError(errorEvt); else if( f.getFaultInfo().getFaultCode() == ImexCentralClient.NO_RECORD_CREATED ) { ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.no_record_created, publication, null, null, null, "requested records were not created : " + e.getMessage()); imexCentralManager.fireOnImexError(errorEvt); else if( f.getFaultInfo().getFaultCode() == ImexCentralClient.STATUS_UNKNOWN ) { ImexErrorEvent errorEvt = new ImexErrorEvent(this, ImexErrorType.status_unknown, publication, null, null, null, "unknown status : " + e.getMessage()); imexCentralManager.fireOnImexError(errorEvt); else if( f.getFaultInfo().getFaultCode() == ImexCentralClient.NO_IMEX_ID ) {
public psidev.psi.mi.jami.model.Publication updatePublicationAdminGroup( String identifier, String source, Operation operation, String group ) throws BridgeFailedException { psidev.psi.mi.jami.model.Publication p = fetchByIdentifier(identifier, source); if (p != null && p instanceof ImexPublication){ if (group != null && (group.equalsIgnoreCase(INTACT_GROUP) || group.equalsIgnoreCase(MATRIXDB_GROUP))){ ((ImexPublication) p).getSources().add(new DefaultSource(group)); } // group not recognized, throw exception as in the real webservice else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(11); IcentralFault fault = new IcentralFault("Group not recognized", imexFault); throw new BridgeFailedException(fault); } } else if (p != null){ p.setSource(new DefaultSource(group)); } else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6); IcentralFault fault = new IcentralFault("No publication record found", imexFault); throw new BridgeFailedException(fault); } return p; }
public List<psidev.psi.mi.jami.model.Publication> fetchPublicationsByOwner(String owner, int first, int max) throws BridgeFailedException { try { // create holders for publication and last record Holder<PublicationList> pubList = new Holder<PublicationList>(); Holder<Long> number = new Holder<Long>(); port.getPublicationByOwner( owner, first, max, pubList, number ); if( pubList.value != null) { List<Publication> pubs = pubList.value.getPublication(); List<psidev.psi.mi.jami.model.Publication> publications = new ArrayList<psidev.psi.mi.jami.model.Publication>(pubs.size()); for (Publication pub : pubs){ if (pub != null){ publications.add(new ImexPublication(pub)); } } return publications; } return Collections.EMPTY_LIST; } catch ( IcentralFault f ) { switch( f.getFaultInfo().getFaultCode() ) { case NO_RECORD: // simply no data found, return empty list return Collections.EMPTY_LIST; } throw new BridgeFailedException( "Error while getting publications by owner: " + owner, f ); } }
public Publication updatePublicationAdminGroup( String identifier, Operation operation, String group ) throws ImexCentralException { Publication p = getPublicationById( identifier ); if (p != null){ if (group != null && (group.equalsIgnoreCase(INTACT_GROUP) || group.equalsIgnoreCase(MATRIXDB_GROUP))){ if (p.getAdminGroupList() == null){ p.setAdminGroupList(new Publication.AdminGroupList()); } p.getAdminGroupList().getGroup().add(group.toUpperCase()); } // group not recognized, throw exception as in the real webservice else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(11); IcentralFault fault = new IcentralFault("Group not recognized", imexFault); throw new ImexCentralException(fault); } } else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6); IcentralFault fault = new IcentralFault("No publication record found", imexFault); throw new ImexCentralException(fault); } return p; }
public List<psidev.psi.mi.jami.model.Publication> fetchPublicationsByStatus(String status, int first, int max) throws BridgeFailedException { try { // create holders for publication and last record Holder<PublicationList> pubList = new Holder<PublicationList>(); Holder<Long> number = new Holder<Long>(); port.getPublicationByStatus( status, first, max, pubList, number ); if( pubList.value != null) { List<Publication> pubs = pubList.value.getPublication(); List<psidev.psi.mi.jami.model.Publication> publications = new ArrayList<psidev.psi.mi.jami.model.Publication>(pubs.size()); for (Publication pub : pubs){ if (pub != null){ publications.add(new ImexPublication(pub)); } } return publications; } return Collections.EMPTY_LIST; } catch ( IcentralFault f ) { switch( f.getFaultInfo().getFaultCode() ) { case NO_RECORD: // simply no data found, return empty list return Collections.EMPTY_LIST; } throw new BridgeFailedException( "Error while getting publications by status: " + status, f ); } }
public Publication updatePublicationAdminUser( String identifier, Operation operation, String user ) throws ImexCentralException { Publication p = getPublicationById( identifier ); if (p != null){ if (user != null && (user.equalsIgnoreCase(intact_user) || user.equalsIgnoreCase(phantom_user))){ if (p.getAdminUserList() == null){ p.setAdminUserList(new Publication.AdminUserList()); } p.getAdminUserList().getUser().add(user.toLowerCase()); } // user not recognized, throw exception as in the real webservice else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(10); IcentralFault fault = new IcentralFault("User not recognized", imexFault); throw new ImexCentralException(fault); } } else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6); IcentralFault fault = new IcentralFault("No publication record found", imexFault); throw new ImexCentralException(fault); } return p; }
/** * * @param identifier * @return the publication or null if not found. * @throws ImexCentralException */ public Publication getPublicationById( String identifier ) throws ImexCentralException { try { final Publication pub = port.getPublicationById(buildIdentifier(identifier)); return pub; } catch ( IcentralFault f ) { switch( f.getFaultInfo().getFaultCode() ) { case NO_RECORD: // simply no data found, return null return null; } throw new ImexCentralException("Impossible to find the publication " + identifier, f); } }
public Publication updatePublicationStatus( String identifier, PublicationStatus status) throws ImexCentralException { final Publication p = getPublicationById( identifier ); if (!status.toString().equals("NEW") && !status.toString().equals("DISCARDED") && !status.toString().equals("RESERVED") && !status.toString().equals("PROCESSED") && !status.toString().equals("RELEASED") && !status.toString().equals("INPROGRESS") && !status.toString().equals("INCOMPLETE")){ ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(8); IcentralFault fault = new IcentralFault("Status not recognized", imexFault); throw new ImexCentralException(fault); } if( p != null ) { p.setStatus( status.toString() ); } else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6); IcentralFault fault = new IcentralFault("No publication record found", imexFault); throw new ImexCentralException(fault); } return p; }
} catch ( BridgeFailedException e ) { IcentralFault f = (IcentralFault) e.getCause(); if( f.getFaultInfo().getFaultCode() == ImexCentralClient.UNKNOWN_GROUP ) { else if (f.getFaultInfo().getFaultCode() != ImexCentralClient.OPERATION_NOT_VALID) { throw e; if( f.getFaultInfo().getFaultCode() == ImexCentralClient.UNKNOWN_GROUP || f.getFaultInfo().getFaultCode() == ImexCentralClient.OPERATION_NOT_VALID ) { if (f.getFaultInfo().getFaultCode() == ImexCentralClient.UNKNOWN_GROUP){ log.warn("The institution " + institution + " is not recognized in IMEx central so we will add INTACT admin group."); } catch ( BridgeFailedException e2 ) { IcentralFault f2 = (IcentralFault) e2.getCause(); if( f2.getFaultInfo().getFaultCode() == ImexCentralClient.UNKNOWN_GROUP) { else if (f2.getFaultInfo().getFaultCode() != ImexCentralClient.OPERATION_NOT_VALID){ throw e; } catch ( BridgeFailedException e ) { IcentralFault f = (IcentralFault) e.getCause(); if( f.getFaultInfo().getFaultCode() == ImexCentralClient.UNKNOWN_GROUP ) { else if (f.getFaultInfo().getFaultCode() != ImexCentralClient.OPERATION_NOT_VALID) { throw e;
public Publication getPublicationImexAccession( String identifier, boolean create ) throws ImexCentralException { final Publication p = getPublicationById( identifier ); if (p != null){ if( create ) { if( p.getImexAccession() != null && !p.getImexAccession().equals("N/A")) { throw new IllegalStateException( "Publication already has an IMEx id: " + p.getImexAccession() ); } // assigning new IMEx ID p.setImexAccession( "IM-" + imexIdSequence ); imexIdSequence++; } } else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6); IcentralFault fault = new IcentralFault("No publication record found", imexFault); throw new ImexCentralException(fault); } return p; }
public List<Publication> getPublicationByOwner( String owner, int first, int max) throws ImexCentralException { try { // create holders for publication and last record Holder<PublicationList> pubList = new Holder<PublicationList>(); Holder<Long> number = new Holder<Long>(); port.getPublicationByOwner( owner, first, max, pubList, number ); if( pubList.value != null) { return pubList.value.getPublication(); } return Collections.EMPTY_LIST; } catch ( IcentralFault f ) { switch( f.getFaultInfo().getFaultCode() ) { case NO_RECORD: // simply no data found, return empty list return Collections.EMPTY_LIST; } throw new ImexCentralException( "Error while getting publications by owner: " + owner, f ); } }
public psidev.psi.mi.jami.model.Publication fetchPublicationImexAccession( String identifier, String source, boolean create ) throws BridgeFailedException { final psidev.psi.mi.jami.model.Publication p = fetchByIdentifier(identifier, source); if (p != null){ if( create ) { if( p.getImexId() != null) { throw new IllegalStateException( "Publication already has an IMEx id: " + p.getImexId() ); } // assigning new IMEx ID p.assignImexId("IM-" + imexIdSequence); imexIdSequence++; } } else { ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6); IcentralFault fault = new IcentralFault("No publication record found", imexFault); throw new BridgeFailedException(fault); } return p; } }
public List<Publication> getPublicationByStatus( String status, int first, int max) throws ImexCentralException { try { // create holders for publication and last record Holder<PublicationList> pubList = new Holder<PublicationList>(); Holder<Long> number = new Holder<Long>(); port.getPublicationByStatus( status, first, max, pubList, number ); if( pubList.value != null) { return pubList.value.getPublication(); } return Collections.EMPTY_LIST; } catch ( IcentralFault f ) { switch( f.getFaultInfo().getFaultCode() ) { case NO_RECORD: // simply no data found, return empty list return Collections.EMPTY_LIST; } throw new ImexCentralException( "Error while getting publications by status: " + status, f ); } }
ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(3); ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(6);
if( f.getFaultInfo().getFaultCode() == ImexCentralClient.UNKNOWN_USER && !containsAdminUser(adminUserList, PHANTOM_CURATOR)) {
@Override public Publication updatePublicationIdentifier(String oldIdentifier, String newIdentifier) throws ImexCentralException { Publication existingPub = getPublicationById(newIdentifier); // if the new identifier is already in IMEx central, we don't update anything if (existingPub != null){ ImexCentralFault imexFault = new ImexCentralFault(); imexFault.setFaultCode(3); IcentralFault fault = new IcentralFault("New publication identifier " + newIdentifier + "already used in IMEx central.", imexFault); throw new ImexCentralException( "Impossible to update the identifier of " + oldIdentifier, fault ); } try { return port.updatePublicationIdentifier( buildIdentifier(oldIdentifier ), buildIdentifier(newIdentifier) ); } catch ( IcentralFault f ) { throw new ImexCentralException( "Error while attempting to upate the identifier to '"+ newIdentifier +"' for publication " + oldIdentifier, f ); } }