Example usage for java.lang IllegalAccessException IllegalAccessException

List of usage examples for java.lang IllegalAccessException IllegalAccessException

Introduction

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

Prototype

public IllegalAccessException(String s) 

Source Link

Document

Constructs an IllegalAccessException with a detail message.

Usage

From source file:com.baidu.rigel.biplatform.ac.util.DataModelUtils.java

/**
 * DataModel??/*ww w.  j av a 2 s  .  c  o m*/
 * 
 * @param dataModel DataModel
 * @throws IllegalAccessException 
 */
private static void buildSortSummary(DataModel dataModel) throws IllegalAccessException {
    List<HeadField> rowLeafs = getLeafNodeList(dataModel.getRowHeadFields());
    if (CollectionUtils.isNotEmpty(rowLeafs)) {
        if (dataModel.getOperateIndex() > rowLeafs.get(0).getCompareDatas().size()) {
            throw new IllegalAccessException("can not access operate index:" + dataModel.getOperateIndex());
        }
        for (HeadField rowHeadField : dataModel.getRowHeadFields()) {
            List<HeadField> leafFileds = rowHeadField.getLeafFileds(true);
            if (CollectionUtils.isNotEmpty(leafFileds)) {

                Queue<HeadField> queue = new LinkedList<HeadField>(leafFileds);
                while (!queue.isEmpty()) {
                    HeadField leafFiled = queue.remove();
                    if (CollectionUtils.isNotEmpty(leafFiled.getCompareDatas())) {
                        leafFiled
                                .setSummarizeData(leafFiled.getCompareDatas().get(dataModel.getOperateIndex()));
                    }
                    HeadField parent = null;
                    if (leafFiled.getParent() != null) {
                        parent = leafFiled.getParent();
                    } else if (leafFiled.getParentLevelField() != null) {
                        parent = leafFiled.getParentLevelField();
                        if (!queue.contains(parent)) {
                            queue.add(parent);
                        }
                    }

                    if (parent != null && CollectionUtils.isEmpty(parent.getCompareDatas())) {
                        parent.setSummarizeData(BigDecimalUtils.addBigDecimal(parent.getSummarizeData(),
                                leafFiled.getSummarizeData()));
                    }
                }
            }

        }
    }
}

From source file:org.mycontroller.standalone.utils.McScriptFileUtils.java

public static McScript getScriptFile(String scriptFile)
        throws IOException, IllegalAccessException, McBadRequestException {
    String scriptsFileLocation = McUtils.getDirectoryLocation(
            FileUtils.getFile(AppProperties.getInstance().getScriptsLocation()).getCanonicalPath());
    String fileFullPath = scriptsFileLocation + scriptFile;
    if (McUtils.isInScope(scriptsFileLocation, fileFullPath)) {
        if (!FileUtils.getFile(fileFullPath).exists()) {
            throw new McBadRequestException("File not found! " + fileFullPath);
        }/*ww  w . j a v  a  2 s.  c o m*/
        File fileScript = FileUtils.getFile(fileFullPath);

        McScript mcScript = McScript.builder()
                .extension(FilenameUtils.getExtension(fileScript.getCanonicalPath())).size(fileScript.length())
                .lastModified(fileScript.lastModified())
                .data(FileUtils.readFileToString(fileScript, StandardCharsets.UTF_8))
                .canonicalPath(fileScript.getCanonicalPath()).build();

        String name = fileScript.getCanonicalPath().replace(scriptsFileLocation, "");
        SCRIPT_TYPE type = null;
        if (name.startsWith(AppProperties.CONDITIONS_SCRIPTS_DIRECTORY)) {
            type = SCRIPT_TYPE.CONDITION;
        } else {
            type = SCRIPT_TYPE.OPERATION;
        }
        mcScript.setType(type);
        name = name.replace(AppProperties.CONDITIONS_SCRIPTS_DIRECTORY, "")
                .replace(AppProperties.OPERATIONS_SCRIPTS_DIRECTORY, "");
        mcScript.setName(FilenameUtils.getBaseName(name));
        return mcScript;
    } else {
        _logger.warn("Trying to get file from outside scope! Filepath:{}, CanonicalPath:{}", fileFullPath,
                FileUtils.getFile(fileFullPath).getCanonicalPath());
        throw new IllegalAccessException("Trying to get file from outside scope!");
    }
}

