Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

In this page you can find the example usage for java.lang RuntimeException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:net.cbtltd.rest.interhome.A_Handler.java

/**
 * Read prices.// w  w  w .j  a va 2 s  .co m
 *
 * @param version the version
 * @param salesoffice the salesoffice
 * @param currency the currency
 * @param duration the duration
 */
private synchronized void readPrices(Date version, String salesoffice, Currency.Code currency, int duration) {
    String altparty = getAltpartyid();
    String message = "Interhome readPrices Weekly " + altparty;
    LOG.debug(message);
    String fn = null;
    final SqlSession sqlSession = RazorServer.openSession();
    try {
        JAXBContext jc = JAXBContext.newInstance("net.cbtltd.rest.interhome.price");
        Unmarshaller um = jc.createUnmarshaller();

        fn = "price_" + salesoffice + "_" + currency.name().toLowerCase()
                + (duration < 14 ? "" : "_" + String.valueOf(duration)) + ".xml";
        Prices prices = (Prices) um.unmarshal(ftp(fn));

        if (prices != null && prices.getPrice() != null) {
            int count = prices.getPrice().size();
            LOG.debug("Total prices for " + duration + " days: " + count);
        } else {
            LOG.debug("Error, no price file for " + duration + " days");
            return;
        }

        int i = 0;
        for (Price weekprice : prices.getPrice()) {
            String altid = weekprice.getCode();
            //            if (!altid.equals("CH3920.126.1") || !"CH3920.126.1".equalsIgnoreCase(altid)) continue;
            String productid = getProductId(altid);

            if (productid == null) {
                Product product = sqlSession.getMapper(ProductMapper.class)
                        .altread(new NameId(altparty, altid));
                if (product == null) {
                    LOG.error(Error.product_id.getMessage() + " " + weekprice.getCode());
                    continue;
                }
                PRODUCTS.put(altid, product.getId());
                productid = getProductId(altid);
            }

            //            if (!productid.equals("27077") || !String.valueOf(27077).equalsIgnoreCase(productid)) continue;

            Date fromdate = weekprice.getStartdate().toGregorianCalendar().getTime();
            Date todate = weekprice.getEnddate().toGregorianCalendar().getTime();

            if (weekprice.getServices() != null && weekprice.getServices().getService() != null) {
                net.cbtltd.shared.Price mandatory = new net.cbtltd.shared.Price();
                mandatory.setEntitytype(NameId.Type.Mandatory.name());
                mandatory.setEntityid(productid);
                mandatory.setCurrency(currency.name());
                mandatory.setPartyid(altparty);
                mandatory.setVersion(version);

                for (Service service : weekprice.getServices().getService()) {
                    mandatory.setType("Fees");
                    mandatory.setDate(fromdate);
                    mandatory.setTodate(todate);
                    mandatory.setQuantity(0.0);
                    mandatory.setUnit(Unit.EA);
                    mandatory.setAvailable(1);
                    mandatory.setMinStay(1);
                    net.cbtltd.shared.Price existprice = sqlSession.getMapper(PriceMapper.class)
                            .exists(mandatory);
                    if (existprice == null) {
                        sqlSession.getMapper(PriceMapper.class).create(mandatory);
                    } else {
                        mandatory = existprice;
                    }

                    mandatory.setState(net.cbtltd.shared.Price.CREATED);
                    mandatory.setName(getServicename(service.getCode()));
                    mandatory.setMinimum(0.0);
                    mandatory.setValue(
                            service.getServiceprice() == null ? 0.0 : service.getServiceprice().doubleValue());
                    mandatory.setRule("Manual");
                    sqlSession.getMapper(PriceMapper.class).update(mandatory);
                }
                sqlSession.getMapper(PriceMapper.class).cancelversion(mandatory);
            }

            //            Adjustment adjustment = setAdjustment(sqlSession, productid, 7, 7, currency.name(), fromdate, todate, weekprice, "1111111", "week", version);

            Adjustment action = new Adjustment();
            action.setCurrency(currency.name());
            action.setState(Adjustment.Created);
            action.setPartyID(altparty);
            action.setProductID(productid);
            action.setFromDate(fromdate);
            action.setToDate(todate);
            action.setMaxStay(999);
            action.setMinStay(5);

            Adjustment example = sqlSession.getMapper(AdjustmentMapper.class).readbyexample(action);
            if (example == null)
                continue;

            Double rentalPrice;
            if (weekprice.getSpecialoffer() != null
                    && weekprice.getSpecialoffer().getSpecialofferprice() != null) {
                rentalPrice = weekprice.getSpecialoffer().getSpecialofferprice().doubleValue();
            } else {
                rentalPrice = weekprice.getRentalprice().doubleValue();
            }

            Double dailyprice = DAILYPRICES.get(example.getID());
            Double fixprice = example.getFixPrice();
            Double extra = ((rentalPrice - fixprice) / duration) - dailyprice;// ( ( weekprice - fixprice ) / 7 ) - rentalprice[per/day]

            action.setMinStay(duration);
            action.setMaxStay(duration);
            action.setState(null);

            net.cbtltd.shared.Adjustment exists = sqlSession.getMapper(AdjustmentMapper.class).exists(action);
            if (exists == null) {
                sqlSession.getMapper(AdjustmentMapper.class).create(action);
            } else {
                action = exists;
            }

            action.setExtra(PaymentHelper.getAmountWithTwoDecimals(extra));
            action.setServicedays(Adjustment.WEEK);
            action.setState(Adjustment.Created);
            action.setFixPrice(fixprice);
            action.setVersion(version);

            sqlSession.getMapper(AdjustmentMapper.class).update(action);
            sqlSession.getMapper(AdjustmentMapper.class).cancelversion(action);

            LOG.debug(i++ + " WeekPrice: " + " " + weekprice.getCode() + " " + productid + " " + salesoffice
                    + " " + action.getExtra() + " " + currency + " " + duration);
        }
        sqlSession.commit();
    } catch (NullPointerException ex) {
        ex.printStackTrace();
        LOG.error("NPE" + ex.getStackTrace());
        sqlSession.rollback();
    } catch (RuntimeException e) {
        e.printStackTrace();
        LOG.error("RuntimeExc " + e.getStackTrace());
        sqlSession.rollback();
    } catch (Throwable x) {
        sqlSession.rollback();
        LOG.error(x.getClass().getName() + ": " + x.getMessage());
    } finally {
        sqlSession.close();
        delete(fn);
    }
}

