Project

General

Profile

« Previous | Next » 

Revision 5654

Added by berkley over 13 years ago

implemented crud.delete

View differences:

CrudService.java
886 886
    }
887 887

  
888 888
    /**
889
     * Delete a document.  NOT IMPLEMENTED
889
     * Delete a document. 
890 890
     */
891 891
    public Identifier delete(AuthToken token, Identifier guid)
892 892
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
893
            NotImplemented {
893
            NotImplemented, InvalidRequest {
894 894
        logCrud.info("delete");
895
        throw new NotImplemented("1321", "This method not yet implemented.");
895
        
896
        if(token == null || token.getToken().equals("publid"))
897
        {
898
            throw new NotAuthorized("1320", "You must be logged in to delete records.");
899
        }
900
        
901
        if(guid == null || guid.getValue().trim().equals(""))
902
        {
903
            throw new InvalidRequest("1322", "No GUID specified in CrudService.delete()");
904
        }
905
        final SessionData sessionData = getSessionData(token);
906
        IdentifierManager manager = IdentifierManager.getInstance();
907
        
908
        String docid;
909
        try
910
        {
911
            docid = manager.getLocalId(guid.getValue());
912
        }
913
        catch(McdbDocNotFoundException mnfe)
914
        {
915
            throw new InvalidRequest("1322", "GUID " + guid + " not found.");
916
        }
917
        
918
        try
919
        {
920
            DocumentImpl.delete(docid, sessionData.getUserName(), sessionData.getGroupNames(), null);
921
        }
922
        catch(Exception e)
923
        {
924
            throw new ServiceFailure("1350", "Could not delete document: " + e.getMessage());
925
        }
926
        
927
        return guid;
896 928
    }
897 929

  
898 930
    /**

Also available in: Unified diff