Search in sources :

Example 6 with Instance

use of org.collectionspace.chain.csp.schema.Instance in project application by collectionspace.

the class WebReset method initialiseAll.

/*
	 * Vocab and Auth initialization is now done when the Services layer starts up -see JIRA issue DRYD-177
	 */
@Deprecated
private boolean initialiseAll(Storage storage, UIRequest request, String path, boolean modifyResponse) throws UIException {
    StringBuffer responseMessage = new StringBuffer();
    boolean initializationFailed = false;
    boolean initializationUnknown = false;
    try {
        logInitMessage(responseMessage, "Initializing vocab/auth entries...", modifyResponse);
        JSONObject myjs = new JSONObject();
        myjs.put("pageSize", "10");
        myjs.put("pageNum", "0");
        JSONObject data = storage.getPathsJSON("/", null);
        String[] paths = (String[]) data.get("listItems");
        for (String dir : paths) {
            try {
                if (this.spec.hasRecord(dir)) {
                    Record record = this.spec.getRecord(dir);
                    if (record.isType("authority") == true) {
                        for (Instance instance : record.getAllInstances()) {
                            if (instance.getCreateUnreferenced() || isInstanceReferenced(instance)) {
                                avi = new AuthoritiesVocabulariesInitialize(instance, populate, modifyResponse);
                                Option[] allOpts = instance.getAllOptions();
                                boolean creatingTerm = false;
                                try {
                                    if (avi.createIfMissingAuthority(storage, responseMessage, record, instance) == -1) {
                                        log.warn(String.format("The currently authenticated user does not have sufficient permission to determine if the '%s' authority/term-list is properly initialized.", instance.getID()));
                                        // since the logged in user doesn't have the correct perms, we can't verify that the authorities and term lists have been properly initialized
                                        initializationUnknown = true;
                                    } else {
                                        // 
                                        // Create the missing items.
                                        // 
                                        creatingTerm = true;
                                        avi.fillVocab(storage, record, instance, responseMessage, allOpts, true);
                                    }
                                } catch (UnderlyingStorageException e) {
                                    if (e.getStatus() == HttpStatus.SC_CONFLICT) {
                                        // This means the authority/vocabulary instance already exists in the backend, so move on to the next instance.
                                        log.warn(String.format("A short ID for the authority/vocabulary instance '%s' already exists.", instance.getID()));
                                        // Not a fatal error.
                                        continue;
                                    } else {
                                        throw e;
                                    }
                                } catch (Exception e) {
                                    if (avi.success() == false) {
                                        initializationFailed = true;
                                    }
                                    throw e;
                                }
                            } else {
                                logInitMessage(responseMessage, "Instance " + instance.getID() + " is defined by not referenced.", modifyResponse);
                            }
                        }
                    }
                }
            } catch (UnderlyingStorageException e) {
                // 
                if (e.getCause() instanceof ConnectionException) {
                    if (initializationFailed == true) {
                        modifyResponse = true;
                        if (e.getStatus() == HttpStatus.SC_UNAUTHORIZED || e.getStatus() == HttpStatus.SC_FORBIDDEN) {
                            logInitMessage(responseMessage, "\nSummary:\n\t*** ERROR *** CollectionSpace has not been properly initialized: The CollectionSpace administrator needs to login to the correct tenant and initialize the default term lists and authorities.\n\n", modifyResponse);
                        } else {
                            logInitMessage(responseMessage, "\nSummary:\n\t*** ERROR *** CollectionSpace has not been properly initialized: Ask the CollectionSpace administrator to login to the correct tenant and initialize the default term lists and authorities.\n\n", modifyResponse);
                        }
                    } else if (initializationUnknown == true) {
                        log.warn("The currently logged in user does not have the correct permissions to determin whether or not the default authorities and term lists have been properly initialized.");
                    } else {
                        // Should never get here unless we've got a bug in our code
                        throw e;
                    }
                }
                logException(e, responseMessage, modifyResponse);
                // no need to continue if the user hasn't authenticated or has incorrect permissions
                break;
            }
        }
    } catch (ExistException e) {
        logInitMessage(responseMessage, "ExistException " + e.getLocalizedMessage(), modifyResponse);
        throw new UIException("Existence problem", e);
    } catch (UnimplementedException e) {
        logInitMessage(responseMessage, "UnimplementedException " + e.getLocalizedMessage(), modifyResponse);
        throw new UIException("Unimplemented ", e);
    } catch (UnderlyingStorageException x) {
        if (x.getStatus() == HttpStatus.SC_UNAUTHORIZED) {
            initializationFailed = true;
            logInitMessage(responseMessage, "\n*** ERROR *** You need to be logged in to the correct tenant with the proper credentials before attempting to initialize the default term lists and authorities.\n", modifyResponse);
            logException(x, responseMessage, modifyResponse);
        } else {
            logInitMessage(responseMessage, "UnderlyingStorageException " + x.getLocalizedMessage(), modifyResponse);
            throw new UIException("Problem storing:" + x.getLocalizedMessage(), x.getStatus(), x.getUrl(), x);
        }
    } catch (JSONException e) {
        logInitMessage(responseMessage, "JSONException " + e.getLocalizedMessage(), modifyResponse);
        throw new UIException("Invalid JSON", e);
    }
    // 
    if (modifyResponse == true && request != null) {
        TTYOutputter tty = request.getTTYOutputter();
        tty.line(responseMessage.toString());
    }
    // report success if we didn't see a failure
    return !initializationFailed;
}
Also used : Instance(org.collectionspace.chain.csp.schema.Instance) JSONException(org.json.JSONException) AuthoritiesVocabulariesInitialize(org.collectionspace.chain.csp.webui.authorities.AuthoritiesVocabulariesInitialize) UnderlyingStorageException(org.collectionspace.csp.api.persistence.UnderlyingStorageException) ExistException(org.collectionspace.csp.api.persistence.ExistException) UnimplementedException(org.collectionspace.csp.api.persistence.UnimplementedException) JSONException(org.json.JSONException) UIException(org.collectionspace.csp.api.ui.UIException) ExistException(org.collectionspace.csp.api.persistence.ExistException) ConnectionException(org.collectionspace.chain.csp.persistence.services.connection.ConnectionException) IOException(java.io.IOException) UnderlyingStorageException(org.collectionspace.csp.api.persistence.UnderlyingStorageException) ConfigException(org.collectionspace.chain.csp.config.ConfigException) JSONObject(org.json.JSONObject) UIException(org.collectionspace.csp.api.ui.UIException) Record(org.collectionspace.chain.csp.schema.Record) Option(org.collectionspace.chain.csp.schema.Option) TTYOutputter(org.collectionspace.csp.api.ui.TTYOutputter) UnimplementedException(org.collectionspace.csp.api.persistence.UnimplementedException) ConnectionException(org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)