From source file:com.free.searcher.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewContainer, Bundle savedInstanceState) {

    super.onCreateView(inflater, viewContainer, savedInstanceState);
    this.activity = getActivity();
    actionBar = activity.getActionBar();

    View v = inflater.inflate(R.layout.main, viewContainer, false);
    v.setOnSystemUiVisibilityChangeListener(this);

    webView = (WebView) v.findViewById(R.id.webView1);
    statusView = (TextView) v.findViewById(R.id.statusView);

    if (webViewBundle != null) {
        webView.restoreState(webViewBundle);
        Log.d("onCreateView.webView.restoreState", webViewBundle + "");
    } else if (currentUrl.length() > 0) {
        Log.d("onCreateView.locX, locY", locX + ", " + locY + ", " + currentUrl);
        webView.loadUrl(currentUrl);// w w w.  j  a va2  s . co m
        webView.setScrollX(locX);
        webView.setScrollY(locY);
        Log.d("currentUrl 8", currentUrl);
    }
    statusView.setText(status);

    Log.d("onCreateView.savedInstanceState", savedInstanceState + "vvv");
    mNotificationManager = (NotificationManager) activity.getSystemService(activity.NOTIFICATION_SERVICE);

    webView.setFocusable(true);
    webView.setFocusableInTouchMode(true);
    webView.requestFocus();
    webView.requestFocusFromTouch();
    webView.getSettings().setAllowContentAccess(false);
    webView.getSettings().setPluginState(WebSettings.PluginState.OFF);
    // webView.setBackgroundColor(LIGHT_BLUE);
    webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    webView.setBackgroundColor(getResources().getColor(R.color.lightyellow));

    webView.setOnLongClickListener(this);
    statusView.setOnLongClickListener(this);

    webView.setWebViewClient(new WebViewClient() {

        private void jumpTo(final int xLocation, final int yLocation) {
            webView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Log.d("jumpTo1.locX, locY", xLocation + ", " + yLocation + ", " + currentUrl);
                    try {
                        webView.scrollTo(xLocation, yLocation);
                        webView.setScrollX(xLocation);
                        webView.setScrollY(yLocation);
                        //                           locX = 0;
                        //                           locY = 0;
                    } catch (RuntimeException e) {
                        Log.e("error jumpTo2.locX, locY", locX + ", " + locY + ", " + currentUrl);
                    }
                }
            }, 100);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, final String url) {
            if (currentZipFileName.length() > 0 && (extractFile == null || extractFile.isClosed())) {
                try {
                    extractFile = new ExtractFile(currentZipFileName,
                            MainFragment.PRIVATE_PATH + currentZipFileName);
                } catch (RarException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            int ind = url.indexOf("?deleteFile=");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }

                String urlStatus = Util.getUrlStatus(url);
                final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteFile=") + 12,
                        urlStatus.length());
                Log.d("deleteFile", "url=" + url + ", urlStatus=" + urlStatus);

                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Delete File?");
                alert.setMessage("Do you really want to delete file \"" + selectedFile + "\"?");
                alert.setCancelable(true);
                alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            locX = webView.getScrollX();
                            locY = webView.getScrollY();
                            webView.loadUrl(
                                    new File(dupTask.deleteFile(selectedFile)).toURI().toURL().toString());
                        } catch (IOException e) {
                            statusView.setText(e.getMessage());
                            Log.d("deleteFile", e.getMessage(), e);
                        }
                    }
                });
                alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            }

            ind = url.indexOf("?deleteGroup=");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }

                String urlStatus = Util.getUrlStatus(url);
                final String groupFile = urlStatus.substring(urlStatus.indexOf("?deleteGroup=") + 13,
                        urlStatus.length());
                int indexOf = groupFile.indexOf(",");
                final int group = Integer.parseInt(groupFile.substring(0, indexOf));
                final String selectedFile = groupFile.substring(indexOf + 1);
                Log.d("groupFile", ",groupFile=" + groupFile + ", url=" + url + ", urlStatus=" + urlStatus);

                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Delete Group of Files?");
                alert.setMessage(
                        "Do you really want to delete this group, except file \"" + selectedFile + "\"?");
                alert.setCancelable(true);
                alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        locX = webView.getScrollX();
                        locY = webView.getScrollY();
                        webView.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    webView.loadUrl(new File(dupTask.deleteGroup(group, selectedFile)).toURI()
                                            .toURL().toString());
                                } catch (Throwable e) {
                                    statusView.setText(e.getMessage());
                                    Log.e("Delete Group", e.getMessage(), e);
                                    Log.e("Delete Group", locX + ", " + locY + ", " + currentUrl);
                                }
                            }
                        }, 0);
                    }
                });
                alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            }

            ind = url.indexOf("?deleteFolder=");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }

                String urlStatus = Util.getUrlStatus(url);
                final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteFolder=") + 14,
                        urlStatus.length());
                Log.d("deleteFolder",
                        ",deleteFolder=" + selectedFile + ", url=" + url + ", urlStatus=" + urlStatus);
                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Delete folder?");
                alert.setMessage("Do you really want to delete duplicate in folder \""
                        + selectedFile.substring(0, selectedFile.lastIndexOf("/")) + "\"?");
                alert.setCancelable(true);
                alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        locX = webView.getScrollX();
                        locY = webView.getScrollY();
                        webView.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    webView.loadUrl(new File(dupTask.deleteFolder(selectedFile)).toURI().toURL()
                                            .toString());
                                } catch (Throwable e) {
                                    statusView.setText(e.getMessage());
                                    Log.e("Delete folder", e.getMessage(), e);
                                    Log.e("Delete folder", locX + ", " + locY + ", " + currentUrl);
                                }
                            }
                        }, 0);
                    }
                });
                alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            }

            ind = url.indexOf("?deleteSub=");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }

                String urlStatus = Util.getUrlStatus(url);

                final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteSub=") + 11,
                        urlStatus.length());
                Log.d("deleteSub", ",deleteSub=" + selectedFile + ", url=" + url + ", urlStatus=" + urlStatus);
                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Delete sub folder?");
                alert.setMessage("Do you really want to delete duplicate files in sub folder of \""
                        + selectedFile.substring(0, selectedFile.lastIndexOf("/")) + "\"?");
                alert.setCancelable(true);
                alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        locX = webView.getScrollX();
                        locY = webView.getScrollY();
                        webView.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    webView.loadUrl(new File(dupTask.deleteSubFolder(selectedFile)).toURI()
                                            .toURL().toString());
                                } catch (Throwable e) {
                                    statusView.setText(e.getMessage());
                                    Log.e("Delete sub folder", e.getMessage(), e);
                                    Log.e("Delete sub folder", locX + ", " + locY + ", " + currentUrl);
                                }
                            }
                        }, 0);
                    }
                });
                alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            }

            ind = url.indexOf("?viewName");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }
                nameOrder = !nameOrder;
                locX = 0;
                locY = 0;
                Log.d("url=", url + ", viewName");
                try {
                    webView.loadUrl(new File(dupTask.genFile(dupTask.groupList, dupTask.NAME_VIEW)).toURI()
                            .toURL().toString());
                } catch (IOException e) {
                    Log.e("viewName", e.getMessage(), e);
                }
                return true;
            }

            ind = url.indexOf("?viewGroup");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }
                groupViewChanged = true;
                locX = 0;
                locY = 0;
                Log.d("url=", url + ", viewGroup");
                try {
                    webView.loadUrl(new File(dupTask.genFile(dupTask.groupList, dupTask.GROUP_VIEW)).toURI()
                            .toURL().toString());
                } catch (IOException e) {
                    Log.e("viewGroup", e.getMessage(), e);
                }
                return true;
            }
            if (zextr == null) {
                locX = 0;
                locY = 0;
            } else {
                zextr = null;
            }

            if (MainActivity.popup) {
                final MainFragment frag = ((MainActivity) activity).addFragmentToStack();
                frag.status = Util.getUrlStatus(url);
                frag.load = load;
                frag.currentSearching = currentSearching;
                frag.selectedFiles = selectedFiles;
                frag.files = files;
                frag.currentZipFileName = currentZipFileName;
                if (extractFile != null) {
                    try {
                        frag.extractFile = new ExtractFile();
                        extractFile.copyTo(frag.extractFile);
                    } catch (RarException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                frag.home = home;
                //                  if (mSearchView != null && mSearchView.getQuery().length() > 0) {
                //                     frag.mSearchView.setQuery(mSearchView.getQuery(), false);
                //                  }
                view.getHandler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        frag.webTask = new WebTask(MainFragment.this);
                        frag.webTask.init(frag.webView, url);
                        frag.webTask.execute();
                        frag.statusView.setText(frag.status);
                    }
                }, 100);
            } else {
                currentUrl = url;
                Log.d("currentUrl 19", currentUrl);
                status = Util.getUrlStatus(url);
                statusView.setText("Opening " + url + "...");
                webTask = new WebTask(MainFragment.this, webView, url, status.toString());
                webTask.execute();
            }
            //               setNavVisibility(false);
            return true;
        }

        //         @Override
        //         public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
        //         }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (container != null) {
                if (showFind) {
                    container.setVisibility(View.VISIBLE);
                    webView.findAllAsync(findBox.getText().toString());
                } else {
                    container.setVisibility(View.INVISIBLE);
                }
            }
            Log.d("onPageFinished", locX + ", " + locY + ", currentUrl=" + currentUrl + ", url=" + url);
            setNavVisibility(false);
            if (!backForward) { //if (zextr != null) {
                // zextr = null;
                jumpTo(locX, locY);
            } else {
                backForward = false;
            }
            //               locX = 0;
            //               locY = 0;
            Log.d("onPageFinished", url);
            /* This call inject JavaScript into the page which just finished loading. */
            //              webView.loadUrl("javascript:window.HTMLOUT.processHTML(" +
            //                    "'<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
        }
    });

    WebSettings settings = webView.getSettings();
    //      webView.setWebViewClient(new WebViewClient());
    //      webView.setWebChromeClient(new WebChromeClient());
    //      webView.addJavascriptInterface(new HtmlSourceViewJavaScriptInterface(), "HTMLOUT");
    settings.setMinimumFontSize(13);
    settings.setJavaScriptEnabled(true);
    settings.setDefaultTextEncodingName("UTF-8");
    settings.setBuiltInZoomControls(true);
    // settings.setSansSerifFontFamily("Tahoma");
    settings.setEnableSmoothTransition(true);

    return v;
}

