private String subjectAsURI(String subj) { // already a uri? if (subj.startsWith(Constants.FEDORA.uri)) { return subj; } // no, convert to uri return PID.toURI(subj); }
static String getSubjectAsUri(String subject) { // if we weren't given a pid, assume it's a URI if (!isPid(subject)) { return subject; } // otherwise return URI from the pid logger.warn("Relationships API methods: the 'pid' (" + subject + ") form of a relationship's subject is deprecated. Please specify the subject using the " + Constants.FEDORA.uri + " uri scheme."); return PID.toURI(subject); }
static String getSubjectAsUri(String subject) { // if we weren't given a pid, assume it's a URI if (!isPid(subject)) { return subject; } // otherwise return URI from the pid logger.warn("Relationships API methods: the 'pid' (" + subject + ") form of a relationship's subject is deprecated. Please specify the subject using the " + Constants.FEDORA.uri + " uri scheme."); return PID.toURI(subject); }
/** * Return a URIReference of some PID string, assuming it is well-formed. */ public static SimpleURIReference toURIReference(String pidString) { SimpleURIReference ref = null; try { ref = new SimpleURIReference(new URI(toURI(pidString))); } catch (URISyntaxException e) { // assumes pid is well-formed throw new Error(e); } return ref; }
/** * Return a URIReference of some PID string, assuming it is well-formed. */ public static SimpleURIReference toURIReference(String pidString) { SimpleURIReference ref = null; try { ref = new SimpleURIReference(new URI(toURI(pidString))); } catch (URISyntaxException e) { // assumes pid is well-formed throw new Error(e); } return ref; }
/** * Explicit RELS-EXT relation to collection object * @throws Exception */ @Test public void testRISearchRelsExtCollection() throws Exception { String collectionPid = "demo:SmileyStuff"; for (String pid : SMILEYS) { String query = "<" + PID.toURI(pid) + ">" + " <" + Constants.RELS_EXT.IS_MEMBER_OF.uri + ">" + " <" + PID.toURI(collectionPid) + ">"; RISearchUtil.checkSPOCount(s_client, query, 1); } }
protected String getSubjectURI(String subject) throws MalformedPIDException { String strippedSubject; if (subject.startsWith(Constants.FEDORA.uri)) { strippedSubject = subject.substring(Constants.FEDORA.uri.length()); } else { strippedSubject = subject; } String parts[] = strippedSubject.split("/"); PID pid = new PID(parts[0]); String subjectURI; if (parts.length == 1) { subjectURI = pid.toURI(); } else if (parts.length == 2) { subjectURI = pid.toURI() + "/" + parts[1]; // add datastream } else { logger.warn("Invalid subject argument for getRelationships: " + subject + ". Should be pid or datastream (URI form optional"); subjectURI = null; } return subjectURI; }
private String resolveSubjectToDatastream(String subject) throws ServerException{ String pidURI = PID.toURI(m_obj.getPid()); if (subject.startsWith(pidURI)) { if (subject.length() == pidURI.length()) { return "RELS-EXT"; } if (subject.charAt(pidURI.length()) == '/') { return "RELS-INT"; } } throw new GeneralException("Cannot determine which relationship datastream to update for subject " + subject + ". Relationship subjects must be the URI of the object or the URI of a datastream within the object."); }
private String resolveSubjectToDatastream(String subject) throws ServerException{ String pidURI = PID.toURI(m_obj.getPid()); if (subject.startsWith(pidURI)) { if (subject.length() == pidURI.length()) { return "RELS-EXT"; } if (subject.charAt(pidURI.length()) == '/') { return "RELS-INT"; } } throw new GeneralException("Cannot determine which relationship datastream to update for subject " + subject + ". Relationship subjects must be the URI of the object or the URI of a datastream within the object."); }
/** * RELS-INT relationships specifying image size for jpeg datastreams * @throws Exception */ @Test public void testRISearchRelsInt() throws Exception { for (String pid : SMILEYS) { String query = "<" + PID.toURI(pid) + "/MEDIUM_SIZE" + ">" + " <" + "http://ns.adobe.com/exif/1.0/PixelXDimension" + ">" + " \"320\""; RISearchUtil.checkSPOCount(s_client, query, 1); } }
/** * Implicit relationship to Fedora object CModel * @throws Exception */ @Test public void testRISearchBasicCModel() throws Exception { for (String pid : SMILEYS) { String query = "<" + PID.toURI(pid) + ">" + " <" + Constants.MODEL.HAS_MODEL.uri + ">" + " <" + Models.FEDORA_OBJECT_CURRENT.uri + ">"; RISearchUtil.checkSPOCount(s_client, query, 1); } }
public void validate(PID pid, String dsId, InputStream content) throws ValidationException { try { m_rootRDFFound = false; m_descriptionCount = 0; m_withinDescription = false; m_depth = 0; m_doURI = pid.toURI(); if (!dsId.equals(RELS_EXT) && !dsId.equals(RELS_INT)) { throw new ValidationException("Relationships datastream ID must be RELS-EXT or RELS-INT (" + dsId + ")"); } m_dsId = dsId; XmlTransformUtility.parseWithoutValidating(content, this); } catch (Exception e) { throw new ValidationException(dsId + " validation failed: " + e.getMessage(), e); } }
public void validate(PID pid, String dsId, InputStream content) throws ValidationException { try { m_rootRDFFound = false; m_descriptionCount = 0; m_withinDescription = false; m_depth = 0; m_doURI = pid.toURI(); if (!dsId.equals(RELS_EXT) && !dsId.equals(RELS_INT)) { throw new ValidationException("Relationships datastream ID must be RELS-EXT or RELS-INT (" + dsId + ")"); } m_dsId = dsId; XmlTransformUtility.parseWithoutValidating(content, this); } catch (Exception e) { throw new ValidationException(dsId + " validation failed: " + e.getMessage(), e); } }
/** * {@inheritDoc} */ public Set<Triple> getTriplesForObject(DOReader reader) throws ResourceIndexException { Set<Triple> set = new HashSet<Triple>(); try { URIReference objURI = new SimpleURIReference( new URI(PID.toURI(reader.GetObjectPID()))); /* Now add the SDef operation-specific triples */ addMethodDefTriples(objURI, reader, set); } catch (Exception e) { throw new ResourceIndexException("Could not generate triples", e); } return set; }
/** * {@inheritDoc} */ public Set<Triple> getTriplesForObject(DOReader reader) throws ResourceIndexException { Set<Triple> set = new HashSet<Triple>(); try { URIReference objURI = new SimpleURIReference( new URI(PID.toURI(reader.GetObjectPID()))); /* Now add the SDef operation-specific triples */ addMethodDefTriples(objURI, reader, set); } catch (Exception e) { throw new ResourceIndexException("Could not generate triples", e); } return set; }
/** * Get the RELS-EXT xml for an object. */ public static String getRELSEXT(String pid, String content) { StringBuilder x = new StringBuilder(185 + content.length() + pid.length()); x.append("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"" + " xmlns:foo=\"http://example.org/foo#\">\n" + "<rdf:Description rdf:about=\""); x.append(PID.getInstance(pid).toURI()); x.append("\">\n"); x.append(content); x.append("\n</rdf:Description>\n</rdf:RDF>"); return x.toString(); }
/** * Get the RELS-INT xml for an object. */ public static String getRELSINT(String pid, String content1, String content2) { StringBuilder x = new StringBuilder(); x.append("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"" + " xmlns:foo=\"http://example.org/foo#\">\n" // relationship(s) from datastream DS1 + "<rdf:Description rdf:about=\""); x.append(PID.getInstance(pid).toURI()); x.append("/DS1\">\n"); x.append(content1); x.append("\n</rdf:Description>\n"); // relationship(s) from datastream DS2 x.append("<rdf:Description rdf:about=\"" + PID.getInstance(pid).toURI() + "/DS2" + "\">\n"); x.append(content2); x.append("\n</rdf:Description>\n</rdf:RDF>"); return x.toString(); }
private Feed createAtomObject(String spid, String contentLocation) throws Exception { PID pid = PID.getInstance(spid); Date date = new Date(1); String title = "title"; String author = "org.fcrepo.test.api.TestManagedDatastreams"; Feed feed = abdera.newFeed(); feed.setId(pid.toURI()); feed.setTitle(title); feed.setUpdated(date); feed.addAuthor(author); if (contentLocation != null && contentLocation.length() > 0) { addAtomManagedDatastream(feed, contentLocation); } return feed; }
private void addObjectProperties(DigitalObject obj, Feed feed) throws ObjectIntegrityException { String state = DOTranslationUtility.getStateAttribute(obj); String ownerId = obj.getOwnerId(); String label = obj.getLabel(); Date cdate = obj.getCreateDate(); Date mdate = obj.getLastModDate(); feed.setId(PID.toURI(obj.getPid())); feed.setTitle(label == null ? "" : label); feed.setUpdated(mdate); feed.addAuthor(ownerId == null ? "" : StreamUtility.enc(ownerId)); feed.addCategory(MODEL.STATE.uri, state, null); if (cdate != null) { feed.addCategory(MODEL.CREATED_DATE.uri, DateUtility .convertDateToString(cdate), null); } // TODO not sure I'm satisfied with this representation of extProperties for (String extProp : obj.getExtProperties().keySet()) { feed.addCategory(MODEL.EXT_PROPERTY.uri, extProp, obj .getExtProperty(extProp)); } }
private void addObjectProperties(DigitalObject obj, Feed feed) throws ObjectIntegrityException { String state = DOTranslationUtility.getStateAttribute(obj); String ownerId = obj.getOwnerId(); String label = obj.getLabel(); Date cdate = obj.getCreateDate(); Date mdate = obj.getLastModDate(); feed.setId(PID.toURI(obj.getPid())); feed.setTitle(label == null ? "" : label); feed.setUpdated(mdate); feed.addAuthor(ownerId == null ? "" : StreamUtility.enc(ownerId)); feed.addCategory(MODEL.STATE.uri, state, null); if (cdate != null) { feed.addCategory(MODEL.CREATED_DATE.uri, DateUtility .convertDateToString(cdate), null); } // TODO not sure I'm satisfied with this representation of extProperties for (String extProp : obj.getExtProperties().keySet()) { feed.addCategory(MODEL.EXT_PROPERTY.uri, extProp, obj .getExtProperty(extProp)); } }