Skip to content

Commit

Permalink
Merge pull request Azure#48 from gcheng/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Albert Cheng committed Dec 4, 2012
2 parents 04e6b9d + 2c2b23c commit 6687de3
Show file tree
Hide file tree
Showing 17 changed files with 1,459 additions and 461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public ClientConfig create(String profile, Builder builder, Map<String, Object>
public Client create(String profile, Builder builder, Map<String, Object> properties) {
ClientConfig clientConfig = builder.build(profile, ClientConfig.class, properties);
Client client = Client.create(clientConfig);
// client.addFilter(new LoggingFilter());
return client;
}
});
Expand All @@ -82,7 +83,7 @@ public Client create(String profile, Builder builder, Map<String, Object> proper
public HttpURLConnectionClient create(String profile, Builder builder, Map<String, Object> properties) {
ClientConfig clientConfig = builder.build(profile, ClientConfig.class, properties);
HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig);
//client.addFilter(new LoggingFilter());
// client.addFilter(new LoggingFilter());
return client;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.microsoft.windowsazure.services.media.implementation.atom.EntryType;
import com.microsoft.windowsazure.services.media.implementation.atom.FeedType;
import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType;
import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType;
import com.microsoft.windowsazure.services.media.implementation.content.AssetType;
import com.microsoft.windowsazure.services.media.implementation.content.Constants;
import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType;
Expand Down Expand Up @@ -131,6 +132,7 @@ private static Class<?>[] getMarshalledClasses() {
classes.add(LocatorRestType.class);
classes.add(TaskType.class);
classes.add(ContentKeyRestType.class);
classes.add(AssetFileType.class);
return classes.toArray(new Class<?>[0]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright 2012 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.microsoft.windowsazure.services.media.implementation;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import java.util.regex.Pattern;

import javax.xml.bind.DatatypeConverter;
import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
* Adapter to convert OData time zone conventions into Java
* Dates and back.
*
*/
public class ODataDateAdapter extends XmlAdapter<String, Date> {

private final static Pattern hasTimezoneRegex;
private final static TimeZone utc;

static {
hasTimezoneRegex = Pattern.compile("^.*(\\+|-)\\d\\d:\\d\\d$");

utc = TimeZone.getDefault();
utc.setRawOffset(0);
}

@Override
public Date unmarshal(String dateString) throws Exception {
if (!hasTimezone(dateString)) {
dateString += "Z";
}
Calendar parsedDate = DatatypeConverter.parseDateTime(dateString);
return parsedDate.getTime();
}

@Override
public String marshal(Date date) throws Exception {
Calendar dateToMarshal = Calendar.getInstance();
dateToMarshal.setTime(date);
dateToMarshal.setTimeZone(utc);
return DatatypeConverter.printDateTime(dateToMarshal);
}

private boolean hasTimezone(String dateString) {
return dateString.endsWith("Z") || hasTimezoneRegex.matcher(dateString).matches();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
/**
* Copyright 2012 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.microsoft.windowsazure.services.media.implementation.content;

import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

/**
* Serialization for the AssetFile entity
*
*/

@XmlAccessorType(XmlAccessType.FIELD)
public class AssetFileType implements MediaServiceDTO {

@XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS)
protected String id;

@XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS)
protected String name;

@XmlElement(name = "ContentFileSize", namespace = Constants.ODATA_DATA_NS)
protected Long contentFileSize;

@XmlElement(name = "ParentAssetId", namespace = Constants.ODATA_DATA_NS)
protected String parentAssetId;

@XmlElement(name = "EncryptionVersion", namespace = Constants.ODATA_DATA_NS)
protected String encryptionVersion;

@XmlElement(name = "EncryptionScheme", namespace = Constants.ODATA_DATA_NS)
protected String encryptionScheme;

@XmlElement(name = "IsEncrypted", namespace = Constants.ODATA_DATA_NS)
protected Boolean isEncrypted;

@XmlElement(name = "EncryptionKeyId", namespace = Constants.ODATA_DATA_NS)
protected String encryptionKeyId;

@XmlElement(name = "InitializationVector", namespace = Constants.ODATA_DATA_NS)
protected String initializationVector;

@XmlElement(name = "IsPrimary", namespace = Constants.ODATA_DATA_NS)
protected Boolean isPrimary;

@XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS)
protected Date lastModified;

@XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS)
protected Date created;

@XmlElement(name = "MimeType", namespace = Constants.ODATA_DATA_NS)
protected String mimeType;

@XmlElement(name = "ContentChecksum", namespace = Constants.ODATA_DATA_NS)
protected String contentChecksum;

/**
* @return the id
*/
public String getId() {
return id;
}

/**
* @param id
* the id to set
*/
public AssetFileType setId(String id) {
this.id = id;
return this;
}

/**
* @return the name
*/
public String getName() {
return name;
}

/**
* @param name
* the name to set
*/
public AssetFileType setName(String name) {
this.name = name;
return this;
}

/**
* @return the contentFileSize
*/
public Long getContentFileSize() {
return contentFileSize;
}

/**
* @param contentFileSize
* the contentFileSize to set
*/
public AssetFileType setContentFileSize(Long contentFileSize) {
this.contentFileSize = contentFileSize;
return this;
}

/**
* @return the parentAssetId
*/
public String getParentAssetId() {
return parentAssetId;
}

/**
* @param parentAssetId
* the parentAssetId to set
*/
public AssetFileType setParentAssetId(String parentAssetId) {
this.parentAssetId = parentAssetId;
return this;
}

/**
* @return the encryptionVersion
*/
public String getEncryptionVersion() {
return encryptionVersion;
}

/**
* @param encryptionVersion
* the encryptionVersion to set
*/
public AssetFileType setEncryptionVersion(String encryptionVersion) {
this.encryptionVersion = encryptionVersion;
return this;
}

/**
* @return the encryptionScheme
*/
public String getEncryptionScheme() {
return encryptionScheme;
}

/**
* @param encryptionScheme
* the encryptionScheme to set
*/
public AssetFileType setEncryptionScheme(String encryptionScheme) {
this.encryptionScheme = encryptionScheme;
return this;
}

/**
* @return the isEncrypted
*/
public Boolean getIsEncrypted() {
return isEncrypted;
}

/**
* @param isEncrypted
* the isEncrypted to set
*/
public AssetFileType setIsEncrypted(Boolean isEncrypted) {
this.isEncrypted = isEncrypted;
return this;
}

/**
* @return the encryptionKeyId
*/
public String getEncryptionKeyId() {
return encryptionKeyId;
}

/**
* @param encryptionKeyId
* the encryptionKeyId to set
*/
public AssetFileType setEncryptionKeyId(String encryptionKeyId) {
this.encryptionKeyId = encryptionKeyId;
return this;
}

/**
* @return the initializationVector
*/
public String getInitializationVector() {
return initializationVector;
}

/**
* @param initializationVector
* the initializationVector to set
*/
public AssetFileType setInitializationVector(String initializationVector) {
this.initializationVector = initializationVector;
return this;
}

/**
* @return the isPrimary
*/
public Boolean getIsPrimary() {
return isPrimary;
}

/**
* @param isPrimary
* the isPrimary to set
*/
public AssetFileType setIsPrimary(Boolean isPrimary) {
this.isPrimary = isPrimary;
return this;
}

/**
* @return the lastModified
*/
public Date getLastModified() {
return lastModified;
}

/**
* @param lastModified
* the lastModified to set
*/
public AssetFileType setLastModified(Date lastModified) {
this.lastModified = lastModified;
return this;
}

/**
* @return the created
*/
public Date getCreated() {
return created;
}

/**
* @param created
* the created to set
*/
public AssetFileType setCreated(Date created) {
this.created = created;
return this;
}

/**
* @return the mimeType
*/
public String getMimeType() {
return mimeType;
}

/**
* @param mimeType
* the mimeType to set
*/
public AssetFileType setMimeType(String mimeType) {
this.mimeType = mimeType;
return this;
}

/**
* @return the contentChecksum
*/
public String getContentChecksum() {
return contentChecksum;
}

/**
* @param contentChecksum
* the contentChecksum to set
*/
public AssetFileType setContentChecksum(String contentChecksum) {
this.contentChecksum = contentChecksum;
return this;
}
}
Loading

0 comments on commit 6687de3

Please sign in to comment.