Project

General

Profile

« Previous | Next » 

Revision 6882

remove method: assertRelation
https://redmine.dataone.org/issues/2158

View differences:

CNResourceHandler.java
119 119
    protected static final String RESOURCE_RESERVE = "reserve";
120 120
    protected static final String RESOURCE_FORMATS = "formats";
121 121
    protected static final String RESOURCE_RESOLVE = "resolve";
122
    protected static final String RESOURCE_ASSERT_RELATION = "assertRelation";
123 122
    protected static final String RESOURCE_OWNER = "owner";
124 123
    protected static final String RESOURCE_REPLICATION_POLICY = "replicaPolicies";
125 124
    protected static final String RESOURCE_REPLICATION_META = "replicaMetadata";
......
191 190
                        reserve();
192 191
                        status = true;
193 192
                    }
194
                } else if (resource.startsWith(RESOURCE_ASSERT_RELATION)) {
195

  
196
                    // after the command
197
                    extra = parseTrailing(resource, RESOURCE_ASSERT_RELATION);
198

  
199
                    // reserve the ID (in params)
200
                    if (httpVerb == GET) {
201
                        assertRelation(extra);
202
                        status = true;
203
                    }
204 193
                } else if (resource.startsWith(RESOURCE_RESOLVE)) {
205 194

  
206 195
                    // after the command
......
835 824
    }
836 825

  
837 826
    /**
838
     * Assert that a relationship exists between two resources
839
     * 
840
     * @param id
841
     * @return
842
     * @throws InvalidToken
843
     * @throws ServiceFailure
844
     * @throws NotAuthorized
845
     * @throws NotFound
846
     * @throws InvalidRequest
847
     * @throws NotImplemented
848
     */
849
    private boolean assertRelation(String id) throws InvalidToken,
850
            ServiceFailure, NotAuthorized, NotFound, InvalidRequest,
851
            NotImplemented {
852
        Identifier pidOfSubject = new Identifier();
853
        pidOfSubject.setValue(id);
854
        String relationship = null;
855
        try {
856
            relationship = params.get("relationship")[0];
857
        } catch (Exception e) {
858
            logMetacat.warn("relationship not specified");
859
        }
860
        Identifier pidOfObject = new Identifier();
861
        try {
862
            String objPid = params.get("pidOfObject")[0];
863
            pidOfObject.setValue(objPid);
864
        } catch (Exception e) {
865
            logMetacat.warn("pidOfObject not specified");
866
        }
867
        boolean result = CNodeService.getInstance(request).assertRelation(
868
                session, pidOfSubject, relationship, pidOfObject);
869
        response.setStatus(200);
870
        response.setContentType("text/xml");
871
        return result;
872
    }
873

  
874
    /**
875 827
     * Set the owner of a resource
876 828
     * 
877 829
     * @param id

Also available in: Unified diff