From source file:org.cloudgraph.hbase.mutation.DefaultMutation.java

protected void validateModifications(DataGraph dataGraph, PlasmaDataObject dataObject, RowWriter rowWriter)
        throws IllegalAccessException {
    PlasmaType type = (PlasmaType) dataObject.getType();
    if (log.isDebugEnabled())
        log.debug(//from   w  w w. ja va2s .  co  m
                "updating " + type.getName() + " '" + ((PlasmaDataObject) dataObject).getUUIDAsString() + "'");
    PlasmaType rootType = (PlasmaType) rowWriter.getRootDataObject().getType();
    DataGraphMapping dataGraphConfig = StoreMapping.getInstance().getDataGraph(rootType.getQualifiedName());

    List<Property> properties = type.getProperties();
    for (Property p : properties) {
        PlasmaProperty property = (PlasmaProperty) p;

        Object oldValue = dataGraph.getChangeSummary().getOldValue(dataObject, property);
        if (oldValue == null)
            continue; // it's not been modified

        if (property.isReadOnly())
            throw new IllegalAccessException("attempt to modify read-only property, " + type.getURI() + "#"
                    + type.getName() + "." + property.getName());

        DataRowKeyFieldMapping userDefinedField = dataGraphConfig.findUserDefinedRowKeyField(property);
        if (userDefinedField != null) {
            throw new IllegalAccessException("attempt to modify row-key property, " + type.getURI() + "#"
                    + type.getName() + "." + property.getName()
                    + " - this property is configured as a row-key field for table '"
                    + dataGraphConfig.getTable().getName() + "'");
        }
        // FIXME: what if an entire entity is deleted which is part
        // of the row key. Detect this. Or added for that matter.
    }
}

From source file:org.neo4art.importer.wikipedia.core.listener.WikipediaCVSFilesBatchImporterListener.java

/**
 * @see org.neo4art.importer.wikipedia.core.listener.WikipediaAbstractImporterListener#persist(org.neo4art.importer.wikipedia.domain.WikipediaElement)
 *//*ww  w . j  av  a 2s.  c o  m*/