Example 7 with Instance

use of org.collectionspace.chain.csp.schema.Instance in project application by collectionspace.

the class CacheTermList method controlledLists.

public JSONArray controlledLists(Storage storage, String vocabname, Record vr, Integer limit) throws JSONException {
    JSONArray displayNames = new JSONArray();
    try {
        // Get List
        int resultsize = 1;
        int pagenum = 0;
        int pagesize = 200;
        if (limit != 0 && limit < pagesize) {
            pagesize = limit;
        }
        while (resultsize > 0) {
            JSONObject restriction = new JSONObject();
            restriction.put("pageNum", pagenum);
            restriction.put("pageSize", pagesize);
            String url = vr.getID() + "/" + vocabname;
            JSONObject data = null;
            try {
                data = storage.getPathsJSON(url, restriction);
            } catch (UnderlyingStorageException e) {
                // need to initialise this vocab
                log.error("Could not retreive term list with URL '%s' from Services layer.", url);
                // REM 8/28/2015 - This code is broken? See https://issues.collectionspace.org/browse/CSPACE-6151
                Instance n = vr.getInstance(vr.getID() + "-" + vocabname);
                JSONObject fields = new JSONObject("{'displayName':'" + n.getTitle() + "','shortIdentifier':'" + n.getWebURL() + "'}");
                if (vr.getFieldFullList("termStatus") instanceof Field) {
                    fields.put("termStatus", ((Field) vr.getFieldFullList("termStatus")).getOptionDefault());
                }
                storage.autocreateJSON(vr.getID(), fields, restriction);
                data = storage.getPathsJSON(url, restriction);
            }
            if (data.has("listItems")) {
                String[] results = (String[]) data.get("listItems");
                /* Get a view of each */
                for (String result : results) {
                    // change csid into displayName
                    JSONObject namedata = getDisplayNameList(storage, vr.getID(), vocabname, result);
                    displayNames.put(namedata);
                }
                Integer total = data.getJSONObject("pagination").getInt("totalItems");
                pagesize = data.getJSONObject("pagination").getInt("pageSize");
                // Integer itemsInPage = data.getJSONObject("pagination").getInt("itemsInPage");
                pagenum = data.getJSONObject("pagination").getInt("pageNum");
                pagenum++;
                // are there more results
                if (total <= (pagesize * (pagenum))) {
                    break;
                }
                // have we got enough results?
                if (limit != 0 && limit <= (pagesize * (pagenum))) {
                    break;
                }
            } else {
                resultsize = 0;
            }
        }
    } catch (ExistException e) {
        throw new JSONException("Exist exception");
    } catch (UnimplementedException e) {
        throw new JSONException("Unimplemented exception");
    } catch (UnderlyingStorageException e) {
        throw new JSONException("Underlying storage exception" + vocabname + e);
    }
    return displayNames;
}
Also used : Field(org.collectionspace.chain.csp.schema.Field) JSONObject(org.json.JSONObject) Instance(org.collectionspace.chain.csp.schema.Instance) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) UnderlyingStorageException(org.collectionspace.csp.api.persistence.UnderlyingStorageException) ExistException(org.collectionspace.csp.api.persistence.ExistException) UnimplementedException(org.collectionspace.csp.api.persistence.UnimplementedException)

