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:org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration.java

public static SentryPolicyServiceClient getSentryClient() throws Exception {
    if (sentryServer == null) {
        throw new IllegalAccessException("Sentry service not initialized");
    }/*from   w  w  w. j av a 2s. c  o m*/
    return SentryServiceClientFactory.create(sentryServer.get(0).getConf());
}

From source file:com.webobjects.monitor.wotaskd.Application.java

/**
 * ============================================================================================
 *                  Methods Added for Enabling JMX in Wotaskd
 * ============================================================================================
 * This methods returns the platform MBean Server from the Factory
 * @return _mbeanServer  - The platform MBeanServer 
 *///from  w w w .  j  a va2  s. co  m
@Override
public MBeanServer getMBeanServer() throws IllegalAccessException {
    if (_mbeanServer == null) {
        _mbeanServer = ManagementFactory.getPlatformMBeanServer();
        if (_mbeanServer == null)
            throw new IllegalAccessException(
                    "Error: PlatformMBeanServer could not be accessed via ManagementFactory.");
    }
    return _mbeanServer;
}

From source file:org.cloudgraph.rdb.service.GraphDispatcher.java

private void update(DataGraph dataGraph, PlasmaDataObject dataObject)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SQLException {

    PlasmaType type = (PlasmaType) dataObject.getType();
    if (log.isDebugEnabled())
        log.debug(//from www . j ava  2 s  . co m
                "updating " + type.getName() + " '" + ((PlasmaDataObject) dataObject).getUUIDAsString() + "'");

    List<Property> pkList = type.findProperties(KeyType.primary);
    if (pkList == null || pkList.size() == 0)
        throw new DataAccessException(
                "no pri-key properties found for type '" + dataObject.getType().getName() + "'");

    List<PropertyPair> pkPairs = new ArrayList<PropertyPair>();
    for (Property pkp : pkList) {
        PlasmaProperty pkProperty = (PlasmaProperty) pkp;
        Object pk = dataObject.get(pkProperty);
        if (pk == null)
            throw new DataAccessException("found null primary key property '" + pkProperty.getName()
                    + "' for type, " + type.getURI() + "#" + type.getName());
        Setting setting = dataGraph.getChangeSummary().getOldValue(dataObject, pkProperty);
        if (setting != null) { // it's been modified
            // pk has been modified, yet we need it to lookup record, use
            // the old value
            if (!pkProperty.isReadOnly()) {
                Object oldPk = setting.getValue();
                PropertyPair pair = this.createValue(dataObject, pk, oldPk, pkProperty);
                pkPairs.add(pair);
            } else
                throw new IllegalAccessException("attempt to modify read-only property, " + type.getURI() + "#"
                        + type.getName() + "." + pkProperty.getName());
        } else {
            PropertyPair pair = this.createValue(dataObject, pk, pkProperty);
            pkPairs.add(pair);
        }
    }

    // FIXME: get rid of cast - define instance properties in 'base type'
    Timestamp snapshotDate = (Timestamp) ((CoreDataObject) dataObject)
            .getValue(CoreConstants.PROPERTY_NAME_SNAPSHOT_TIMESTAMP);
    if (snapshotDate == null)
        throw new RequiredPropertyException(
                "instance property '" + CoreConstants.PROPERTY_NAME_SNAPSHOT_TIMESTAMP
                        + "' is required to update entity '" + type.getURI() + "#" + type.getName() + "'");
    else if (log.isDebugEnabled())
        log.debug("snapshot date: " + String.valueOf(snapshotDate));
    PlasmaProperty lockingUserProperty = (PlasmaProperty) type.findProperty(ConcurrencyType.pessimistic,
            ConcurrentDataFlavor.user);
    if (lockingUserProperty == null)
        if (log.isDebugEnabled())
            log.debug("could not find locking user property for type, " + type.getURI() + "#" + type.getName());

    PlasmaProperty lockingTimestampProperty = (PlasmaProperty) type.findProperty(ConcurrencyType.pessimistic,
            ConcurrentDataFlavor.time);
    if (lockingTimestampProperty == null)
        if (log.isDebugEnabled())
            log.debug("could not find locking timestamp property for type, " + type.getURI() + "#"
                    + type.getName());

    PlasmaProperty concurrencyUserProperty = (PlasmaProperty) type.findProperty(ConcurrencyType.optimistic,
            ConcurrentDataFlavor.user);
    if (concurrencyUserProperty == null)
        if (log.isDebugEnabled())
            log.debug("could not find optimistic concurrency (username) property for type, " + type.getURI()
                    + "#" + type.getName());

    PlasmaProperty concurrencyTimestampProperty = (PlasmaProperty) type.findProperty(ConcurrencyType.optimistic,
            ConcurrentDataFlavor.time);
    if (concurrencyTimestampProperty == null)
        if (log.isDebugEnabled())
            log.debug("could not find optimistic concurrency timestamp property for type, " + type.getURI()
                    + "#" + type.getName());

    List<Object> params = new ArrayList<Object>();
    StringBuilder select = this.statementFactory.createSelectConcurrent(type, pkPairs, 5, params);
    Map<String, PropertyPair> entity = this.statementExecutor.fetchRowMap(type, select);
    if (entity.size() == 0)
        throw new GraphServiceException("could not lock record of type, " + type.toString());

    // overwrite with original PK pairs as these may contain old/new value
    // info
    for (PropertyPair pair : pkPairs)
        entity.put(pair.getProp().getName(), pair);

    if (concurrencyTimestampProperty != null && concurrencyUserProperty != null)
        checkAndRefreshConcurrencyFields(type, entity, concurrencyTimestampProperty, concurrencyUserProperty,
                snapshotDate);

    if (CoreHelper.isFlaggedLocked(dataObject))
        lock(dataObject, entity, lockingTimestampProperty, lockingUserProperty, snapshotDate);
    else if (CoreHelper.isFlaggedUnlocked(dataObject))
        unlock(dataObject, entity, lockingTimestampProperty, lockingUserProperty, snapshotDate);

    List<Property> properties = type.getProperties();
    for (Property p : properties) {
        PlasmaProperty property = (PlasmaProperty) p;
        if (property.isMany())
            continue; // do/could we invoke a "marshaler" here?
        if (property.isKey(KeyType.primary))
            continue; // handled above

        if (property.getConcurrent() != null)
            continue;

        Object oldValue = dataGraph.getChangeSummary().getOldValue(dataObject, property);
        if (oldValue != null) { // it's been modified
            if (!property.isReadOnly()) {
                Object value = dataObject.get(property);
                if (value != null) {
                    PropertyPair pair = createValue(dataObject, value, property);
                    entity.put(property.getName(), pair);
                }
                // setEntityValue(entity, value, property);
            } else
                throw new IllegalAccessException("attempt to modify read-only property, " + type.getURI() + "#"
                        + type.getName() + "." + property.getName());
        }
    }

    if (this.statementFactory.hasUpdatableProperties(entity)) {
        StringBuilder update = this.statementFactory.createUpdate(type, entity);
        if (log.isDebugEnabled()) {
            log.debug("updating " + dataObject.getType().getName());
        }
        this.statementExecutor.execute(type, update, entity);
    }
}