From source file:singh.amandeep.musicplayer.MusicService.java

/**
 * Creates a shuffled playlist used for party mode
 *//* w ww . ja  v a 2  s  .c  om*/
private boolean makeAutoShuffleList() {
    Cursor cursor = null;
    try {
        cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                new String[] { MediaStore.Audio.Media._ID }, MediaStore.Audio.Media.IS_MUSIC + "=1", null,
                null);
        if (cursor == null || cursor.getCount() == 0) {
            return false;
        }
        final int len = cursor.getCount();
        final long[] list = new long[len];
        for (int i = 0; i < len; i++) {
            cursor.moveToNext();
            list[i] = cursor.getLong(0);
        }
        mAutoShuffleList = list;
        return true;
    } catch (final RuntimeException e) {
        e.printStackTrace();
    } finally {
        if (cursor != null) {
            cursor.close();
            cursor = null;
        }
    }
    return false;
}

From source file:com.afunms.system.manage.equipManager.java

public String execute(String action) {
    // ------------20091029 pm--------------------------------------------
    if (action == null)
        action = "";

    if (action.equals("ready_add"))
        return readyAdd();
    if (action.equals("add"))
        return save();
    if (action.equals("update"))
        return update();
    if (action.equals("list")) {
        DaoInterface dao = new equipDao();
        setTarget("/system/equip_pic/list.jsp");
        return list(dao);
    }//www  .  j a v  a2  s  .c om
    if (action.equals("delete")) {
        boolean result = false;
        String jsp = "/equip.do?action=list";
        String[] id = getParaArrayValue("checkbox");
        UserDao dao = new UserDao();
        try {
            result = dao.delete(id);
            if (result) {
                equipDao userAuditDao = new equipDao();
                try {
                    for (int i = 0; i < id.length; i++) {
                        userAuditDao.deleteById(id[i]);
                    }
                } catch (RuntimeException e) {
                    e.printStackTrace();
                } finally {
                    userAuditDao.close();
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            dao.close();
        }

        return jsp;
    }
    if (action.equals("ready_edit")) {
        return ready_edit();
        // DaoInterface dao = new UserDao();
        // setTarget("/system/user/edit.jsp");
        // return readyEdit(dao);
    }
    if (action.equals("read")) {
        return read();
        // DaoInterface dao = new UserDao();
        // setTarget("/system/user/read.jsp");
        // return readyEdit(dao);
    }

    setErrorCode(ErrorMessage.ACTION_NO_FOUND);
    return null;
}

From source file:org.alfresco.repo.search.impl.lucene.index.IndexInfo.java

/**
 * Get the main reader for committed index data
 * //from   w w  w. j av  a  2 s.c  o  m
 * @return IndexReader
 * @throws IOException
 */
public IndexReader getMainIndexReferenceCountingReadOnlyIndexReader() throws IOException {
    getReadLock();
    try {
        // Check if we need to rebuild the main indexer as it is invalid.
        // (it is shared and quick version check fails)
        if (indexIsShared && !checkVersion()) {
            releaseReadLock();
            getWriteLock();
            try {
                if (mainIndexReader != null) {
                    ((ReferenceCounting) mainIndexReader).setInvalidForReuse();
                }
                mainIndexReader = null;
            } finally {
                getReadLock();
                releaseWriteLock();
            }
        }

        // Build if required
        if (mainIndexReader == null) {
            releaseReadLock();
            getWriteLock();
            try {
                if (mainIndexReader == null) {
                    // Sync with disk image if required
                    doWithFileLock(new LockWork<Object>() {
                        public Object doWork() throws Exception {
                            return null;
                        }

                        public boolean canRetry() {
                            return true;
                        }

                    });
                    mainIndexReader = createMainIndexReader();

                }

            } finally {
                getReadLock();
                releaseWriteLock();
            }
        }
        // Manage reference counting
        mainIndexReader.incRef();
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Main index reader references = "
                    + ((ReferenceCounting) mainIndexReader).getReferenceCount());
        }

        // ALF-10040: Wrap with a one-off CachingIndexReader (with cache disabled) so that LeafScorer behaves and passes through SingleFieldSelectors to the main index readers
        IndexReader reader = ReferenceCountingReadOnlyIndexReaderFactory
                .createReader(MAIN_READER + GUID.generate(), mainIndexReader, false, config);
        ReferenceCounting refCounting = (ReferenceCounting) reader;
        reader.incRef();
        refCounting.setInvalidForReuse();
        return reader;
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw e;
    } finally {
        releaseReadLock();
    }
}

