Example usage for java.net URISyntaxException printStackTrace

List of usage examples for java.net URISyntaxException printStackTrace

Introduction

In this page you can find the example usage for java.net URISyntaxException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Evaluates the current eco-efficiency of a VM.
 *
 * @param vmId VM identifier of the VM to be evaluated.
 * @param type Type of eco-efficiency assessment: energy (energy?) or
 * ecological (ecological?) efficiency.//from w  w  w  .ja v a  2  s  .c o  m
 * @return Eco-efficiency evaluation of the VM.
 */
public String assessVMEcoEfficiency(String vmId, String type) {
    String ret = null;
    try {
        if (vmId != null) {
            WebResource resource = client.resource(this.getAddress()).path("vm").path(vmId)
                    .path("assessecoefficiency");
            if (type != null) {
                resource = resource.queryParam("type", type);
            }
            ret = resource.type(MediaType.TEXT_PLAIN).accept(MediaType.TEXT_PLAIN).get(String.class);
        }
    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Returns the maximum eco-efficiency of a given node.
 *//*from w w  w .j  a v  a 2 s .c  o  m*/
public String getNodeMaxEco(String nodeId, String type) {
    String ret = null;
    try {
        if (nodeId != null) {
            WebResource resource = client.resource(this.getAddress()).path("infrastructure").path(nodeId)
                    .path("maxeco");
            if (type != null) {
                resource = resource.queryParam("type", type);
            }
            ret = resource.type("text/plain").get(String.class);
        }
    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Predicts the services energy and ecological efficiency upon its
 * deployment if it doesnt exist in the system, or it just predicts its
 * future energy and ecological efficiency otherwise.
 *
 * @param manifest Service manifest XML descriptor.
 * @param timeSpan Specifies the amount of time in the future in which the
 * prediction will be made./*from  w ww.  java  2s  .  com*/
 * @return Energy efficiency forecast of the service (to be deployed if it
 * doesnt exist). Ecological efficiency forecast of the service (to be
 * deployed if it doesnt exist).
 */
public double[] forecastServiceEnEcoEff(String manifest, Long timeSpan) {
    ListStrings result = null;
    double[] ret = { -1.0, -1.0 };
    try {
        WebResource resource = client.resource(this.getAddress()).path("/service/forecastenecoeff");
        if (timeSpan != null) {
            resource = resource.queryParam("timeSpan", timeSpan.toString());
        }

        result = resource.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML)
                .post(ListStrings.class, manifest);
        ret[0] = Double.parseDouble(result.get(0));
        ret[1] = Double.parseDouble(result.get(1));
    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:com.freeme.filemanager.view.FileViewFragment.java

public void init() {
    long time1 = System.currentTimeMillis();
    //Debug.startMethodTracing("file_view");
    ViewStub stub = (ViewStub) mRootView.findViewById(R.id.viewContaniner);
    stub.setLayoutResource(R.layout.file_explorer_list);
    stub.inflate();//from  w w  w .  j  av a 2 s.c  om
    ActivitiesManager.getInstance().registerActivity(ActivitiesManager.ACTIVITY_FILE_VIEW, mActivity);

    mFileCagetoryHelper = new FileCategoryHelper(mActivity);
    mFileViewInteractionHub = new FileViewInteractionHub(this, 1);
    // */ modify by droi liuhaoran for stop run
    /*/ Added by tyd wulianghuan 2013-12-12
    mCleanUpDatabaseHelper = new CleanUpDatabaseHelper(mActivity);
    mDatabase = mCleanUpDatabaseHelper.openDatabase();
    mFolderNameMap = new HashMap<String, String>();
    //*/

    // */add by droi liuhaoran for get Sd listener on 20160419
    mApplication = (FileManagerApplication) mActivity.getApplication();
    // */

    // notifyFileChanged();
    Intent intent = mActivity.getIntent();
    String action = intent.getAction();
    if (!TextUtils.isEmpty(action)
            && (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT))) {
        mFileViewInteractionHub.setMode(Mode.Pick);

        boolean pickFolder = intent.getBooleanExtra(PICK_FOLDER, false);
        if (!pickFolder) {
            String[] exts = intent.getStringArrayExtra(EXT_FILTER_KEY);
            if (exts != null) {
                mFileCagetoryHelper.setCustomCategory(exts);
            }
        } else {
            mFileCagetoryHelper.setCustomCategory(new String[] {} /*
                                                                  * folder
                                                                  * only
                                                                  */);
            mRootView.findViewById(R.id.pick_operation_bar).setVisibility(View.VISIBLE);

            mRootView.findViewById(R.id.button_pick_confirm).setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    try {
                        Intent intent = Intent.parseUri(mFileViewInteractionHub.getCurrentPath(), 0);
                        mActivity.setResult(Activity.RESULT_OK, intent);
                        mActivity.finish();
                    } catch (URISyntaxException e) {
                        e.printStackTrace();
                    }
                }
            });

            mRootView.findViewById(R.id.button_pick_cancel).setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    mActivity.finish();
                }
            });
        }
    } else {
        mFileViewInteractionHub.setMode(Mode.View);
    }
    mVolumeSwitch = (ImageButton) mRootView.findViewById(R.id.volume_navigator);
    updateVolumeSwitchState();
    mGalleryNavigationBar = (RelativeLayout) mRootView.findViewById(R.id.gallery_navigation_bar);
    mVolumeSwitch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            int visibility = getVolumesListVisibility();
            if (visibility == View.GONE) {
                buildVolumesList();
                showVolumesList(true);
            } else if (visibility == View.VISIBLE) {
                showVolumesList(false);
            }
        }

    });
    mFileListView = (ListView) mRootView.findViewById(R.id.file_path_list);
    mFileIconHelper = new FileIconHelper(mActivity);
    mAdapter = new FileListAdapter(mActivity, R.layout.file_browser_item, mFileNameList,
            mFileViewInteractionHub, mFileIconHelper);

    boolean baseSd = intent.getBooleanExtra(GlobalConsts.KEY_BASE_SD,
            !FileExplorerPreferenceActivity.isReadRoot(mActivity));
    Log.i(LOG_TAG, "baseSd = " + baseSd);

    String rootDir = intent.getStringExtra(ROOT_DIRECTORY);
    if (!TextUtils.isEmpty(rootDir)) {
        if (baseSd && this.sdDir.startsWith(rootDir)) {
            rootDir = this.sdDir;
        }
    } else {
        rootDir = baseSd ? this.sdDir : GlobalConsts.ROOT_PATH;
    }

    String currentDir = FileExplorerPreferenceActivity.getPrimaryFolder(mActivity);
    Uri uri = intent.getData();
    if (uri != null) {
        if (baseSd && this.sdDir.startsWith(uri.getPath())) {
            currentDir = this.sdDir;
        } else {
            currentDir = uri.getPath();
        }
    }
    initVolumeState();
    mBackspaceExit = (uri != null) && (TextUtils.isEmpty(action)
            || (!action.equals(Intent.ACTION_PICK) && !action.equals(Intent.ACTION_GET_CONTENT)));

    mFileListView.setAdapter(mAdapter);
    IntentFilter intentFilter = new IntentFilter();
    // add by xueweili for get sdcard
    intentFilter.setPriority(1000);

    /*
     * intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
     * intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_EJECT);
     */
    if (!mReceiverTag) {
        mReceiverTag = true;
        intentFilter.addAction(GlobalConsts.BROADCAST_REFRESH);
        intentFilter.addDataScheme("file");
        mActivity.registerReceiver(mReceiver, intentFilter);
    }

    // */add by droi liuhaoran for get Sd listener on 20160419
    mApplication.addSDCardChangeListener(this);
    // */

    setHasOptionsMenu(true);

    // add by mingjun for load file
    mRootView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6,
                int arg7, int arg8) {
            isLayout = arg1;
        }
    });
    loadDialog = new ProgressDialog(mRootView.getContext());
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Predicts IPs overall eco-efficiency./*from www . jav a  2s . com*/
 *
 * @param timeSpan Specifies the amount of time in the future in which the
 * prediction will be made.
 * @param type Type of eco-efficiency forecast: energy (energy?) or
 * ecological (ecological?) efficiency.
 * @return Eco-efficiency forecast of the IP.
 */