From source file:org.plasma.sdo.jdbc.service.GraphDispatcher.java

private void update(DataGraph dataGraph, PlasmaDataObject dataObject)
        throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {

    PlasmaType type = (PlasmaType) dataObject.getType();
    if (log.isDebugEnabled())
        log.debug(// ww w  . jav  a 2  s.c  o m
                "updating " + type.getName() + " '" + ((PlasmaDataObject) dataObject).getUUIDAsString() + "'");

    List<Property> pkList = type.findProperties(KeyType.primary);
    if (pkList == null || pkList.size() == 0)
        throw new DataAccessException(
                "no pri-key properties found for type '" + dataObject.getType().getName() + "'");

    List<PropertyPair> pkPairs = new ArrayList<PropertyPair>();
    for (Property pkp : pkList) {
        PlasmaProperty pkProperty = (PlasmaProperty) pkp;
        Object pk = dataObject.get(pkProperty);
        if (pk == null)
            throw new DataAccessException("found null primary key property '" + pkProperty.getName()
                    + "' for type, " + type.getURI() + "#" + type.getName());
        pkPairs.add(new PropertyPair(pkProperty, pk));
    }

    // FIXME: get rid of cast - define instance properties in 'base type'
    Timestamp snapshotDate = (Timestamp) ((CoreDataObject) dataObject)
            .getValue(CoreConstants.PROPERTY_NAME_SNAPSHOT_TIMESTAMP);
    if (snapshotDate == null)
        throw new RequiredPropertyException(
                "instance property '" + CoreConstants.PROPERTY_NAME_SNAPSHOT_TIMESTAMP
                        + "' is required to update entity '" + type.getURI() + "#" + type.getName() + "'");
    else if (log.isDebugEnabled())
        log.debug("snapshot date: " + String.valueOf(snapshotDate));
    PlasmaProperty lockingUserProperty = (PlasmaProperty) type.findProperty(ConcurrencyType.pessimistic,
            ConcurrentDataFlavor.user);
    if (lockingUserProperty == null)
        if (log.isDebugEnabled())
            log.debug("could not find locking user property for type, " + type.getURI() + "#" + type.getName());

    PlasmaProperty lockingTimestampProperty = (PlasmaProperty) type.findProperty(ConcurrencyType.pessimistic,
            ConcurrentDataFlavor.time);
    if (lockingTimestampProperty == null)
        if (log.isDebugEnabled())
            log.debug("could not find locking timestamp property for type, " + type.getURI() + "#"
                    + type.getName());

    PlasmaProperty concurrencyUserProperty = (PlasmaProperty) type.findProperty(ConcurrencyType.optimistic,
            ConcurrentDataFlavor.user);
    if (concurrencyUserProperty == null)
        if (log.isDebugEnabled())
            log.debug("could not find optimistic concurrency (username) property for type, " + type.getURI()
                    + "#" + type.getName());

    PlasmaProperty concurrencyTimestampProperty = (PlasmaProperty) type.findProperty(ConcurrencyType.optimistic,
            ConcurrentDataFlavor.time);
    if (concurrencyTimestampProperty == null)
        if (log.isDebugEnabled())
            log.debug("could not find optimistic concurrency timestamp property for type, " + type.getURI()
                    + "#" + type.getName());

    StringBuilder select = createSelectForUpdate(type, pkPairs, 5);
    Map<String, PropertyPair> entity = fetchRowMap(type, select, con);

    if (concurrencyTimestampProperty != null && concurrencyUserProperty != null)
        checkAndRefreshConcurrencyFields(type, entity, concurrencyTimestampProperty, concurrencyUserProperty,
                snapshotDate);

    if (CoreHelper.isFlaggedLocked(dataObject))
        lock(dataObject, entity, lockingTimestampProperty, lockingUserProperty, snapshotDate);
    else if (CoreHelper.isFlaggedUnlocked(dataObject))
        unlock(dataObject, entity, lockingTimestampProperty, lockingUserProperty, snapshotDate);

    List<Property> properties = type.getProperties();
    for (Property p : properties) {
        PlasmaProperty property = (PlasmaProperty) p;
        if (property.isMany())
            continue; // do/could we invoke a "marshaler" here?
        if (property.isKey(KeyType.primary))
            continue;

        if (property.getConcurrent() != null)
            continue;

        Object oldValue = dataGraph.getChangeSummary().getOldValue(dataObject, property);
        if (oldValue != null) { // it's been modified  
            if (!property.isReadOnly()) {
                Object value = dataObject.get(property);
                if (value != null) {
                    PropertyPair pair = createValue(dataObject, value, property);
                    entity.put(property.getName(), pair);
                }
                //setEntityValue(entity, value, property);
            } else
                throw new IllegalAccessException("attempt to modify read-only property, " + type.getURI() + "#"
                        + type.getName() + "." + property.getName());
        }
    }

    if (hasUpdatableProperties(entity)) {
        StringBuilder update = createUpdate(type, entity);
        if (log.isDebugEnabled()) {
            log.debug("updating " + dataObject.getType().getName());
        }
        execute(type, update, entity, con);
    }
}