From source file:org.seadva.metadatagen.service.MetadataGenerator.java

@POST
@Path("/oremap")
@Consumes(MediaType.APPLICATION_JSON)//from w ww . ja  va2s .  co  m
@Produces(MediaType.APPLICATION_JSON)
public Response putOreMap(String publicationRequestString, @QueryParam("requestUrl") String requestURL)
        throws JSONException {
    try {
        String messageString = "";
        Document request = Document.parse(publicationRequestString);
        Document content = (Document) request.get("Aggregation");
        if (content == null) {
            messageString += "Missing Aggregation";
        }

        if (messageString.equals("")) {
            // Get organization from profile(s)
            // Add to base document
            String ID = (String) content.get("Identifier");

            // retrieve OREMap
            Document aggregation = (Document) request.get("Aggregation");
            Client client = Client.create();
            WebResource webResource;

            webResource = client.resource(aggregation.get("@id").toString());
            webResource.addFilter(new RedirectFilter());

            ClientResponse response = null;
            try {
                response = webResource.accept("application/json").get(ClientResponse.class);
                if (response.getStatus() != 200) {
                    String message = "Error while retrieving OREMap from Project Space - Response : "
                            + response.getStatus();
                    System.out.println(MetadataGenerator.class.getName() + " - " + message);
                    return Response.status(ClientResponse.Status.BAD_REQUEST).entity(message).build();
                }
            } catch (RuntimeException e) {
                String message = "Error while retrieving OREMap from Project Space - Response : "
                        + e.getMessage();
                System.out.println(MetadataGenerator.class.getName() + " - " + message);
                return Response.status(ClientResponse.Status.BAD_REQUEST).entity(message).build();
            }

            String oreString = response.getEntity(String.class);

            OREMetadataGen oreMetadataGen = new OREMetadataGen();
            if (!oreMetadataGen.hasValidOREMetadata(oreString)) {
                String message = "Error occurred while validating OREMap : " + oreMetadataGen.getErrorMsg();
                System.out.println(MetadataGenerator.class.getName() + " - " + message);
                return Response.status(ClientResponse.Status.BAD_REQUEST).entity(message).build();
            }

            Document oreMapDocument = Document.parse(oreString);
            ObjectId mapId = new ObjectId();
            //oreMapDocument.put("_id", mapId);

            //Update 'actionable' identifiers for map and aggregation:
            //Note these changes retain the tag-style identifier for the aggregation created by the space
            //These changes essentially work like ARKs/ARTs and represent the <aggId> moving from the custodianship of the space <SpaceURL>/<aggId>
            // to that of the CP services <servicesURL>/<aggId>
            String newMapURL = requestURL + "/" + ID + "/oremap";

            //@id of the map in the map
            oreMapDocument.put("@id", newMapURL);

            //@id of describes object (the aggregation)  in map
            ((Document) oreMapDocument.get("describes")).put("@id", newMapURL + "#aggregation");

            ClientResponse postResponse = pdtWebService.path("researchobjects").path("/oremap")
                    .queryParam("objectId", mapId.toString()).accept("application/json")
                    .type("application/json").post(ClientResponse.class, oreMapDocument.toJson().toString());

            if (postResponse.getStatus() == 200 && !oreMetadataGen.getSkipValidation()) {
                return Response.ok(new JSONObject().put("id", mapId).toString()).build();
            } else if (postResponse.getStatus() == 200 && oreMetadataGen.getSkipValidation()) {
                try {
                    return Response.created(new URI(newMapURL)).entity(new JSONObject().put("id", mapId)
                            .put("warning", oreMetadataGen.getErrorMsg()).toString()).build();
                } catch (URISyntaxException e) {
                    System.out.println(MetadataGenerator.class.getName() + ": Error while persisting OREMap : "
                            + e.getMessage());
                    return Response.serverError().build();
                }
            } else {
                System.out.println(MetadataGenerator.class.getName()
                        + ": Error while persisting OREMap in PDT - Response : " + postResponse.getStatus());
                return Response.serverError().build();
            }
        } else {
            System.out.println(MetadataGenerator.class.getName() + ": Bad Request : " + messageString);
            return Response.status(ClientResponse.Status.BAD_REQUEST).entity(messageString).build();
        }
    } catch (Exception e) {
        System.out.println(e.getStackTrace());
        System.out.println(e.getMessage());
        e.printStackTrace();
        return Response.status(ClientResponse.Status.BAD_REQUEST)
                .entity("Exception thrown when persisting OREMap" + e.getMessage()).build();
    }
}

