当前位置: 首页>>代码示例>>Java>>正文


Java ServiceException类代码示例

本文整理汇总了Java中com.microsoft.windowsazure.exception.ServiceException的典型用法代码示例。如果您正苦于以下问题:Java ServiceException类的具体用法?Java ServiceException怎么用?Java ServiceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ServiceException类属于com.microsoft.windowsazure.exception包,在下文中一共展示了ServiceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadFileAndCreateAsset

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private AssetInfo uploadFileAndCreateAsset(String fileName)
        throws ServiceException, IOException {
    final WritableBlobContainerContract uploader;
    final AssetInfo resultAsset;
    final AccessPolicyInfo uploadAccessPolicy;
    LocatorInfo uploadLocator = null;

    // Create an Asset
    resultAsset = mediaService
            .create(Asset.create().setName(fileName).setAlternateId("altId"));
    System.out.println("Created Asset " + fileName);

    // Create an AccessPolicy that provides Write access for 15 minutes
    uploadAccessPolicy = mediaService.create(AccessPolicy.create("uploadAccessPolicy",
            15.0, EnumSet.of(AccessPolicyPermission.WRITE)));

    // Create a Locator using the AccessPolicy and Asset
    uploadLocator = mediaService.create(Locator.create(uploadAccessPolicy.getId(),
            resultAsset.getId(), LocatorType.SAS));

    // Create the Blob Writer using the Locator
    uploader = mediaService.createBlobWriter(uploadLocator);

    // The local file that will be uploaded to your Media Services account
    try (final InputStream input = new ClassPathResource(fileName).getInputStream()) {
        System.out.println("Uploading " + fileName);

        // Upload the local file to the asset
        uploader.createBlockBlob(fileName, input);
    }
    // Inform Media Services about the uploaded files
    mediaService.action(AssetFile.createFileInfos(resultAsset.getId()));
    System.out.println("Uploaded Asset File " + fileName);

    mediaService.delete(Locator.delete(uploadLocator.getId()));
    mediaService.delete(AccessPolicy.delete(uploadAccessPolicy.getId()));

    return resultAsset;
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:40,代码来源:MediaServicesSampleApplication.java

示例2: createMediaContract

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private MediaContract createMediaContract() throws ServiceException {
    LOG.debug("createMediaContract called");
    final com.microsoft.windowsazure.Configuration configuration = MediaConfiguration
            .configureWithOAuthAuthentication(
                    MediaServicesProperties.MEDIA_SERVICE_URI,
                    MediaServicesProperties.OAUTH_URI,
                    mediaServicesProperties.getAccountName(),
                    mediaServicesProperties.getAccountKey(),
                    MediaServicesProperties.SCOPE);

    if (nonNull(mediaServicesProperties.getProxyHost())
            && nonNull(mediaServicesProperties.getProxyPort())) {
        configuration.getProperties().put(PROPERTY_HTTP_PROXY_HOST, mediaServicesProperties.getProxyHost());
        configuration.getProperties().put(PROPERTY_HTTP_PROXY_PORT, mediaServicesProperties.getProxyPort());
        configuration.getProperties().put(PROPERTY_HTTP_PROXY_SCHEME, mediaServicesProperties.getProxyScheme());
    } else if (nonNull(mediaServicesProperties.getProxyHost()) && isNull(mediaServicesProperties.getProxyPort())) {
        throw new ServiceException("Please Set Network Proxy port in application.properties");
    } else if (nonNull(mediaServicesProperties.getProxyPort()) && isNull(mediaServicesProperties.getProxyHost())) {
        throw new ServiceException("Please Set Network Proxy host in application.properties");
    }
    return MediaService.create(configuration);
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:23,代码来源:MediaServicesAutoConfiguration.java

示例3: createAssetDeliveryPolicy

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
public static void createAssetDeliveryPolicy(AssetInfo asset, ContentKeyInfo key) throws ServiceException {
    String acquisitionUrl = mediaService
            .create(ContentKey.getKeyDeliveryUrl(key.getId(), ContentKeyDeliveryType.PlayReadyLicense));

    Map<AssetDeliveryPolicyConfigurationKey, String> assetDeliveryPolicyConfiguration
        = new HashMap<AssetDeliveryPolicyConfigurationKey, String>();

    assetDeliveryPolicyConfiguration.put(AssetDeliveryPolicyConfigurationKey.PlayReadyLicenseAcquisitionUrl,
            acquisitionUrl);

    AssetDeliveryPolicyInfo assetDeliveryPolicy = mediaService.create(AssetDeliveryPolicy.create()
            .setName("PlayReady Smooth + Dash + HLS Asset Delivery Policy")
            .setAssetDeliveryConfiguration(assetDeliveryPolicyConfiguration)
            .setAssetDeliveryPolicyType(AssetDeliveryPolicyType.DynamicCommonEncryption)
            .setAssetDeliveryProtocol(EnumSet.of(AssetDeliveryProtocol.SmoothStreaming, AssetDeliveryProtocol.Dash, AssetDeliveryProtocol.HLS)));

    // Link the AssetDeliveryPolicy to the Asset
    mediaService.action(Asset.linkDeliveryPolicy(asset.getId(), assetDeliveryPolicy.getId()));

    System.out.println("Added Asset Delivery Policy: " + assetDeliveryPolicy.getName());
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:22,代码来源:Program.java

示例4: getStreamingOriginLocator

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
public static String getStreamingOriginLocator(AssetInfo asset) throws ServiceException {
    // Get the .ISM AssetFile
    ListResult<AssetFileInfo> assetFiles = mediaService.list(AssetFile.list(asset.getAssetFilesLink()));
    AssetFileInfo streamingAssetFile = null;
    for (AssetFileInfo file : assetFiles) {
        if (file.getName().toLowerCase().endsWith(".ism")) {
            streamingAssetFile = file;
            break;
        }
    }

    AccessPolicyInfo originAccessPolicy;
    LocatorInfo originLocator = null;

    // Create a 30-day readonly AccessPolicy
    double durationInMinutes = 60 * 24 * 30;
    originAccessPolicy = mediaService.create(
            AccessPolicy.create("Streaming policy", durationInMinutes, EnumSet.of(AccessPolicyPermission.READ)));

    // Create a Locator using the AccessPolicy and Asset
    originLocator = mediaService
            .create(Locator.create(originAccessPolicy.getId(), asset.getId(), LocatorType.OnDemandOrigin));

    // Create a Smooth Streaming base URL
    return originLocator.getPath() + streamingAssetFile.getName() + "/manifest";
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:27,代码来源:Program.java

示例5: checkJobStatus

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private static void checkJobStatus(String jobId) throws InterruptedException, ServiceException {
    boolean done = false;
    JobState jobState = null;
    while (!done) {
        // Sleep for 5 seconds
        Thread.sleep(5000);

        // Query the updated Job state
        jobState = mediaService.get(Job.get(jobId)).getState();
        System.out.println("Job state: " + jobState);

        if (jobState == JobState.Finished || jobState == JobState.Canceled || jobState == JobState.Error) {
            done = true;
        }
    }
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:17,代码来源:Program.java

示例6: checkJobStatus

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private static JobState checkJobStatus(String jobId) throws InterruptedException, ServiceException {
    boolean done = false;
    JobState jobState = null;
    while (!done) {
        // Sleep for 5 seconds
        Thread.sleep(5000);

        // Query the updated Job state
        jobState = mediaService.get(Job.get(jobId)).getState();
        System.out.println("Job state: " + jobState);

        if (jobState == JobState.Finished || jobState == JobState.Canceled || jobState == JobState.Error) {
            done = true;
        }
    }

    return jobState;
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:19,代码来源:Program.java

示例7: getStreamingOriginLocator

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
public static String getStreamingOriginLocator(AssetInfo asset) throws ServiceException {
    // Get the .ISM AssetFile
    ListResult<AssetFileInfo> assetFiles = mediaService.list(AssetFile.list(asset.getAssetFilesLink()));
    AssetFileInfo streamingAssetFile = null;
    for (AssetFileInfo file : assetFiles) {
        if (file.getName().toLowerCase().endsWith(".ism")) {
            streamingAssetFile = file;
            break;
        }
    }

    AccessPolicyInfo originAccessPolicy;
    LocatorInfo originLocator = null;

    // Create a 30-day readonly AccessPolicy
    double durationInMinutes = 60 * 24 * 30;
    originAccessPolicy = mediaService.create(
            AccessPolicy.create("Streaming policy", durationInMinutes, EnumSet.of(AccessPolicyPermission.READ)));

    // Create a Locator using the AccessPolicy and Asset
    originLocator = mediaService
            .create(Locator.create(originAccessPolicy.getId(), asset.getId(), LocatorType.OnDemandOrigin));

    // Create a Smooth Streaming base URL
    return originLocator.getPath() + streamingAssetFile.getName() + "/manifest(format=m3u8-aapl)";
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:27,代码来源:Program.java

示例8: createHostedService

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private void createHostedService(String hostedServiceName, String loc, String certPath) throws SAXException, InterruptedException, ExecutionException, TransformerException, ServiceException, URISyntaxException, ParserConfigurationException, IOException {
    //hosted service required for vm deployment
    HostedServiceCreateParameters createParameters = new HostedServiceCreateParameters();
    //required
    createParameters.setLabel(hostedServiceName);
    //required
    createParameters.setServiceName(hostedServiceName);
    createParameters.setDescription(hostedServiceName);

    //required
    String location="North Europe";
    if(!loc.equals(""))
        location=loc;

    createParameters.setLocation(location);
    OperationResponse hostedServiceOperationResponse = hostedServicesOperations.create(createParameters);

    uploadCerts(computeManagementClient,hostedServiceName,getCertData(certPath));
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:20,代码来源:AzureConnector.java

示例9: CreateResourceGroup

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
public static void CreateResourceGroup(String rgname, ResourceManagementClient resourcesClient) throws URISyntaxException, IOException, ServiceException, URISyntaxException
{
    ResourceGroup rgroup = new ResourceGroup();
    rgroup.setLocation(defaultLocation);
    
    try
    {
        resourcesClient.getResourceGroupsOperations().createOrUpdate(rgname, rgroup);
    }
    catch(URISyntaxException | IOException e)
    {
        System.out.println(e.getMessage());
    }
}
 
开发者ID:mjeelanimsft,项目名称:storage-java-resource-provider-getting-started,代码行数:15,代码来源:StorageResourceProviderSample.java

示例10: DeleteStorageAccount

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private static void DeleteStorageAccount(String rgname, String acctName, StorageManagementClient storageMgmtClient)
{
    System.out.println("Deleting a storage account...");
    try {
        storageMgmtClient.getStorageAccountsOperations().delete(rgname, acctName);
    } catch (IOException | ServiceException e) {
        System.out.println("Error deleting storage account - " + e.getMessage());
    }
    System.out.println("Storage account " + acctName + " deleted");
}
 
开发者ID:mjeelanimsft,项目名称:storage-java-resource-provider-getting-started,代码行数:11,代码来源:StorageResourceProviderSample.java

示例11: UpdateStorageAccount

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private static void UpdateStorageAccount(String rgname, String acctName, StorageManagementClient storageMgmtClient)
{
    System.out.println("Updating storage account...");

    // Update storage account type
    StorageAccountUpdateParameters parameters = new StorageAccountUpdateParameters();
    parameters.setAccountType(AccountType.STANDARDLRS);
    
    try {
        storageMgmtClient.getStorageAccountsOperations().update(rgname, acctName, parameters);
    } catch (IOException | ServiceException | URISyntaxException e) {
        System.out.println("Error updating storage account - " + e.getMessage());
    }
    System.out.println("Account type on storage account updated.");
}
 
开发者ID:mjeelanimsft,项目名称:storage-java-resource-provider-getting-started,代码行数:16,代码来源:StorageResourceProviderSample.java

示例12: uploadFileAndCreateAsset

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private static AssetInfo uploadFileAndCreateAsset(String fileName)
        throws ServiceException, FileNotFoundException, NoSuchAlgorithmException {
    WritableBlobContainerContract uploader;
    AssetInfo resultAsset;
    AccessPolicyInfo uploadAccessPolicy;
    LocatorInfo uploadLocator = null;

    // Create an Asset
    resultAsset = mediaService.create(Asset.create().setName(fileName).setAlternateId("altId"));
    System.out.println("Created Asset " + fileName);

    // Create an AccessPolicy that provides Write access for 15 minutes
    uploadAccessPolicy = mediaService
            .create(AccessPolicy.create("uploadAccessPolicy", 15.0, EnumSet.of(AccessPolicyPermission.WRITE)));

    // Create a Locator using the AccessPolicy and Asset
    uploadLocator = mediaService
            .create(Locator.create(uploadAccessPolicy.getId(), resultAsset.getId(), LocatorType.SAS));

    // Create the Blob Writer using the Locator
    uploader = mediaService.createBlobWriter(uploadLocator);

    // The local file that will be uploaded to your Media Services account
    InputStream input = new FileInputStream(
            new File(Program.class.getClassLoader().getResource("").getPath() + fileName));

    System.out.println("Uploading " + fileName);

    // Upload the local file to the asset
    uploader.createBlockBlob(fileName, input);

    // Inform Media Services about the uploaded files
    mediaService.action(AssetFile.createFileInfos(resultAsset.getId()));
    System.out.println("Uploaded Asset File " + fileName);

    mediaService.delete(Locator.delete(uploadLocator.getId()));
    mediaService.delete(AccessPolicy.delete(uploadAccessPolicy.getId()));

    return resultAsset;
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:41,代码来源:Program.java

示例13: downloadAssetFiles

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
private static void downloadAssetFiles(AssetInfo asset, String destinationPath) throws ServiceException, IOException {
    // Create destination directory if does not exist
    new File(destinationPath).mkdir();

    // Create an AccessPolicy that provides Read access for 15 minutes
    AccessPolicyInfo accessPolicy = mediaService
            .create(AccessPolicy.create("downloadAccessPolicy", 15.0, EnumSet.of(AccessPolicyPermission.READ)));

    // Create a SAS Locator using the AccessPolicy and Asset
    LocatorInfo sasLocator = mediaService
            .create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS));

    // List all the Asset Files
    ListResult<AssetFileInfo> assetFiles = mediaService.list(AssetFile.list(asset.getAssetFilesLink()));

    for (AssetFileInfo file : assetFiles) {
        System.out.print("Downloading " + file.getName() + " output file...");

        URL downloadUrl = new URL(sasLocator.getBaseUri() + "/" + file.getName() + sasLocator.getContentAccessToken());
        HttpURLConnection httpConn = (HttpURLConnection) downloadUrl.openConnection();
        InputStream inputStream = httpConn.getInputStream();
        Files.copy(inputStream, Paths.get(destinationPath, file.getName()), StandardCopyOption.REPLACE_EXISTING);
        inputStream.close();

        System.out.println("Done!");
    }

    // Clean up Locator and Access Policy
    mediaService.delete(Locator.delete(sasLocator.getId()));
    mediaService.delete(AccessPolicy.delete(accessPolicy.getId()));
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:32,代码来源:Program.java

示例14: createAssetDeliveryPolicy

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
public static void createAssetDeliveryPolicy(AssetInfo asset, ContentKeyInfo key) throws ServiceException {
    String acquisitionUrl = mediaService
            .create(ContentKey.getKeyDeliveryUrl(key.getId(), ContentKeyDeliveryType.FairPlay));

    // The reason the below code replaces "https://" with "skd://" is because
    // in the IOS player sample code which you obtained in Apple developer account,
    // the player only recognizes a Key URL that starts with skd://.
    // However, if you are using a customized player,
    // you can choose whatever protocol you want.
    // For example, "https".
    acquisitionUrl = acquisitionUrl.replace("https://", "skd://");
    acquisitionUrl = acquisitionUrl.substring(0, acquisitionUrl.indexOf('?'));

    Map<AssetDeliveryPolicyConfigurationKey, String> assetDeliveryPolicyConfiguration
        = new HashMap<AssetDeliveryPolicyConfigurationKey, String>();

    assetDeliveryPolicyConfiguration.put(AssetDeliveryPolicyConfigurationKey.FairPlayBaseLicenseAcquisitionUrl,
            acquisitionUrl);
    assetDeliveryPolicyConfiguration.put(AssetDeliveryPolicyConfigurationKey.CommonEncryptionIVForCbcs, fairPlayIV);

    AssetDeliveryPolicyInfo assetDeliveryPolicy = mediaService.create(AssetDeliveryPolicy.create()
            .setName("FairPlay Asset Delivery Policy")
            .setAssetDeliveryConfiguration(assetDeliveryPolicyConfiguration)
            .setAssetDeliveryPolicyType(AssetDeliveryPolicyType.DynamicCommonEncryptionCbcs)
            .setAssetDeliveryProtocol(EnumSet.of(AssetDeliveryProtocol.HLS)));

    // Link the AssetDeliveryPolicy to the Asset
    mediaService.action(Asset.linkDeliveryPolicy(asset.getId(), assetDeliveryPolicy.getId()));

    System.out.println("Added Asset Delivery Policy: " + assetDeliveryPolicy.getName());
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:32,代码来源:Program.java

示例15: createAssetDeliveryPolicy

import com.microsoft.windowsazure.exception.ServiceException; //导入依赖的package包/类
public static void createAssetDeliveryPolicy(AssetInfo asset, ContentKeyInfo key) throws ServiceException {
    String acquisitionUrl = mediaService
            .create(ContentKey.getKeyDeliveryUrl(key.getId(), ContentKeyDeliveryType.PlayReadyLicense));
    String widevineUrl = mediaService
            .create(ContentKey.getKeyDeliveryUrl(key.getId(), ContentKeyDeliveryType.Widevine));

    Map<AssetDeliveryPolicyConfigurationKey, String> assetDeliveryPolicyConfiguration
        = new HashMap<AssetDeliveryPolicyConfigurationKey, String>();

    if (widevineUrl.contains("?")) {
        widevineUrl = widevineUrl.substring(0, widevineUrl.indexOf("?"));
    }

    assetDeliveryPolicyConfiguration.put(AssetDeliveryPolicyConfigurationKey.PlayReadyLicenseAcquisitionUrl,
            acquisitionUrl);
    assetDeliveryPolicyConfiguration.put(AssetDeliveryPolicyConfigurationKey.WidevineBaseLicenseAcquisitionUrl,
            widevineUrl);

    AssetDeliveryPolicyInfo assetDeliveryPolicy = mediaService.create(AssetDeliveryPolicy.create()
            .setName("PlayReady & Widevine Dash Asset Delivery Policy")
            .setAssetDeliveryConfiguration(assetDeliveryPolicyConfiguration)
            .setAssetDeliveryPolicyType(AssetDeliveryPolicyType.DynamicCommonEncryption)
            .setAssetDeliveryProtocol(EnumSet.of(AssetDeliveryProtocol.Dash)));

    // Link the AssetDeliveryPolicy to the Asset
    mediaService.action(Asset.linkDeliveryPolicy(asset.getId(), assetDeliveryPolicy.getId()));

    System.out.println("Added Asset Delivery Policy: " + assetDeliveryPolicy.getName());
}
 
开发者ID:southworkscom,项目名称:azure-sdk-for-media-services-java-samples,代码行数:30,代码来源:Program.java


注:本文中的com.microsoft.windowsazure.exception.ServiceException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。