From source file:de.fiz.ddb.aas.utils.LDAPEngineUtility.java

/**
 * get attribute values of given resource and attributes.
 * // w  w  w.  j a va2s .co m
 * @param scope
 *            scope
 * @param id
 *            id of resource
 * @param attributeName
 *            attribute-name to retrieve
 * 
 * @return String attribute value
 * @throws NamingException
 * @throws IllegalAccessException
 */
public Map<String, String> getResourceAttributes(Scope scope, String id, String[] attributeNames)
        throws NamingException, IllegalAccessException {
    Map<String, String> returnMap = new HashMap<String, String>();
    String baseDn = null;
    String filter = getIdFilter(scope, id);
    int levelScope = 0;
    InitialLdapContext ctx = null;
    NamingEnumeration<SearchResult> results = null;
    if (scope == Scope.ORGANIZATION) {
        baseDn = LDAPConnector.getSingletonInstance().getInstitutionBaseDN();
        levelScope = SearchControls.SUBTREE_SCOPE;
    } else if (scope == Scope.PERSON) {
        baseDn = LDAPConnector.getSingletonInstance().getPersonBaseDN();
        levelScope = SearchControls.ONELEVEL_SCOPE;
    }
    try {
        ctx = LDAPConnector.getSingletonInstance().takeCtx();
        results = query(ctx, baseDn, filter, attributeNames, levelScope);
        if (results.hasMore()) {
            SearchResult searchResult = results.next();
            if (results.hasMore()) {
                throw new IllegalAccessException("found more than one object with id=" + id);
            }
            Attributes attributes = searchResult.getAttributes();
            for (int i = 0; i < attributeNames.length; i++) {
                Attribute attribute = attributes.get(attributeNames[i]);
                if (attribute == null) {
                    returnMap.put(attributeNames[i], (String) null);
                } else {
                    returnMap.put(attributeNames[i], (String) attribute.get());
                }
            }
            return returnMap;
        } else {
            throw new NameNotFoundException("id not found");
        }

    } finally {
        if (ctx != null) {
            try {
                LDAPConnector.getSingletonInstance().putCtx(ctx);
            } catch (IllegalAccessException ex) {
                LOG.log(Level.SEVERE, null, ex);
            }
        }
        if (results != null) {
            try {
                results.close();
            } catch (NamingException e) {
                LOG.log(Level.WARNING, null, e);
            }
        }
    }
}