Example 8 with Instance

use of org.collectionspace.chain.csp.schema.Instance in project application by collectionspace.

the class DataGenerator method getAuthdata.

/**
 * Return appropriate authority for the field in question
 * @param f
 * @param context
 * @return
 * @throws JSONException
 */
private JSONObject getAuthdata(FieldSet fs, UISpecRunContext context) throws JSONException {
    JSONObject dataitem = new JSONObject();
    JSONObject allnames = new JSONObject();
    Integer i = 0;
    if (fs instanceof Field) {
        for (Instance type : ((Field) fs).getAllAutocompleteInstances()) {
            String iid = type.getTitleRef();
            Record ir = type.getRecord();
            JSONArray thesenames = ctl.get(this.storage, iid, ir, authoritylimit);
            log.info("getting authority: " + type.getID() + ":" + type.getRecord());
            try {
                tty.line("getting authority: " + type.getID() + ":" + type.getRecord());
            } catch (UIException e) {
            }
            allnames.put(i.toString(), thesenames);
            i++;
        }
    }
    Random objrandom = new Random();
    Integer pickobj = objrandom.nextInt(allnames.length());
    JSONArray getallnames = allnames.getJSONArray(pickobj.toString());
    // use random number to choose which item to use
    Random arrayrandom = new Random();
    if (getallnames.length() > 0) {
        int pick = arrayrandom.nextInt(getallnames.length());
        dataitem = getallnames.getJSONObject(pick);
    }
    return dataitem;
}
Also used : Field(org.collectionspace.chain.csp.schema.Field) JSONObject(org.json.JSONObject) Random(java.util.Random) Instance(org.collectionspace.chain.csp.schema.Instance) JSONArray(org.json.JSONArray) UIException(org.collectionspace.csp.api.ui.UIException) Record(org.collectionspace.chain.csp.schema.Record)

Example 9 with Instance

use of org.collectionspace.chain.csp.schema.Instance in project application by collectionspace.

the class VocabInstanceCache method getVocabularyId.