@Override
protected long persist(WikipediaElement wikipediaElement) {

    throw new RuntimeException(new IllegalAccessException(
            "Method not allowed in this implementation. Use 'persistNodes' and 'persistRepationships' instead."));
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetterUtils.java

private static String chooseType(List<String> types, String dataGetterURI) throws IllegalAccessException {
    //currently just get the first one that is not owl:Thing
    for (String type : types) {
        if (!StringUtils.isEmpty(type) && !type.equals(OWL.Thing.getURI()))
            return type;
    }//from  w w  w  .j a va2 s  . c  om
    throw new IllegalAccessException("No useful type defined for <" + dataGetterURI + ">");
}

From source file:uk.ac.ucl.excites.sapelli.collector.transmission.protocol.geokey.AndroidGeoKeyClient.java

/**
 * @param modelID//  www  . java  2  s .com
 * @return a {@link ProjectSession} instance, or {@code null} if the user is not or no longer logged in
 * @throws UnknownModelException when the server has no matching Sapelli project to which the logged-in user has contribution access
 * @throws IllegalAccessException when the user does not have access to the project in question
 */
@Override
protected ProjectSession getModelSession(long modelID) throws UnknownModelException, IllegalAccessException {
    Project project = app.collectorClient.getProject(modelID);
    if (project == null) {
        Log.e(TAG, "Cannot open ProjectSession because no Project was found for the given Model.");
        return null;
    }

    if (server == null)
        return null;
    JSONObject token = getUserToken(false,
            server.hasUserCredentials() ? "Cannot open ProjectSession because user is not logged in." : null);
    if (token == null && server.hasUserCredentials())
        return null;

    // Request project description:
    ResponseHandler handler = getWithJSONResponse(getAbsoluteUrl(server, PATH_API_GEOKEY_SAPELLI
            + "projects/description/" + project.getID() + "/" + project.getFingerPrint() + "/"),
            getNewHeaders(token), null);
    if (checkResponseObject(handler, JSON_KEY_GEOKEY_PROJECT_ID)) {
        //Log.d(TAG, "ProjectInfo: " + handler.getResponseObject().toString());
        return new ProjectSession(project, handler.getResponseObject(), token);
    } else {
        if (handler.hasResponseObject() && JSON_VALUE_ERROR_NO_SUCH_PROJECT
                .equalsIgnoreCase(handler.getResponseObject().optString(JSON_KEY_ERROR)))
            throw new UnknownModelException(project.getModel().id, project.getModel().name);
        else if (handler.hasResponseObject() && JSON_VALUE_ERROR_PROJECT_ACCESS_DENIED
                .equalsIgnoreCase(handler.getResponseObject().optString(JSON_KEY_ERROR)))
            throw new IllegalAccessException(JSON_VALUE_ERROR_PROJECT_ACCESS_DENIED);
        else {
            logError(handler, "Could not get project description");
            return null;
        }
    }
}

From source file:com.oneops.cms.dj.service.CmsDpmtProcessor.java

private void checkIfAthorized(String approvalToken, long approvalId)
        throws IllegalAccessException, GeneralSecurityException {
    if (cmsCrypto != null) {
        CmsDpmtApproval approval = dpmtMapper.getDpmtApproval(approvalId);
        CmsCI support = cmProcessor.getCiById(approval.getGovernCiId());
        CmsCIAttribute approvalTokenAttribute = support.getAttribute("approval_token");
        CmsCIAttribute approvalAuthTypeAttribute = support.getAttribute("approval_auth_type");
        if (approvalAuthTypeAttribute != null && approvalTokenAttribute != null
                && "token".equals(support.getAttribute("approval_auth_type").getDfValue())) {
            if (!cmsCrypto.decrypt(approvalTokenAttribute.getDjValue()).equals(approvalToken)) {
                throw new IllegalAccessException("Not authorized to approve this record");
            }/*  www.ja va2s.  c om*/
        }
    }
}

From source file:org.nordapp.web.servlet.SessionCallServlet.java

/**
 * @param req The request/*from w  w  w.  j  a  v a2 s.  c o m*/
 * @param resp The response
 * @param data The data
 * @throws IOException 
 */
private void process(SessionControl ctrl, HttpServletRequest req, HttpServletResponse resp,
        Map<String, Object> data) throws IOException {

    //
    // Session service
    //
    String cert = null;

    //The '0' session of the mandator
    Session mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(), "0");
    Integer baseIndex = ((Integer) mSession.getValue(Session.ENGINE_BASE_INDEX)).intValue();
    //String sessionId = session.getId();

    String[] elem = RequestPath.getPath(req, ctrl.getPathStartIndex());
    if (elem.length == 0)
        throw new MalformedURLException("The URL needs the form '" + req.getServletPath()
                + (ctrl.getPathStartIndex() == 0 ? "" : "mandator-id/session-id") + "/function-id' but was '"
                + req.getRequestURI() + "'");

    BigInteger engineId = ctrl.decodeCert();
    String functionId = elem[0];

    StringBuffer buffer = new StringBuffer();
    List<String> states = new ArrayList<String>();
    ResponseHandler rsHdl = new ResponseHandler(context, ctrl);

    EngineBaseService engineBaseService = null;
    Engine engine = null;
    BigInteger anonId = null;
    boolean anonymous = false;
    try {
        //
        // Gets the engine base service
        //
        engineBaseService = EngineBaseServiceImpl.getService(context, ctrl.getMandatorID(),
                String.valueOf(baseIndex));
        if (engineBaseService == null)
            throw new IOException(
                    "The mandator base service is not available (maybe down or a version conflict).");

        //
        // Run the step
        //
        Mandator mandator = MandatorServiceImpl.getMandator(context, ctrl.getMandatorID());
        if (mandator == null)
            throw new IOException("The mandator service is not available (maybe down or a version conflict).");

        //
        // getEngine() creates one, if there is no engine.
        //

        Map<String, Object> params = new HashMap<String, Object>();
        params.put(EngineBaseService.IS_AVAILABLE, Boolean.TRUE);
        params.put(EngineBaseService.IS_LOGIN, Boolean.TRUE);
        engine = engineBaseService.queryEngine(engineId, params);

        if (engine == null) {

            String key = ctrl.getGroupID() + "." + ctrl.getArtifactID() + ".anonymous-support";
            if (Boolean.valueOf(mandator.getProperty(key)).booleanValue()) {
                key = ctrl.getGroupID() + "." + ctrl.getArtifactID() + ".anonymous-session";
                String val = mandator.getProperty(key);
                anonId = val == null ? BigInteger.ONE : new BigInteger(val);

                //
                // TODO cache this to avoid the initialization each call
                //

                //setup the bundles
                engineBaseService.setupStore(anonId);
                //uses the login-flag to signal the init state
                engine = engineBaseService.getEngine(anonId);
                //cleanup the old state
                if (!engine.hasNext()) {
                    engine.reinit();
                }

                anonymous = true;
            } else
                throw new IllegalAccessException("There is no login to this session (needs login).");

            //engineBaseService.dropEngine(engineId);
        }

        //
        // Set the parameter to the user-session
        //
        if (!anonymous) {
            mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(),
                    ctrl.decodeCert().toString());

            if (mSession != null && data != null && data.size() > 0) {
                for (String key : data.keySet()) {
                    Object value = data.get(key);

                    logger.trace("Set data to session mandatorId:{}, sessionId:{}, key:{}, value:{}",
                            ctrl.getMandatorID(), ctrl.getCertID(), key, value);
                    mSession.setValue(key, value);
                } //for
            } //fi
        }

        try {
            engine.setLocalValue(Mandator.MANDATORID, ctrl.getMandatorID());
            engine.setLocalValue("anonymous", new Boolean(anonymous));
            engine.setLocalValue("sessionId", ctrl.decodeCert().toString());
            engine.setLocalValue("nativeSessionId", ctrl.decodeCert());
            engine.setLocalValue("immediate.result", null);
            engine.setLocalValue("immediate.fields", data == null ? null : Collections.unmodifiableMap(data));
            engine.setLocalValue("immediate.states", states);

            engine.call(functionId);
        } catch (Exception e) {
            e.printStackTrace();
        }

        Object val = engine.getLocalValue("immediate.result");
        if (val != null) {
            logger.trace("immediate.results:{}", val);
            //Gson gson = new Gson();
            buffer.append(String.valueOf(val));
        }

    } catch (Exception e) {
        logger.error("Error running the step.", e);
    } finally {

        if (anonymous) {

            //
            // TODO cache this to avoid the initialization each call
            //

            engine.exit();
            try {
                engineBaseService.dropEngine(anonId);
            } catch (Exception e) {
                logger.error("Error running the step.", e);
            }
        } //fi
    }

    //
    //
    //
    byte[] bytes = buffer.toString().getBytes();

    //
    // Set RESTful states to HTTP links
    //

    LinkHeader lhdr = new LinkHeaderImpl();
    if (ctrl.isStateful()) {
        StateUtil.setDefault(lhdr, req);

        lhdr.setLink_mandator(ctrl.getMandatorID());
        lhdr.setLink_uuid(ctrl.getCertID());

        for (String state : states) {
            if (state == null)
                continue;
            int k = state.trim().lastIndexOf(' ');
            if (k < 1 || k == (state.length() - 1))
                continue;
            lhdr.add(state.substring(0, k), state.substring(k + 1));
        }
        //StateUtil.setState(context, ctrl, lhdr, "init.state");
        logger.debug(lhdr.toString());
    }
    rsHdl.setLinkHeader(resp, lhdr.toString());

    //
    // Send the resource
    //
    rsHdl.avoidCaching(resp);
    rsHdl.sendData(bytes, resp);

}

