Skip to content

Commit

Permalink
Merge pull request Azure#10 from gcheng/AssetCRUD
Browse files Browse the repository at this point in the history
Asset CRUD initial commit
  • Loading branch information
Albert Cheng committed Sep 21, 2012
2 parents b7c1e8a + b6d1652 commit 7818021
Show file tree
Hide file tree
Showing 10 changed files with 515 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class Exports implements Builder.Exports {

/**
* register the OAUTH service.
* register the Media services.
*/
@Override
public void register(Builder.Registry registry) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2011 Microsoft Corporation
* 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.
Expand All @@ -14,15 +14,96 @@
*/
package com.microsoft.windowsazure.services.media;

import java.util.List;

import com.microsoft.windowsazure.services.core.FilterableService;
import com.microsoft.windowsazure.services.media.models.AssetInfo;
import com.microsoft.windowsazure.services.media.models.CreateAssetOptions;
import com.microsoft.windowsazure.services.media.models.ListAssetsOptions;

// TODO: Auto-generated Javadoc
/**
*
* Defines the methods available for Windows Azure Media Services
*
* Defines the methods available for Windows Azure Media Services.
*/
public interface MediaContract extends FilterableService<MediaContract> {

// Will fill in as we implement the various Media Services entities
/**
* Creates the asset.
*
* @param asset
* the asset
* @return the asset info
*/
public AssetInfo createAsset(AssetInfo asset);

/**
* List assets.
*
* @param listAssetsOptions
* the list assets options
* @return the list
*/
public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions);

/**
* Update asset.
*
* @param updatedAsset
* the updated asset
* @return the asset info
*/
public AssetInfo updateAsset(AssetInfo updatedAsset);

/**
* Delete asset.
*
* @param assetId
* the asset id
*/
public void deleteAsset(String assetId);

/**
* Creates the asset.
*
* @param assetName
* the asset name
* @return the asset info
*/
public AssetInfo createAsset(String assetName);

/**
* Creates the asset.
*
* @param assetName
* the asset name
* @param createAssetOptions
* the create asset options
* @return the asset info
*/
public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions);

/**
* Gets the asset.
*
* @param assetId
* the asset id
* @return the asset
*/
public AssetInfo getAsset(String assetId);

/**
* List assets.
*
* @return the list
*/
public List<AssetInfo> listAssets();

/**
* Delete asset.
*
* @param assetInfo
* the asset info
*/
public void deleteAsset(AssetInfo assetInfo);

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

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

import java.util.List;

import javax.inject.Inject;

import org.apache.commons.logging.Log;
Expand All @@ -24,6 +26,9 @@
import com.microsoft.windowsazure.services.core.ServiceFilter;
import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory;
import com.microsoft.windowsazure.services.media.MediaContract;
import com.microsoft.windowsazure.services.media.models.AssetInfo;
import com.microsoft.windowsazure.services.media.models.CreateAssetOptions;
import com.microsoft.windowsazure.services.media.models.ListAssetsOptions;

/**
* Wrapper implementation of <code>MediaServicesContract</code> that
Expand All @@ -32,26 +37,71 @@
*/
public class MediaExceptionProcessor implements MediaContract {

private final MediaContract next;
private final MediaContract service;
static Log log = LogFactory.getLog(MediaContract.class);

public MediaExceptionProcessor(MediaContract next) {
this.next = next;
public MediaExceptionProcessor(MediaContract service) {
this.service = service;
}

@Inject
public MediaExceptionProcessor(MediaRestProxy next) {
this.next = next;
public MediaExceptionProcessor(MediaRestProxy service) {
this.service = service;
}

@Override
public MediaContract withFilter(ServiceFilter filter) {
return new MediaExceptionProcessor(next.withFilter(filter));
return new MediaExceptionProcessor(service.withFilter(filter));
}

private ServiceException processCatch(ServiceException e) {
log.warn(e.getMessage(), e.getCause());
return ServiceExceptionFactory.process("MediaServices", e);
}

@Override
public void deleteAsset(String assetId) {
service.deleteAsset(assetId);
}

@Override
public AssetInfo createAsset(AssetInfo asset) {
return service.createAsset(asset);
}

@Override
public AssetInfo updateAsset(AssetInfo updatedAsset) {
return service.updateAsset(updatedAsset);
}

@Override
public AssetInfo createAsset(String assetName) {
return service.createAsset(assetName);
}

@Override
public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) {
return service.createAsset(assetName, createAssetOptions);
}

@Override
public AssetInfo getAsset(String assetId) {
return service.getAsset(assetId);
}

@Override
public List<AssetInfo> listAssets() {
return service.listAssets();
}

@Override
public void deleteAsset(AssetInfo assetInfo) {
service.deleteAsset(assetInfo);
}

@Override
public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) {
return service.listAssets(listAssetsOptions);
}

}
Loading

0 comments on commit 7818021

Please sign in to comment.