public synchronized String forecastIPEcoEfficiency(Long timeSpan, String type) {
    String ret = null;
    try {
        WebResource resource = client.resource(this.getAddress()).path("infrastructure")
                .path("forecastecoefficiency");
        if (timeSpan != null) {
            resource = resource.queryParam("timeSpan", timeSpan.toString());
        }
        if (type != null) {
            resource = resource.queryParam("type", type);
        }

        ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).get(String.class);

    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Predicts the services eco-efficiency upon its deployment if it doesnt
 * exist in the system, or it just predicts its future eco-efficiency
 * otherwise.//w ww.j a  va  2 s . c o m
 *
 * @param manifest Service manifest XML descriptor.
 * @param timeSpan Specifies the amount of time in the future in which the
 * prediction will be made.
 * @param type Type of eco-efficiency forecast: energy (energy?) or
 * ecological (ecological?) efficiency.
 * @return Eco-efficiency forecast of the service (to be deployed if it
 * doesnt exist).
 */
public String forecastServiceEcoEfficiency(String manifest, Long timeSpan, String type) {
    String ret = null;
    try {
        WebResource resource = client.resource(this.getAddress()).path("service/forecastecoefficiency");
        if (type != null) {
            resource = resource.queryParam("type", type);
        }
        if (timeSpan != null) {
            resource = resource.queryParam("timeSpan", timeSpan.toString());
        }

        //if (manifest != null) resource = resource.queryParam("manifest", manifest);
        ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).post(String.class,
                manifest);
    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Predicts the future eco-efficiency of a VM.
 *
 * @param vmId VM identifier of the VM to be evaluated.
 * @param type Type of eco-efficiency forecast: energy (energy?) or
 * ecological (ecological?) efficiency./*w w  w.  j  av  a2s.c  om*/
 * @param timeSpan Specifies the amount of time in the future in which the
 * prediction will be made.
 * @return
 */
public String forecastVMEcoEfficiency(String vmId, String type, Long timeSpan) {
    String ret = null;
    try {
        if (vmId != null) {
            WebResource resource = client.resource(this.getAddress()).path("vm").path(vmId)
                    .path("forecastecoefficiency");
            if (type != null) {
                resource = resource.queryParam("type", type);
            }
            if (timeSpan != null) {
                resource = resource.queryParam("timeSpan", timeSpan.toString());
            }
            ret = resource.type(MediaType.TEXT_PLAIN).accept(MediaType.TEXT_PLAIN).get(String.class);
        }
    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Predicts IPs overall eco-efficiency upon a VM deployment in a yet
 * unknown physical host.//from  www .  ja  va2  s .com
 *
 * @param ovfDom OVF descriptor of the VM to be deployed, generated using
 * EMOTIVEs OVFWrapper (see Installation Guide).
 * @param timeSpan Specifies the amount of time in the future in which the
 * prediction will be made.
 * @param type Type of eco-efficiency forecast: energy (energy?) or
 * ecological (ecological?) efficiency.
 * @return Eco-efficiency forecast of the IP.
 */
public synchronized String forecastIPEcoEfficiencyVMDeploymentUnknownPlacement(OVFWrapper ovfDom, String type,
        Long timeSpan) {
    String ret = null;
    try {
        WebResource resource = client.resource(this.getAddress()).path("infrastructure")
                .path("forecastecoefficiencyVMDeploymentUnknownPlacement");
        if (timeSpan != null) {
            resource = resource.queryParam("timeSpan", timeSpan.toString());
        }
        if (type != null) {
            resource = resource.queryParam("type", type);
        }

        ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).post(String.class,
                ovfDom.toString());

    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Predicts IPs overall eco-efficiency upon a service deployment.
 *
 * @param manifest Service manifest XML descriptor.
 * @param timeSpan Specifies the amount of time in the future in which the
 * prediction will be made./*  ww w  .  java2s .c o m*/
 * @param type Type of eco-efficiency forecast: energy (energy?) or
 * ecological (ecological?) efficiency.
 * @return Eco-efficiency forecast of the IP.
 */
public synchronized String forecastIPEcoEfficiencyServiceDeployment(String manifest, Long timeSpan,
        String type) {
    String ret = null;
    try {
        WebResource resource = client.resource(this.getAddress()).path("infrastructure")
                .path("forecastecoefficiencyPlusService");
        if (timeSpan != null) {
            resource = resource.queryParam("timeSpan", timeSpan.toString());
        }
        if (type != null) {
            resource = resource.queryParam("type", type);
        }

        if (manifest == null) {
            log.error("Manifest can not be null");
            return "-1.0";
        }

        ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).post(String.class,
                manifest);

    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}

From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java

/**
 * Predicts IPs overall eco-efficiency upon a VM cancellation (VM to be
 * shut down)./*  w ww  . j a  v a  2  s  .  com*/
 *
 * @param vmId VM identifier of the VM to be cancelled
 * @param timeSpan Specifies the amount of time in the future in which the
 * prediction will be made.
 * @param type Type of eco-efficiency forecast: energy (energy?) or
 * ecological (ecological?) efficiency.
 * @return Eco-efficiency forecast of the IP.
 */
public synchronized String forecastIPEcoEfficiencyVMCancellation(String vmId, Long timeSpan, String type) {
    String ret = null;
    try {
        WebResource resource = client.resource(this.getAddress()).path("infrastructure")
                .path("forecastecoefficiencyVMCancellation");
        if (timeSpan != null) {
            resource = resource.queryParam("timeSpan", timeSpan.toString());
        }
        if (type != null) {
            resource = resource.queryParam("type", type);
        }

        if (vmId == null) {
            log.error("vmId can not be null");
            return null;
        } else {
            resource = resource.queryParam("vmId", vmId);
        }

        ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).get(String.class);

    } catch (UniformInterfaceException ex) {
        ClientResponse cr = ex.getResponse();
        log.error(cr.getStatus());
        ex.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ret;
}