From source file:de.fiz.ddb.aas.utils.LDAPEngineUtility.java

/**
 * get filter-string for given id and scope.
 * //from  www .  ja  v a 2 s . c o m
 * @param scope
 *            scope
 * @param id
 *            id of resource
 * 
 * @return String id-filter as String
 * @throws IllegalAccessException
 */
public String getIdFilter(Scope scope, String id) throws IllegalAccessException {
    if (id == null) {
        throw new IllegalAccessException("id may not be null");
    }
    if (scope == Scope.ORGANIZATION) {
        return new StringBuilder("(& (objectclass=").append(Constants.ldap_ddbOrg_ObjectClass).append(") (")
                .append(Constants.ldap_ddbOrg_Id).append("=").append(id).append("))").toString();
    } else if (scope == Scope.PERSON) {
        return new StringBuilder("(& (objectclass=").append(Constants.ldap_ddbPerson_ObjectClass).append(") (")
                .append(Constants.ldap_ddbPerson_Id).append("=").append(id).append("))").toString();
    } else {
        throw new IllegalAccessException("scope does not match");
    }
}

From source file:com.amalto.workbench.editors.DataModelMainPage.java

public void validateSchema() throws IllegalAccessException {

    final String msg_shouldRefresh[] = { Messages.XsdRefresh };

    // do not force to refresh every time just when an error throws.
    String error = validateDiagnoses(XSDEditor.MSG_OMIT);
    for (String msg : msg_shouldRefresh) {
        if (error.indexOf(msg) != -1) {
            refreshModelPageSchema();/*from  www  . ja  v  a2  s.  c  o  m*/
        }
    }
    // refreshModelPageSchema and validate again
    error = validateDiagnoses(XSDEditor.MSG_OMIT);

    if (!error.equals("")) {//$NON-NLS-1$
        IllegalAccessException illegalAccessException = new IllegalAccessException(error);
        log.error(illegalAccessException.getMessage(), illegalAccessException);
        ErrorExceptionDialog.openError(this.getSite().getShell(), Messages.ErrorCommittingPage,
                CommonUtil.getErrMsgFromException(illegalAccessException));
    }

    validateType();
    validateElementation();
}