From source file:org.sakaiproject.tool.assessment.facade.AssessmentGradingFacadeQueries.java

public List getTotalScores(final String publishedId, String which, final boolean getSubmittedOnly) {
    try {//  w  w  w. j a v a 2  s.c o  m
        // sectionSet of publishedAssessment is defined as lazy loading in
        // Hibernate OR map, so we need to initialize them. Unfortunately our
        // spring-1.0.2.jar does not support HibernateTemplate.intialize(Object)
        // so we need to do it ourselves
        //PublishedAssessmentData assessment =PersistenceService.getInstance().getPublishedAssessmentFacadeQueries().loadPublishedAssessment(new Long(publishedId));
        //HashSet sectionSet = PersistenceService.getInstance().getPublishedAssessmentFacadeQueries().getSectionSetForAssessment(assessment);
        //assessment.setSectionSet(sectionSet);
        // proceed to get totalScores
        //      Object[] objects = new Object[2];
        //      objects[0] = new Long(publishedId);
        //      objects[1] = new Boolean(true);
        //      Type[] types = new Type[2];
        //      types[0] = Hibernate.LONG;
        //      types[1] = Hibernate.BOOLEAN;

        final HibernateCallback hcb = new HibernateCallback() {
            public Object doInHibernate(Session session) throws HibernateException, SQLException {
                Query q = null;
                if (getSubmittedOnly) {
                    q = session.createQuery("from AssessmentGradingData a where a.publishedAssessmentId=? "
                            + "and a.forGrade=? "
                            + "order by a.agentId ASC, a.finalScore DESC, a.submittedDate DESC");
                    q.setLong(0, Long.parseLong(publishedId));
                    q.setBoolean(1, true);
                } else {
                    q = session.createQuery("from AssessmentGradingData a where a.publishedAssessmentId=? "
                            + "and (a.forGrade=? or (a.forGrade=? and a.status=?)) "
                            + "order by a.agentId ASC, a.finalScore DESC, a.submittedDate DESC");

                    q.setLong(0, Long.parseLong(publishedId));
                    q.setBoolean(1, true);
                    q.setBoolean(2, false);
                    q.setInteger(3, AssessmentGradingData.NO_SUBMISSION.intValue());
                }
                return q.list();
            };
        };
        List list = getHibernateTemplate().executeFind(hcb);

        //      List list = getHibernateTemplate().find(
        //            "from AssessmentGradingData a where a.publishedAssessmentId=? and a.forGrade=? order by agentId ASC, finalScore DESC, submittedDate DESC", 
        //            objects, types);

        // last submission
        if (which.equals(EvaluationModelIfc.LAST_SCORE.toString())) {
            final HibernateCallback hcb2 = new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException, SQLException {
                    Query q = null;
                    if (getSubmittedOnly) {
                        q = session.createQuery("from AssessmentGradingData a where a.publishedAssessmentId=? "
                                + "and a.forGrade=? " + "order by a.agentId ASC, a.submittedDate DESC");
                        q.setLong(0, Long.parseLong(publishedId));
                        q.setBoolean(1, true);
                    } else {
                        q = session.createQuery("from AssessmentGradingData a where a.publishedAssessmentId=? "
                                + "and (a.forGrade=? or (a.forGrade=? and a.status=?)) "
                                + "order by a.agentId ASC, a.submittedDate DESC");
                        q.setLong(0, Long.parseLong(publishedId));
                        q.setBoolean(1, true);
                        q.setBoolean(2, false);
                        q.setInteger(3, AssessmentGradingData.NO_SUBMISSION.intValue());
                    }
                    return q.list();
                };
            };
            list = getHibernateTemplate().executeFind(hcb2);

            //         list = getHibernateTemplate().find(
            //            "from AssessmentGradingData a where a.publishedAssessmentId=? and a.forGrade=? order by agentId ASC, submittedDate DESC", 
            //            objects, types);
        }

        if (which.equals(EvaluationModelIfc.ALL_SCORE.toString())
                || which.equals(EvaluationModelIfc.AVERAGE_SCORE.toString())) {
            return list;
        } else {
            // only take highest or latest
            Iterator items = list.iterator();
            ArrayList newlist = new ArrayList();
            String agentid = null;
            AssessmentGradingData data = (AssessmentGradingData) items.next();
            // daisyf add the following line on 12/15/04
            data.setPublishedAssessmentId(Long.valueOf(publishedId));
            agentid = data.getAgentId();
            newlist.add(data);
            while (items.hasNext()) {
                while (items.hasNext()) {
                    data = (AssessmentGradingData) items.next();
                    if (!data.getAgentId().equals(agentid)) {
                        agentid = data.getAgentId();
                        newlist.add(data);
                        break;
                    }
                }
            }
            return newlist;
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
        return new ArrayList();
    }
}

