Пример #1
0
		/// <summary>
		/// Execute the delete request
		/// </summary>
		/// <returns>Ark identifier that was deleted deleted</returns>
		/// <exception cref="System.Net.WebException">Thrown when there is a problem with the HTTP request</exception>
		/// <exception cref="WSULibs.EZID.EZIDApiException">Thrown when the EZID API returns an API level error</exception>
		public string ExecuteRequest()
		{
			if (string.IsNullOrWhiteSpace(this.Identifier))
				throw new InvalidOperationException("Identifier cannot of empty or null");

			if (this.Authentication == null)
				throw new InvalidOperationException("Authentication must not be null");

			var response = new Response(Request.ExecuteRequest(GetRequest.PATH + this.Identifier, RequestMethod.DELETE));

			var map = response.Parse();
			if (response.HasError)
				throw new EZIDApiException(response.StatusCode, map[Response.ResponseStatusKeys.Error]);

			return map[Response.ResponseStatusKeys.Success];
		}
Пример #2
0
		/// <summary>
		/// Execute the modify request
		/// </summary>
		/// <returns>ARK identifier</returns>
		/// <exception cref="System.Net.WebException">Thrown when there is a problem with the HTTP request</exception>
		/// <exception cref="WSULibs.EZID.EZIDApiException">Thrown when the EZID API returns an API level error</exception>
		public string ExecuteRequest()
		{
			if (string.IsNullOrWhiteSpace(this.Identifier))
				throw new InvalidOperationException("Identifier cannot of empty or null");

			if (this.Metadata == null)
				throw new InvalidOperationException("Metadata must not be null");

			if (this.Authentication == null)
				throw new InvalidOperationException("Authentication must not be null");

			var httpResponse = Request.ExecuteRequest(ModifyRequest.PATH + this.Identifier, RequestMethod.POST, authentication: this.Authentication, metadataDictionary: this.Metadata.AsDictionary());
			var response = new Response(httpResponse);

			var map = response.Parse();
			if (response.HasError)
				throw new EZIDApiException(response.StatusCode, map[Response.ResponseStatusKeys.Error]);

			return map[Response.ResponseStatusKeys.Success];
		}