From source file:com.amalto.workbench.editors.xsdeditor.XSDEditor.java

public void validateXsdSourceEditor() {
    String xsd = getSourcePageDocument();
    Exception ex = null;//from w  ww .j  av  a  2s  . co  m
    try {
        XSDSchema xsdSchema = Util.createXsdSchema(xsd, xobject);
        String error = validateDiagnoses(xsdSchema);
        if (!"".equals(error)) { //$NON-NLS-1$
            ex = new IllegalAccessException(error);
        }

    } catch (SAXParseException e) {
        ex = e;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        ex = e;
    }

    if (ex != null) {
        hasXSDErrors = true;

        ErrorExceptionDialog.openError(getSite().getShell(), Messages.XSDEditor_ChangedPageErrorTitle,
                CommonUtil.getErrMsgFromException(ex));
        Display.getDefault().asyncExec(new Runnable() {

            public void run() {
                setActivePage(SOURCE_PAGE_INDEX);
            }
        });

        return;
    }
    hasXSDErrors = false;
    return;
}

From source file:Formulario.CapturaHuella.java

/**
 * Identifica a una persona registrada por medio de su huella digital
 *///w  ww  .  j  av  a 2  s .  c  om
//CONEXION STFP EMPIEZA AQUI,AUN NO TERMINADA !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
public void connect(String username, String password, String host, int port)
        throws JSchException, IllegalAccessException {
    if (this.session == null || !this.session.isConnected()) {
        JSch jsch = new JSch();

        this.session = jsch.getSession(username, host, port);
        this.session.setPassword(password);

        // Parametro para no validar key de conexion.
        this.session.setConfig("StrictHostKeyChecking", "no");

        this.session.connect();
    } else {
        throw new IllegalAccessException("Sesion SFTP ya iniciada.");
    }
}

From source file:de.fiz.ddb.aas.utils.LDAPEngineUtility.java

/**
 * set modification-properties in LDAP./*from  w w w . j a va2s .c om*/
 * 
 * @param isCreate
 *            if also createProperties should be set.
 * @param performer
 *            performer.
 * @param id
 *            id to set properties for.
 * @param scope
 *            scope.
 * 
 * @return
 * @throws
 */
public void setModificationPropertiesInLdap(boolean isCreate, AasPrincipal performer, String id, Scope scope)
        throws NamingException, IllegalAccessException {
    String propertiesAttName = null;
    if (scope == Scope.PERSON) {
        propertiesAttName = Constants.ldap_ddbPerson_Properties;
    } else if (scope == Scope.ORGANIZATION) {
        propertiesAttName = Constants.ldap_ddbOrg_Properties;
    } else {
        throw new IllegalAccessException("scope does not match");
    }

    Map<String, String> attributes = getResourceAttributes(scope, id,
            new String[] { propertiesAttName, Constants.ldap_ddb_EntryDN });
    DdbProperties properties = null;
    String entryDn = null;
    if (attributes != null && StringUtils.isNotBlank(attributes.get(Constants.ldap_ddb_EntryDN))) {
        if (StringUtils.isNotBlank(attributes.get(propertiesAttName))) {
            properties = serializer.deserialize(attributes.get(propertiesAttName));
        }
        properties = PropertiesHelper.setModificationProperties(properties, isCreate, performer);
        entryDn = attributes.get(Constants.ldap_ddb_EntryDN);
    } else {
        throw new NameNotFoundException("entry with id=" + id + " not found");
    }
    InitialLdapContext ctx = null;
    try {
        ctx = LDAPConnector.getSingletonInstance().takeCtx();
        Attributes saveAttributes = new BasicAttributes(true);
        saveAttributes.put(new BasicAttribute(propertiesAttName, serializer.serialize(properties)));
        ctx.modifyAttributes(entryDn, DirContext.REPLACE_ATTRIBUTE, saveAttributes);
    } finally {
        if (ctx != null) {
            try {
                LDAPConnector.getSingletonInstance().putCtx(ctx);
            } catch (IllegalAccessException ex) {
                LOG.log(Level.SEVERE, null, ex);
            }
        }
    }

}