String getVocabularyId(CSPRequestCredentials creds, CSPRequestCache cache, String id) throws ConnectionException, UnderlyingStorageException, ExistException {
    // must allow for the dynamic creation of instances when the system is working
    vocabs = new ConcurrentHashMap<String, String>();
    for (Instance n : r.getAllInstances()) {
        vocabs.put(n.getTitleRef(), n.getTitle());
    }
    if (csids.containsKey(id))
        return csids.get(id);
    synchronized (getClass()) {
        buildVocabularies(creds, cache);
        if (csids.containsKey(id))
            return csids.get(id);
        createVocabulary(creds, cache, id);
        if (csids.containsKey(id))
            return csids.get(id);
        throw new UnderlyingStorageException("Bad vocabulary " + id);
    }
}
Also used : Instance(org.collectionspace.chain.csp.schema.Instance) UnderlyingStorageException(org.collectionspace.csp.api.persistence.UnderlyingStorageException)

Example 10 with Instance

use of org.collectionspace.chain.csp.schema.Instance in project application by collectionspace.

the class WebUI method configure_finish.

private void configure_finish(Spec spec) {
    final String MEDIA_RECORD_ID = "media";
    for (Operation op : Operation.values()) tries.put(op, new Trie());
    // Operation.CREATE/UPDATE = method= POST
    // Operation.READ = method= GET
    addMethod(Operation.READ, new String[] { "login" }, 0, new WebLogin(this, spec));
    addMethod(Operation.CREATE, new String[] { "login" }, 0, new WebLogin(this, spec));
    addMethod(Operation.CREATE, new String[] { "uploads" }, 0, new BlobCreateUpdate(spec.getRecord("blobs"), true));
    addMethod(Operation.READ, new String[] { "uploads" }, 0, new BlobCreateUpdate(spec.getRecord("blobs"), true));
    addMethod(Operation.READ, new String[] { "download" }, 1, new BlobRead());
    addMethod(Operation.READ, new String[] { "logout" }, 0, new WebLogout());
    addMethod(Operation.READ, new String[] { "loginstatus" }, 0, new WebLoginStatus(spec));
    addMethod(Operation.READ, new String[] { "authorities", "initialise" }, 0, new WebReset(false, false));
    addMethod(Operation.READ, new String[] { "reset" }, 0, new WebReset(false, true));
    addMethod(Operation.READ, new String[] { "quick-reset" }, 0, new WebReset(true, true));
    // addMethod(Operation.READ,new String[]{find_page,"uispec"},0,new
    // FindEditUISpec(spec.getAllRecords()));//removed as I don't think
    // anyone uses it
    addMethod(Operation.CREATE, new String[] { "passwordreset" }, 0, new UserDetailsReset(false, spec));
    addMethod(Operation.CREATE, new String[] { "resetpassword" }, 0, new UserDetailsReset(true, spec));
    addMethod(Operation.READ, new String[] { "adjacentRecords" }, 2, new RecordTraverser(spec));
    addMethod(Operation.READ, new String[] { "parseDate" }, 0, new StructuredDateParser());
    for (Schemas s : spec.getAllSchemas()) {
        addMethod(Operation.READ, new String[] { s.getWebURL(), "uischema" }, 0, new UISchema(spec, s));
    }
    addMethod(Operation.READ, new String[] { "generator" }, 0, new DataGenerator(spec));
    Record mediaR = spec.getRecord(MEDIA_RECORD_ID);
    if (mediaR == null) {
        log.error("No media record configured!!!");
    }
    for (Record r : spec.getAllRecords()) {
        addMethod(Operation.READ, new String[] { r.getWebURL(), "generator" }, 0, new DataGenerator(r, "screen"));
        addMethod(Operation.READ, new String[] { r.getWebURL(), "serviceschema" }, 0, new ServicesXsd(r, "common"));
        addMethod(Operation.READ, new String[] { r.getWebURL(), "uischema" }, 0, new UISchema(r, "screen"));
        addMethod(Operation.READ, new String[] { r.getTabURL(), "uischema" }, 0, new UISchema(r, "tab"));
        addMethod(Operation.READ, new String[] { r.getSearchURL(), "uischema" }, 0, new UISchema(r, "search"));
        addMethod(Operation.READ, new String[] { r.getWebURL(), "uispec" }, 0, new UISpec(r, "screen"));
        addMethod(Operation.READ, new String[] { r.getTabURL(), "uispec" }, 0, new UISpec(r, "tab"));
        addMethod(Operation.READ, new String[] { r.getSearchURL(), "uispec" }, 0, new UISpec(r, "search"));
        addMethod(Operation.READ, new String[] { r.getWebURL(), "termList" }, 1, new WebTermList(r));
        if (r.isType("authority")) {
            // urls like record urls to make life easier for the UI
            // CSPACE-1139
            addMethod(Operation.READ, new String[] { r.getWebURL() }, 0, new AuthoritiesVocabulariesSearchList(r, false));
            addMethod(Operation.READ, new String[] { r.getWebURL(), "search" }, 0, new AuthoritiesVocabulariesSearchList(r, true));
            addMethod(Operation.CREATE, new String[] { r.getWebURL(), "search" }, 0, new AuthoritiesVocabulariesSearchList(r, true));
            addMethod(Operation.READ, new String[] { "authorities", r.getWebURL() }, 0, new AuthoritiesVocabulariesSearchList(r, false));
            addMethod(Operation.READ, new String[] { "authorities", r.getWebURL(), "search" }, 0, new AuthoritiesVocabulariesSearchList(r, true));
            addMethod(Operation.CREATE, new String[] { "authorities", r.getWebURL(), "search" }, 0, new AuthoritiesVocabulariesSearchList(r, true));
            addMethod(Operation.CREATE, new String[] { "authorities", r.getWebURL() }, 0, new VocabulariesCreateUpdate(r, true));
            addMethod(Operation.READ, new String[] { "authorities", r.getWebURL(), "initialize" }, 0, new AuthoritiesVocabulariesInitialize(r, true));
            addMethod(Operation.READ, new String[] { "authorities", r.getWebURL(), "refresh" }, 0, new AuthoritiesVocabulariesInitialize(r, false));
            // We'll search on media related to the CSID tail.
            if (mediaR != null) {
                addMethod(Operation.READ, new String[] { r.getWebURL(), mediaR.getWebURL() }, 1, new RecordSearchList(mediaR, RecordSearchList.MODE_SEARCH_RELATED));
            }
            for (Instance n : r.getAllInstances()) {
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL() }, 0, new AuthoritiesVocabulariesSearchList(n, false));
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL(), "search" }, 0, new AuthoritiesVocabulariesSearchList(n, true));
                addMethod(Operation.CREATE, new String[] { "vocabularies", n.getWebURL(), "search" }, 0, new AuthoritiesVocabulariesSearchList(n, true));
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL(), "initialize" }, 0, new AuthoritiesVocabulariesInitialize(n, true, true));
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL(), "refresh" }, 0, new AuthoritiesVocabulariesInitialize(n, false, true));
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL() }, 1, new VocabulariesRead(n, VocabulariesRead.GET_FULL_INFO));
                addMethod(Operation.READ, new String[] { "vocabularies", "basic", n.getWebURL() }, 1, new VocabulariesRead(n, VocabulariesRead.GET_BASIC_INFO));
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL(), "authorities" }, 1, new VocabulariesRead(n, VocabulariesRead.GET_TERMS_USED_INFO));
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL(), "refobjs" }, 1, new VocabulariesRead(n, VocabulariesRead.GET_REF_OBJS_INFO));
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL(), "autocomplete" }, 0, new WebAutoComplete(spec.getRecord(r.getID())));
                addMethod(Operation.CREATE, new String[] { "vocabularies", n.getWebURL() }, 0, new VocabulariesCreateUpdate(n, true));
                addMethod(Operation.UPDATE, new String[] { "vocabularies", n.getWebURL() }, 1, new VocabulariesCreateUpdate(n, false));
                addMethod(Operation.DELETE, new String[] { "vocabularies", n.getWebURL() }, 0, new VocabulariesDelete(n));
                addMethod(Operation.UPDATE, new String[] { "vocabularies", n.getWebURL(), "workflow" }, 2, new VocabulariesWorkflowTransition(n));
                addMethod(Operation.READ, new String[] { "vocabularies", n.getWebURL(), "source-vocab" }, 1, new VocabRedirector(r));
            }
        } else if (r.isType("record") || r.isType("blob") || r.isType("authorizationdata")) {
            addMethod(Operation.READ, new String[] { r.getWebURL(), "__auto" }, 0, new WebAuto());
            addMethod(Operation.READ, new String[] { r.getWebURL(), "autocomplete" }, 0, new WebAutoComplete(spec.getRecord(r.getID())));
            addMethod(Operation.READ, new String[] { r.getWebURL(), "search" }, 0, new RecordSearchList(r, RecordSearchList.MODE_SEARCH));
            addMethod(Operation.CREATE, new String[] { r.getWebURL(), "search" }, 0, new RecordSearchList(r, RecordSearchList.MODE_SEARCH));
            addMethod(Operation.READ, new String[] { r.getWebURL() }, 0, new RecordSearchList(r, RecordSearchList.MODE_LIST));
            addMethod(Operation.READ, new String[] { r.getWebURL() }, 1, new RecordRead(r));
            addMethod(Operation.READ, new String[] { "basic", r.getWebURL() }, 1, new RecordRead(r, true));
            addMethod(Operation.DELETE, new String[] { r.getWebURL() }, 1, new RecordDelete(r.getID()));
            addMethod(Operation.CREATE, new String[] { r.getWebURL() }, 0, new RecordCreateUpdate(r, true));
            addMethod(Operation.UPDATE, new String[] { r.getWebURL() }, 1, new RecordCreateUpdate(r, false));
            addMethod(Operation.READ, new String[] { r.getWebURL(), "source-vocab" }, 1, new VocabRedirector(r));
            addMethod(Operation.READ, new String[] { r.getWebURL(), "authorities" }, 1, new RecordAuthorities(r));
            // relatable records.
            if ((r.isType("procedure") && !r.isType("vocabulary")) || "collection-object".equals(r.getID())) {
                for (Record r2 : spec.getAllRecords()) {
                    if ((r2.isType("procedure") && !r2.isType("vocabulary")) || "collection-object".equals(r2.getID())) {
                        // We do not actually care about the type of r, but
                        // rather just the CSID tail.
                        // We'll search on r2's related to the CSID tail.
                        addMethod(Operation.READ, new String[] { r.getWebURL(), r2.getWebURL() }, 1, new RecordSearchList(r2, RecordSearchList.MODE_SEARCH_RELATED));
                    } else if (r2.isType("searchall")) {
                        // Allow to ask for all procedures related to this
                        // record. Use SearchAll with a related search.
                        addMethod(Operation.READ, new String[] { r.getWebURL(), "procedures" }, 1, new RecordSearchList(r2, RecordSearchList.MODE_SEARCH_RELATED, "procedure"));
                    }
                }
            }
        } else if (r.isType("userdata")) {
            addMethod(Operation.READ, new String[] { r.getWebURL(), "search" }, 0, new UserDetailsSearchList(r, true));
            addMethod(Operation.READ, new String[] { r.getWebURL() }, 1, new UserDetailsRead(r));
            addMethod(Operation.READ, new String[] { r.getWebURL() }, 0, new UserDetailsSearchList(r, false));
            addMethod(Operation.DELETE, new String[] { r.getWebURL() }, 1, new UserDetailsDelete(r.getID()));
            addMethod(Operation.CREATE, new String[] { r.getWebURL() }, 0, new UserDetailsCreateUpdate(r, true));
            addMethod(Operation.UPDATE, new String[] { r.getWebURL() }, 1, new UserDetailsCreateUpdate(r, false));
            addMethod(Operation.READ, new String[] { r.getWebURL() }, 3, new UserRolesRead(spec.getRecordByWebUrl("userrole")));
            addMethod(Operation.CREATE, new String[] { r.getWebURL() }, 2, new UserRolesCreate(spec.getRecordByWebUrl("userrole")));
            addMethod(Operation.DELETE, new String[] { r.getWebURL() }, 3, new UserRolesDelete(spec.getRecordByWebUrl("userrole").getID()));
        } else if (r.isType("id")) {
            // XXX this isn't right but it does work. NEEDS to have it's own
            // methods rather than piggy backing on RECORD
            addMethod(Operation.READ, new String[] { r.getWebURL(), "__auto" }, 0, new WebAuto());
            addMethod(Operation.READ, new String[] { r.getWebURL(), "autocomplete" }, 0, new WebAutoComplete(spec.getRecord(r.getID())));
            addMethod(Operation.READ, new String[] { r.getWebURL(), "search" }, 0, new RecordSearchList(r, RecordSearchList.MODE_SEARCH));
            addMethod(Operation.READ, new String[] { r.getWebURL() }, 0, new RecordSearchList(r, RecordSearchList.MODE_LIST));
            addMethod(Operation.READ, new String[] { r.getWebURL() }, 1, new RecordRead(r));
            addMethod(Operation.DELETE, new String[] { r.getWebURL() }, 1, new RecordDelete(r.getID()));
            addMethod(Operation.CREATE, new String[] { r.getWebURL() }, 0, new RecordCreateUpdate(r, true));
            addMethod(Operation.UPDATE, new String[] { r.getWebURL() }, 1, new RecordCreateUpdate(r, false));
            addMethod(Operation.READ, new String[] { r.getWebURL(), "source-vocab" }, 1, new VocabRedirector(r));
        } else if (r.isType("searchall")) {
            addMethod(Operation.READ, new String[] { r.getWebURL(), "search" }, 0, new RecordSearchList(r, RecordSearchList.MODE_SEARCH));
        }
    }
    addMethod(Operation.CREATE, new String[] { "relationships" }, 0, new RelateCreateUpdate(true));
    addMethod(Operation.UPDATE, new String[] { "relationships" }, 1, new RelateCreateUpdate(false));
    addMethod(Operation.READ, new String[] { "relationships" }, 1, new RelateRead());
    addMethod(Operation.READ, new String[] { "relationships", "hierarchical" }, 1, new RelateRead("hierarchical"));
    addMethod(Operation.DELETE, new String[] { "relationships" }, 1, new RelateDelete(false));
    addMethod(Operation.DELETE, new String[] { "relationships", "one-way" }, 1, new RelateDelete(true));
    addMethod(Operation.READ, new String[] { "relationships", "search" }, 0, new RelateSearchList(true));
    addMethod(Operation.READ, new String[] { "relationships", "hierarchical", "search" }, 0, new RelateSearchList(true, "hierarchical"));
    addMethod(Operation.READ, new String[] { "relationships", "hierarchical" }, 0, new RelateSearchList(false, "hierarchical"));
    addMethod(Operation.READ, new String[] { "relationships" }, 0, new RelateSearchList(false));
}
Also used : RecordAuthorities(org.collectionspace.chain.csp.webui.record.RecordAuthorities) UserDetailsDelete(org.collectionspace.chain.csp.webui.userdetails.UserDetailsDelete) VocabulariesDelete(org.collectionspace.chain.csp.webui.authorities.VocabulariesDelete) Instance(org.collectionspace.chain.csp.schema.Instance) UserDetailsRead(org.collectionspace.chain.csp.webui.userdetails.UserDetailsRead) RelateRead(org.collectionspace.chain.csp.webui.relate.RelateRead) RecordDelete(org.collectionspace.chain.csp.webui.record.RecordDelete) UserRolesRead(org.collectionspace.chain.csp.webui.userroles.UserRolesRead) Operation(org.collectionspace.csp.api.ui.Operation) RecordCreateUpdate(org.collectionspace.chain.csp.webui.record.RecordCreateUpdate) RelateSearchList(org.collectionspace.chain.csp.webui.relate.RelateSearchList) UserRolesDelete(org.collectionspace.chain.csp.webui.userroles.UserRolesDelete) RecordTraverser(org.collectionspace.chain.csp.webui.misc.RecordTraverser) VocabulariesCreateUpdate(org.collectionspace.chain.csp.webui.authorities.VocabulariesCreateUpdate) BlobRead(org.collectionspace.chain.csp.webui.mediablob.BlobRead) UISpec(org.collectionspace.chain.csp.webui.nuispec.UISpec) WebAuto(org.collectionspace.chain.csp.webui.misc.WebAuto) Record(org.collectionspace.chain.csp.schema.Record) AuthoritiesVocabulariesSearchList(org.collectionspace.chain.csp.webui.authorities.AuthoritiesVocabulariesSearchList) Trie(org.collectionspace.chain.pathtrie.Trie) UserDetailsReset(org.collectionspace.chain.csp.webui.userdetails.UserDetailsReset) VocabulariesRead(org.collectionspace.chain.csp.webui.authorities.VocabulariesRead) UserRolesCreate(org.collectionspace.chain.csp.webui.userroles.UserRolesCreate) RelateCreateUpdate(org.collectionspace.chain.csp.webui.relate.RelateCreateUpdate) StructuredDateParser(org.collectionspace.chain.csp.webui.misc.StructuredDateParser) UISchema(org.collectionspace.chain.csp.webui.nuispec.UISchema) WebLogout(org.collectionspace.chain.csp.webui.misc.WebLogout) WebLogin(org.collectionspace.chain.csp.webui.misc.WebLogin) Schemas(org.collectionspace.chain.csp.schema.Schemas) AuthoritiesVocabulariesInitialize(org.collectionspace.chain.csp.webui.authorities.AuthoritiesVocabulariesInitialize) ServicesXsd(org.collectionspace.chain.csp.webui.nuispec.ServicesXsd) RelateDelete(org.collectionspace.chain.csp.webui.relate.RelateDelete) WebAutoComplete(org.collectionspace.chain.csp.webui.misc.WebAutoComplete) WebReset(org.collectionspace.chain.csp.webui.misc.WebReset) RecordSearchList(org.collectionspace.chain.csp.webui.record.RecordSearchList) VocabRedirector(org.collectionspace.chain.csp.webui.misc.VocabRedirector) UserDetailsCreateUpdate(org.collectionspace.chain.csp.webui.userdetails.UserDetailsCreateUpdate) UserDetailsSearchList(org.collectionspace.chain.csp.webui.userdetails.UserDetailsSearchList) WebLoginStatus(org.collectionspace.chain.csp.webui.misc.WebLoginStatus) DataGenerator(org.collectionspace.chain.csp.webui.nuispec.DataGenerator) WebTermList(org.collectionspace.chain.csp.webui.misc.WebTermList) RecordRead(org.collectionspace.chain.csp.webui.record.RecordRead) BlobCreateUpdate(org.collectionspace.chain.csp.webui.mediablob.BlobCreateUpdate) VocabulariesWorkflowTransition(org.collectionspace.chain.csp.webui.authorities.VocabulariesWorkflowTransition)