From source file:com.almalence.opencam.ApplicationScreen.java

protected void onCameraConfigured() {
    ApplicationScreen.getPluginManager().setupCameraParameters();

    if (!CameraController.isRemoteCamera()) {
        if (!CameraController.isUseCamera2()) {
            Camera.Parameters cp = CameraController.getCameraParameters();
            try {
                // Nexus 5 is giving preview which is too dark without this
                if (CameraController.isNexus5) {
                    cp.setPreviewFpsRange(7000, 30000);
                    CameraController.setCameraParameters(cp);
                    cp = CameraController.getCameraParameters();
                }//from   ww  w.  j  a v  a 2s.  com
            } catch (RuntimeException e) {
                Log.d("ApplicationScreen",
                        "ApplicationScreen.onCameraConfigured() unable to setParameters " + e.getMessage());
            }

            if (cp != null) {
                SharedPreferences prefs = PreferenceManager
                        .getDefaultSharedPreferences(ApplicationScreen.getMainContext());
                int antibanding = Integer.parseInt(prefs.getString(ApplicationScreen.sAntibandingPref, "3"));
                switch (antibanding) {
                case 0:
                    cp.setAntibanding("off");
                    break;
                case 1:
                    cp.setAntibanding("50hz");
                    break;
                case 2:
                    cp.setAntibanding("60hz");
                    break;
                case 3:
                    cp.setAntibanding("auto");
                    break;
                default:
                    cp.setAntibanding("auto");
                    break;
                }
                CameraController.setCameraParameters(cp);

                previewWidth = cp.getPreviewSize().width;
                previewHeight = cp.getPreviewSize().height;
            }
        }

        try {
            Util.initialize(mainContext);
            Util.initializeMeteringMatrix();
        } catch (Exception e) {
            Log.e("Main setup camera", "Util.initialize failed!");
        }

        prepareMeteringAreas();

        if (!CameraController.isUseCamera2()) {
            guiManager.onCameraCreate();
            ApplicationScreen.getPluginManager().onCameraParametersSetup();
            guiManager.onPluginsInitialized();
        }
    } else {
        guiManager.onCameraCreate();
        ApplicationScreen.getPluginManager().onCameraParametersSetup();
        guiManager.onPluginsInitialized();
    }

    // ----- Start preview and setup frame buffer if needed

    // call camera release sequence from onPause somewhere ???
    new CountDownTimer(10, 10) {
        @Override
        public void onFinish() {
            if (!CameraController.isRemoteCamera()) {
                if (!CameraController.isUseCamera2()) {
                    if (!CameraController.isCameraCreated())
                        return;
                    // exceptions sometimes happen here when resuming after
                    // processing
                    try {
                        CameraController.startCameraPreview();
                    } catch (RuntimeException e) {
                        e.printStackTrace();
                        Toast.makeText(ApplicationScreen.instance, "Unable to start camera", Toast.LENGTH_LONG)
                                .show();
                        return;
                    }

                    CameraController.setPreviewCallbackWithBuffer();
                } else {
                    guiManager.onCameraCreate();
                    ApplicationScreen.getPluginManager().onCameraParametersSetup();
                    guiManager.onPluginsInitialized();
                }
            } else {
                guiManager.onCameraCreate();
                ApplicationScreen.getPluginManager().onCameraParametersSetup();
                guiManager.onPluginsInitialized();
            }

            ApplicationScreen.getPluginManager().onCameraSetup();
            guiManager.onCameraSetup();
            ApplicationScreen.mApplicationStarted = true;

            if (ApplicationScreen.isForceClose)
                ApplicationScreen.getPluginManager().sendMessage(ApplicationInterface.MSG_APPLICATION_STOP, 0);
        }

        @Override
        public void onTick(long millisUntilFinished) {
            // Not used
        }
    }.start();
}

From source file:com.afunms.system.manage.UserManager.java

