本文整理汇总了Java中org.apache.abdera.i18n.iri.IRI类的典型用法代码示例。如果您正苦于以下问题:Java IRI类的具体用法?Java IRI怎么用?Java IRI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRI类属于org.apache.abdera.i18n.iri包,在下文中一共展示了IRI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDatasetReceipt
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
DepositReceipt createDatasetReceipt(String baseUrl, Dataset dataset) {
logger.fine("baseUrl was: " + baseUrl);
DepositReceipt depositReceipt = new DepositReceipt();
String globalId = dataset.getGlobalId();
String editIri = baseUrl + "/edit/study/" + globalId;
depositReceipt.setEditIRI(new IRI(editIri));
/**
* @todo: should setLocation depend on if an atom entry or a zip file
* was deposited? (This @todo has been carried over from the DVN 3.x
* version.)
*/
depositReceipt.setLocation(new IRI(editIri));
depositReceipt.setEditMediaIRI(new IRI(baseUrl + "/edit-media/study/" + globalId));
depositReceipt.setStatementURI("application/atom+xml;type=feed", baseUrl + "/statement/study/" + globalId);
depositReceipt.addDublinCore("bibliographicCitation", dataset.getLatestVersion().getCitation());
depositReceipt.setSplashUri(dataset.getPersistentURL());
return depositReceipt;
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:19,代码来源:ReceiptGenerator.java
示例2: createDataverseReceipt
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
DepositReceipt createDataverseReceipt(String baseUrl, Dataverse dataverse) {
logger.fine("baseUrl was: " + baseUrl);
DepositReceipt depositReceipt = new DepositReceipt();
String globalId = dataverse.getAlias();
String collectionIri = baseUrl + "/collection/dataverse/" + globalId;
depositReceipt.setSplashUri(collectionIri);
/**
* @todo We have to include an "edit" IRI or else we get
* NullPointerException in getAbderaEntry at
* https://github.com/swordapp/JavaServer2.0/blob/sword2-server-1.0/src/main/java/org/swordapp/server/DepositReceipt.java#L52
*
* Do we want to support a replaceMetadata of dataverses? Probably not.
* Let's do that with the native API.
*
* Typically, we only operate on the "collection" IRI for dataverses, to
* create a dataset.
*/
String editIri = baseUrl + "/edit/dataverse/" + globalId;
depositReceipt.setEditIRI(new IRI(editIri));
return depositReceipt;
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:22,代码来源:ReceiptGenerator.java
示例3: getMediaResourceRepresentation
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
public MediaResource getMediaResourceRepresentation(String editMediaIRI, Map<String, String> accept,
AuthCredentials authCredentials, SwordConfiguration swordConfiguration)
throws SwordError, SwordServerException, SwordAuthException {
LOGGER.info("getMediaResourceRepresentation: {}", editMediaIRI);
final IRI mediaEditIRI = new IRI(editMediaIRI);
final String requestDerivateID = MCRSwordUtil.ParseLinkUtil.MediaEditIRI
.getDerivateFromMediaEditIRI(mediaEditIRI);
final String requestFilePath = MCRSwordUtil.ParseLinkUtil.MediaEditIRI
.getFilePathFromMediaEditIRI(mediaEditIRI);
final String collection = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getCollectionFromMediaEditIRI(mediaEditIRI);
doAuthentication(authCredentials, collection);
checkObject(requestDerivateID);
return getMediaProvider(collection).getMediaResourceRepresentation(requestDerivateID, requestFilePath, accept);
}
示例4: replaceMediaResource
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
public DepositReceipt replaceMediaResource(String editMediaIRI, Deposit deposit, AuthCredentials authCredentials,
SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
LOGGER.info("replaceMediaResource: {}", editMediaIRI);
final IRI mediaEditIRI = new IRI(editMediaIRI);
final String requestDerivateID = MCRSwordUtil.ParseLinkUtil.MediaEditIRI
.getDerivateFromMediaEditIRI(mediaEditIRI);
final String requestFilePath = MCRSwordUtil.ParseLinkUtil.MediaEditIRI
.getFilePathFromMediaEditIRI(mediaEditIRI);
final String collection = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getCollectionFromMediaEditIRI(mediaEditIRI);
doAuthentication(authCredentials, collection);
checkObject(requestDerivateID);
getMediaProvider(collection).replaceMediaResource(requestDerivateID, requestFilePath, deposit);
final MCRObject mcrObject = MCRSwordUtil.getMcrObjectForDerivateID(requestDerivateID);
return MCRSword.getCollection(collection).getMetadataProvider().provideMetadata(mcrObject);
}
示例5: addResource
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
public DepositReceipt addResource(String editMediaIRI, Deposit deposit, AuthCredentials authCredentials,
SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
LOGGER.info("addResource: {}", editMediaIRI);
final IRI mediaEditIRI = new IRI(editMediaIRI);
final String requestDerivateID = MCRSwordUtil.ParseLinkUtil.MediaEditIRI
.getDerivateFromMediaEditIRI(mediaEditIRI);
String requestFilePath = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getFilePathFromMediaEditIRI(mediaEditIRI);
final String collection = MCRSwordUtil.ParseLinkUtil.MediaEditIRI.getCollectionFromMediaEditIRI(mediaEditIRI);
doAuthentication(authCredentials, collection);
checkObject(requestDerivateID);
if (requestFilePath == null) {
requestFilePath = "/";
}
getMediaProvider(collection).addResource(requestDerivateID, requestFilePath, deposit);
final MCRObject mcrObject = MCRSwordUtil.getMcrObjectForDerivateID(requestDerivateID);
return MCRSword.getCollection(collection).getMetadataProvider().provideMetadata(mcrObject);
}
示例6: getEntry
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
@Override
public DepositReceipt getEntry(String editIRI, Map<String, String> map, AuthCredentials authCredentials,
SwordConfiguration swordConfiguration) throws SwordServerException, SwordError, SwordAuthException {
IRI iri = new IRI(editIRI);
String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
LOGGER.info(MessageFormat.format("REQUEST: Get entry {0} from {1} !", objectIdString, collection));
collectionProvider.getAuthHandler().authentication(authCredentials);
MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
if (!MCRMetadataManager.exists(objectId)) {
throwObjectDoesNotExist(objectIdString);
}
MCRBase retrievedMCRBase = MCRMetadataManager.retrieve(objectId);
checkIsObject(retrievedMCRBase);
final Optional<Map<String, String>> accept = Optional.of(map);
return collectionProvider.getContainerHandler().getMetadata(collection,
(MCRObject) retrievedMCRBase, accept);
}
示例7: replaceMetadata
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
@Override
public DepositReceipt replaceMetadata(String editIRI, Deposit deposit, AuthCredentials authCredentials,
SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
IRI iri = new IRI(editIRI);
String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
LOGGER.info(MessageFormat.format("REQUEST: Replace metadata of {0} from {1} !", objectIdString, collection));
collectionProvider.getAuthHandler().authentication(authCredentials);
MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
if (!MCRMetadataManager.exists(objectId)) {
throwObjectDoesNotExist(objectIdString);
}
MCRBase retrievedMCRBase = MCRMetadataManager.retrieve(objectId);
checkIsObject(retrievedMCRBase);
return collectionProvider.getContainerHandler().replaceMetadata((MCRObject) retrievedMCRBase, deposit);
}
示例8: replaceMetadataAndMediaResource
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
@Override
public DepositReceipt replaceMetadataAndMediaResource(String editIRI, Deposit deposit,
AuthCredentials authCredentials, SwordConfiguration swordConfiguration)
throws SwordError, SwordServerException, SwordAuthException {
IRI iri = new IRI(editIRI);
String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
LOGGER.info(MessageFormat.format("REQUEST: Replace metadata and resource of {0} from {1} !", objectIdString,
collection));
collectionProvider.getAuthHandler().authentication(authCredentials);
MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
if (!MCRMetadataManager.exists(objectId)) {
throwObjectDoesNotExist(objectIdString);
}
MCRBase retrievedMCRBase = MCRMetadataManager.retrieve(objectId);
return collectionProvider.getContainerHandler().replaceMetadataAndResources((MCRObject) retrievedMCRBase,
deposit);
}
示例9: addResources
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
@Override
public DepositReceipt addResources(String editIRI, Deposit deposit, AuthCredentials authCredentials,
SwordConfiguration swordConfiguration) throws SwordError, SwordServerException, SwordAuthException {
IRI iri = new IRI(editIRI);
String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
LOGGER.info(MessageFormat.format("REQUEST: add resources {0} from {1} !", objectIdString, collection));
collectionProvider.getAuthHandler().authentication(authCredentials);
MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
if (!MCRMetadataManager.exists(objectId)) {
throwObjectDoesNotExist(objectIdString);
}
MCRBase retrievedMCRBase = MCRMetadataManager.retrieve(objectId);
return collectionProvider.getContainerHandler().addResources((MCRObject) retrievedMCRBase, deposit);
}
示例10: deleteContainer
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
@Override
public void deleteContainer(String editIRI, AuthCredentials authCredentials, SwordConfiguration swordConfiguration)
throws SwordError, SwordServerException, SwordAuthException {
IRI iri = new IRI(editIRI);
String collection = MCRSwordUtil.ParseLinkUtil.EditIRI.getCollectionFromEditIRI(iri);
String objectIdString = MCRSwordUtil.ParseLinkUtil.EditIRI.getObjectFromEditIRI(iri);
final MCRSwordCollectionProvider collectionProvider = MCRSword.getCollection(collection);
LOGGER.info(MessageFormat.format("REQUEST: Delete {0} from {1}", objectIdString, collection));
collectionProvider.getAuthHandler().authentication(authCredentials);
MCRObjectID objectId = MCRObjectID.getInstance(objectIdString);
if (!MCRMetadataManager.exists(objectId)) {
throwObjectDoesNotExist(objectIdString);
}
final MCRBase object = MCRMetadataManager.retrieve(objectId);
checkIsObject(object);
collectionProvider.getContainerHandler().deleteObject((MCRObject) object);
}
示例11: getXFromXIRI
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
private static String getXFromXIRI(IRI editIRI, Integer x, String iri, Pattern iriPattern, boolean required) {
String[] urlParts = editIRI.toString().split(iri);
if (urlParts.length < 2) {
final String message = "Invalid " + iri + " : " + editIRI;
throw new IllegalArgumentException(message);
}
String uriPathAsString = urlParts[1];
Matcher matcher = iriPattern.matcher(uriPathAsString);
if (matcher.matches()) {
if (matcher.groupCount() >= x) {
return matcher.group(x);
} else {
return null;
}
} else {
if (required) {
throw new IllegalArgumentException(
MessageFormat.format("{0} does not match the pattern {1}", uriPathAsString, iriPattern));
} else {
return null;
}
}
}
示例12: getEditMediaIRIStream
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
/**
* Creates a edit link for every derivate of a mcrobject.
*
* @param mcrObjId the mcrobject id as String
* @return returns a Stream which contains links to every derivate.
*/
public static Stream<Link> getEditMediaIRIStream(final String collection, final String mcrObjId)
throws SwordError {
return MCRSword.getCollection(collection).getDerivateIDsofObject(mcrObjId).map(derivateId -> {
final Factory abderaFactory = Abdera.getNewFactory();
final Stream<IRI> editMediaFileIRIStream = getEditMediaFileIRIStream(collection, derivateId);
return Stream
.concat(Stream.of(getEditMediaHrefOfDerivate(collection, derivateId)), editMediaFileIRIStream)
.map(link -> {
final Link newLinkElement = abderaFactory.newLink();
newLinkElement.setHref(link.toString());
newLinkElement.setRel("edit-media");
return newLinkElement;
});
}).flatMap(s -> s);
}
示例13: getEditMediaFileIRIStream
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
/**
* Creates a Stream which contains edit-media-IRIs to all files in a specific derivate derivate.
*
* @param collection the collection in which the derivate is.
* @param derivateId the id of the derivate
* @return a Stream which contains edit-media-IRIs to all files.
*/
private static Stream<IRI> getEditMediaFileIRIStream(final String collection, final String derivateId) {
MCRPath derivateRootPath = MCRPath.getPath(derivateId, "/");
try {
List<IRI> iris = new ArrayList<>();
Files.walkFileTree(derivateRootPath, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException {
String relativePath = derivateRootPath.relativize(file).toString();
final String URI = MessageFormat.format("{0}{1}{2}/{3}/{4}", MCRFrontendUtil.getBaseURL(),
MCRSwordConstants.SWORD2_EDIT_MEDIA_IRI, collection, derivateId,
encodeURLPart(relativePath));
iris.add(new IRI(URI));
return FileVisitResult.CONTINUE;
}
});
return iris.stream();
} catch (IOException e) {
LOGGER.error("Error while processing directory stream of {}", derivateId, e);
throw new MCRException(e);
}
}
示例14: configureBaseMapper
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
private static void configureBaseMapper(ObjectMapper mapper,
boolean includeIdsMappers) {
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.setDateFormat(new ISO8601VerboseDateFormat());
SimpleModule module = new SimpleModule();
JsonSerializer<IRI> iriSerializer = new IRISerializer();
module.addSerializer(IRI.class, iriSerializer);
if (includeIdsMappers) {
module.addSerializer(Agent.class, new AgentIdsSerializer());
module.addSerializer(Group.class, new GroupIdsSerializer());
module.addSerializer(Activity.class, new ActivityIdsSerializer());
}
mapper.registerModule(module);
}
示例15: before
import org.apache.abdera.i18n.iri.IRI; //导入依赖的package包/类
@Before
public void before() {
validAgent = new Agent();
IFI ifi = new IFI();
ifi.setMbox(ValidMbox);
validAgent.setIdentifier(ifi);
validActor = validAgent;
validVerb = new Verb();
validVerb.setId(new IRI("http://uva.nl/verbs/making"));
validActivity = new Activity();
validActivity.setId(new IRI("http://uva.nl/activities/homework"));
validStatementObject = validActivity;
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
}