From source file:org.infoscoop.service.SiteAggregationMenuService.java

private Element getTargetElement(Element sitetopEl, String workingUid, String targetMenuId,
        boolean ignoreSiteTop) throws Exception {
    if (sitetopEl == null)
        return null;

    ISPrincipal p = SecurityController.getPrincipalByType("UIDPrincipal");
    String myUid = p.getName();/* ww w. j  a v a 2  s  .c om*/

    Document document = sitetopEl.getOwnerDocument();
    Node node = null;
    node = AdminServiceUtil.getNodeById(document, "//site", targetMenuId);

    String siteTopId = sitetopEl.getAttribute("id");
    if (!ignoreSiteTop && node == null) {
        node = (siteTopId.equals(targetMenuId)) ? sitetopEl : null;
    }

    if (node == null)
        return null;

    if (workingUid != null && !workingUid.equals(myUid)) {
        // If other user has edit control
        workingUid = getUserName(workingUid);
        throw new IllegalAccessException("The user \"" + workingUid + "\" is editing it.");
    }

    // If the user is not tree administrator
    boolean isMenuTreeRoleUser = PortalAdminsService.getHandle().isMenuTreeRoleUser();
    if (isMenuTreeRoleUser && !isMyRoleTree(siteToJSON(siteTopId, sitetopEl, false), myUid)) {
        String siteTopTitle = sitetopEl.getAttribute("title");
        throw new IllegalAccessException("The edit has not been permitted.[" + siteTopTitle + "]");
    }

    return (Element) node;
}