Aggregations

Instance (org.collectionspace.chain.csp.schema.Instance)16 JSONObject (org.json.JSONObject)12 Record (org.collectionspace.chain.csp.schema.Record)11 JSONArray (org.json.JSONArray)7 UnderlyingStorageException (org.collectionspace.csp.api.persistence.UnderlyingStorageException)6 UIException (org.collectionspace.csp.api.ui.UIException)6 JSONException (org.json.JSONException)6 Field (org.collectionspace.chain.csp.schema.Field)5 ConfigException (org.collectionspace.chain.csp.config.ConfigException)3 FieldSet (org.collectionspace.chain.csp.schema.FieldSet)3 Option (org.collectionspace.chain.csp.schema.Option)3 ExistException (org.collectionspace.csp.api.persistence.ExistException)3 UnimplementedException (org.collectionspace.csp.api.persistence.UnimplementedException)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ConnectionException (org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)2 Structure (org.collectionspace.chain.csp.schema.Structure)2 AuthoritiesVocabulariesInitialize (org.collectionspace.chain.csp.webui.authorities.AuthoritiesVocabulariesInitialize)2 AuthoritiesVocabulariesSearchList (org.collectionspace.chain.csp.webui.authorities.AuthoritiesVocabulariesSearchList)2 RecordSearchList (org.collectionspace.chain.csp.webui.record.RecordSearchList)2