public String execute(String action) {
    // ------------20091029 pm--------------------------------------------
    if (action == null)
        action = "";
    if (action.equals("setReceiver")) {
        return setReceiver();
    }//from  w  w w  .  ja va2s  .  co m
    if (action.equals("ready_add"))
        return readyAdd();
    if (action.equals("add"))
        return save();
    if (action.equals("update"))
        return update();
    if (action.equals("setdbmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            DBVo vo = new DBVo();
            DBDao dbdao = new DBDao();
            vo = (DBVo) dbdao.findByID(id);
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setdbphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            DBVo vo = new DBVo();
            DBDao dbdao = new DBDao();
            vo = (DBVo) dbdao.findByID(id);
            String userphone = vo.getSendphone();
            if (userphone != null && userphone.trim().length() > 0) {
                String mobiles[] = userphone.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }
    if (action.equals("setwebmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WebConfig vo = new WebConfig();
            WebConfigDao webdao = new WebConfigDao();
            vo = (WebConfig) webdao.findByID(id);
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setwebphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WebConfig vo = new WebConfig();
            WebConfigDao webdao = new WebConfigDao();
            vo = (WebConfig) webdao.findByID(id);
            String userphone = vo.getSendphone();
            if (userphone != null && userphone.trim().length() > 0) {
                String mobiles[] = userphone.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }
    if (action.equals("setmqmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            MQConfig vo = new MQConfig();
            MQConfigDao mqdao = new MQConfigDao();
            vo = (MQConfig) mqdao.findByID(id);
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setmqemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            MQConfig vo = new MQConfig();
            MQConfigDao mqdao = new MQConfigDao();
            vo = (MQConfig) mqdao.findByID(id);
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }
    if (action.equals("setdbphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            MQConfig vo = new MQConfig();
            MQConfigDao mqdao = new MQConfigDao();
            vo = (MQConfig) mqdao.findByID(id);
            String userphone = vo.getSendphone();
            if (userphone != null && userphone.trim().length() > 0) {
                String mobiles[] = userphone.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }
    if (action.equals("setwebemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WebConfig vo = new WebConfig();
            WebConfigDao webdao = new WebConfigDao();
            vo = (WebConfig) webdao.findByID(id);
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }
    if (action.equals("setwebphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WebConfig vo = new WebConfig();
            WebConfigDao webdao = new WebConfigDao();
            vo = (WebConfig) webdao.findByID(id);
            String useremails = vo.getSendphone();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }
    if (action.equals("setdbemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            DBVo vo = new DBVo();
            DBDao dbdao = new DBDao();
            vo = (DBVo) dbdao.findByID(id);
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }
    if (action.equals("list")) {
        DaoInterface dao = new UserDao();
        setTarget("/system/user/list.jsp");
        return list(dao);
    }
    if (action.equals("delete")) {
        boolean result = false;
        String jsp = "/user.do?action=list";
        String[] id = getParaArrayValue("checkbox");
        UserDao dao = new UserDao();
        try {
            result = dao.delete(id);
            if (result) {
                UserAuditDao userAuditDao = new UserAuditDao();
                try {
                    for (int i = 0; i < id.length; i++) {
                        userAuditDao.deleteByUserId(id[i]);
                    }
                } catch (RuntimeException e) {
                    e.printStackTrace();
                } finally {
                    userAuditDao.close();
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            dao.close();
        }

        return jsp;
    }
    if (action.equals("ready_edit")) {
        return ready_edit();
        // DaoInterface dao = new UserDao();
        // setTarget("/system/user/edit.jsp");
        // return readyEdit(dao);
    }
    if (action.equals("read")) {
        return read();
        // DaoInterface dao = new UserDao();
        // setTarget("/system/user/read.jsp");
        // return readyEdit(dao);
    }
    if (action.equals("login"))
        return login();
    if (action.equals("home"))
        return home();
    if (action.equals("personhome"))
        return personhome();
    if (action.equals("testJQury"))
        return testJQury();
    if (action.equals("logout"))
        return logout();
    if (action.equals("setdominomobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            DominoConfig vo = new DominoConfig();
            DominoConfigDao dominodao = new DominoConfigDao();
            vo = (DominoConfig) dominodao.findByID(id);
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setdominoemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            DominoConfig vo = new DominoConfig();
            DominoConfigDao dominodao = new DominoConfigDao();
            vo = (DominoConfig) dominodao.findByID(id);
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }
    if (action.equals("setdominophone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            DominoConfig vo = new DominoConfig();
            DominoConfigDao dominodao = new DominoConfigDao();
            vo = (DominoConfig) dominodao.findByID(id);
            String useremails = vo.getSendphone();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }
    // IIS,,
    if (action.equals("setiismobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            IISConfig vo = new IISConfig();
            IISConfigDao iisdao = new IISConfigDao();
            try {
                vo = (IISConfig) iisdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                iisdao.close();
            }
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setiisemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            IISConfig vo = new IISConfig();
            IISConfigDao iisdao = new IISConfigDao();
            try {
                vo = (IISConfig) iisdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                iisdao.close();
            }
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }
    if (action.equals("setiisphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            IISConfig vo = new IISConfig();
            IISConfigDao iisdao = new IISConfigDao();
            try {
                vo = (IISConfig) iisdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                iisdao.close();
            }
            String useremails = vo.getSendphone();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }

    if (action.equals("setweblogicmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WeblogicConfig vo = new WeblogicConfig();
            WeblogicConfigDao weblogicdao = new WeblogicConfigDao();
            vo = (WeblogicConfig) weblogicdao.findByID(id);
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setweblogicemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WeblogicConfig vo = new WeblogicConfig();
            WeblogicConfigDao weblogicdao = new WeblogicConfigDao();
            vo = (WeblogicConfig) weblogicdao.findByID(id);
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }

    if (action.equals("setweblogicphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WeblogicConfig vo = new WeblogicConfig();
            WeblogicConfigDao weblogicdao = new WeblogicConfigDao();
            vo = (WeblogicConfig) weblogicdao.findByID(id);
            String userphones = vo.getSendphone();
            if (userphones != null && userphones.trim().length() > 0 && !"null".equalsIgnoreCase(userphones)) {
                String email[] = userphones.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }

    if (action.equals("settomcatmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            Tomcat vo = new Tomcat();
            TomcatDao tomcatdao = new TomcatDao();
            vo = (Tomcat) tomcatdao.findByID(id);
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0
                    && !"null".equalsIgnoreCase(usermobiles)) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("settomcatemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            Tomcat vo = new Tomcat();
            TomcatDao weblogicdao = new TomcatDao();
            vo = (Tomcat) weblogicdao.findByID(id);
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0 && !"null".equalsIgnoreCase(useremails)) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }
    if (action.equals("settomcatphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            Tomcat vo = new Tomcat();
            TomcatDao tomcatdao = new TomcatDao();
            vo = (Tomcat) tomcatdao.findByID(id);
            String userphone = vo.getSendphone();
            if (userphone != null && userphone.trim().length() > 0 && !"null".equalsIgnoreCase(userphone)) {
                String phones[] = userphone.split(",");
                if (phones != null && phones.length > 0) {
                    for (int i = 0; i < phones.length; i++) {
                        ids.add(Integer.parseInt(phones[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }
    // SOCKET
    if (action.equals("setsocketmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            PSTypeVo vo = new PSTypeVo();
            PSTypeDao socketdao = new PSTypeDao();
            try {
                vo = (PSTypeVo) socketdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                socketdao.close();
            }
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0
                    && !"null".equalsIgnoreCase(usermobiles)) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setsocketemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            PSTypeVo vo = new PSTypeVo();
            PSTypeDao socketdao = new PSTypeDao();
            try {
                vo = (PSTypeVo) socketdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                socketdao.close();
            }
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0 && !"null".equalsIgnoreCase(useremails)) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }
    if (action.equals("setsocketphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            PSTypeVo vo = new PSTypeVo();
            PSTypeDao socketdao = new PSTypeDao();
            try {
                vo = (PSTypeVo) socketdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                socketdao.close();
            }
            String userphone = vo.getSendphone();
            if (userphone != null && userphone.trim().length() > 0 && !"null".equalsIgnoreCase(userphone)) {
                String phones[] = userphone.split(",");
                if (phones != null && phones.length > 0) {
                    for (int i = 0; i < phones.length; i++) {
                        ids.add(Integer.parseInt(phones[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setphone.jsp";
    }

    if (action.equals("setwasmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WasConfig vo = new WasConfig();
            WasConfigDao wasdao = null;
            try {
                wasdao = new WasConfigDao();
                vo = (WasConfig) wasdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (wasdao != null) {
                    wasdao.close();
                }
            }
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setwasemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            WasConfig vo = new WasConfig();
            WasConfigDao wasdao = null;
            try {
                wasdao = new WasConfigDao();
                vo = (WasConfig) wasdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (wasdao != null) {
                    wasdao.close();
                }
            }
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }

    if (action.equals("setnetmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            HostNode vo = new HostNode();
            HostNodeDao hostdao = new HostNodeDao();
            try {
                vo = (HostNode) hostdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                hostdao.close();
            }
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        if (mobiles[i].equalsIgnoreCase("null"))
                            continue;
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setnetemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            HostNode vo = new HostNode();
            HostNodeDao hostdao = new HostNodeDao();
            try {
                vo = (HostNode) hostdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                hostdao.close();
            }
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        if (email[i].equalsIgnoreCase("null"))
                            continue;
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }
    if (action.equals("setnetphone")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            HostNode vo = new HostNode();
            HostNodeDao hostdao = new HostNodeDao();
            try {
                vo = (HostNode) hostdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                hostdao.close();
            }
            String userphone = vo.getSendphone();
            if (userphone != null && userphone.trim().length() > 0) {
                String phone[] = userphone.split(",");
                if (phone != null && phone.length > 0) {
                    for (int i = 0; i < phone.length; i++) {
                        if (phone[i].equalsIgnoreCase("null"))
                            continue;
                        ids.add(Integer.parseInt(phone[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setnetphone.jsp";
    }

    if (action.equals("setgrapesmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            GrapesConfig vo = new GrapesConfig();
            GrapesConfigDao grapesdao = new GrapesConfigDao();
            try {
                vo = (GrapesConfig) grapesdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                grapesdao.close();
            }
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }
    if (action.equals("setgrapesemail")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            GrapesConfig vo = new GrapesConfig();
            GrapesConfigDao grapesdao = new GrapesConfigDao();
            try {
                vo = (GrapesConfig) grapesdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                grapesdao.close();
            }
            String useremails = vo.getSendemail();
            if (useremails != null && useremails.trim().length() > 0) {
                String email[] = useremails.split(",");
                if (email != null && email.length > 0) {
                    for (int i = 0; i < email.length; i++) {
                        ids.add(Integer.parseInt(email[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setemail.jsp";
    }

    if (action.equals("setnetsmsmobiles")) {
        DaoInterface dao = new UserDao();
        List list = dao.loadAll();
        request.setAttribute("list", list);
        String id = request.getParameter("id");
        Vector ids = new Vector();
        if (id != null && id.length() > 0) {
            HostNode vo = new HostNode();
            HostNodeDao hostdao = new HostNodeDao();
            try {
                vo = (HostNode) hostdao.findByID(id);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                hostdao.close();
            }
            String usermobiles = vo.getSendmobiles();
            if (usermobiles != null && usermobiles.trim().length() > 0) {
                String mobiles[] = usermobiles.split(",");
                if (mobiles != null && mobiles.length > 0) {
                    for (int i = 0; i < mobiles.length; i++) {
                        if (mobiles[i].equalsIgnoreCase("null"))
                            continue;
                        ids.add(Integer.parseInt(mobiles[i]));
                    }
                }
            }
        }
        request.setAttribute("ids", ids);
        return "/system/user/setmobiles.jsp";
    }

    setErrorCode(ErrorMessage.ACTION_NO_FOUND);
    return null;
}

From source file:com.ah.ui.actions.hiveap.HiveApUpdateAction.java

private void logUpdateOperation() {
    try {//from  w ww. j av  a  2  s.c o  m
        if (null != updateHiveAps && updateHiveAps.size() > 0) {
            String label = "";
            if ("uploadWizard".equals(operation)) {
                label = "Configuration";
            } else if ("uploadImage".equals(operation)) {
                label = "Image";
            } else if ("updateBootstrap".equals(operation)) {
                label = "Bootstrap";
            } else if ("updateCountryCode".equals(operation)) {
                label = "Country Code";
            } else if ("updatePoe".equals(operation)) {
                label = "PoE Max Power";
            } else if ("updateOutdoorSettings".equals(operation)) {
                label = "Outdoor Settings";
            } else if ("uploadOsDetection".equals(operation)) {
                label = "Os Detection";
            } else if ("uploadSignature".equals(operation)) {
                label = "Application Signature";
            }
            if (!"".equals(label)) {
                if (updateHiveAps.size() > 50) {
                    // just combine into one audit log
                    generateAuditLog(HmAuditLog.STATUS_EXECUTE,
                            updateHiveAps.size() + " " + NmsUtil.getOEMCustomer().getAccessPonitName() + "s "
                                    + MgrUtil.getUserMessage("hm.audit.log.hiveap.update") + " " + label + ".");
                } else {
                    for (UpdateHiveAp hiveAp : updateHiveAps) {
                        generateAuditLog(HmAuditLog.STATUS_EXECUTE,
                                NmsUtil.getOEMCustomer().getAccessPonitName() + " "
                                        + hiveAp.getHiveAp().getHostName() + " "
                                        + MgrUtil.getUserMessage("hm.audit.log.hiveap.update") + " " + label
                                        + ".");
                    }
                }
            }
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
}