From source file:org.reusables.dbunit.DbUnitDatasetExecutionListener.java

/**
 * Load the testdata from the given inputstream.
 * //from  w  ww.  j  a  va 2 s  .com
 * @param task Task for handling the DbUnit operation.
 * @param testContext The context for the current test.
 * @param connectionType Type indicating how to obtain a connection.
 * @throws Exception On any error.
 */
protected void handleOperation(final JdbcTask task, final TestContext testContext,
        final ConnectionType connectionType) throws Exception {
    switch (connectionType) {
    case HIBERNATE_ENTITY_MANAGER:
        if (!new HibernateEntityManagerOperationHandler(testContext).handleOperation(task)) {
            throw new IllegalAccessException("Invalid connectionType: " + connectionType);
        }
        break;
    case HIBERNATE_SESSION_FACTORY:
        if (!new HibernateSessionFactoryOperationHandler(testContext).handleOperation(task)) {
            throw new IllegalAccessException("Invalid connectionType: " + connectionType);
        }
        break;
    case DATA_SOURCE:
        if (!new DataSourceOperationHandler(testContext).handleOperation(task)) {
            throw new IllegalAccessException("Invalid connectionType: " + connectionType);
        }
        break;
    case AUTO:
        if (!(new HibernateEntityManagerOperationHandler(testContext).handleOperation(task)
                || new HibernateSessionFactoryOperationHandler(testContext).handleOperation(task)
                || new DataSourceOperationHandler(testContext).handleOperation(task))) {
            throw new IllegalArgumentException("Unable to execute operation, no handler available.");
        }
        break;
    }
}