Examples of AttributeDefinition


Examples of com.adito.properties.attributes.AttributeDefinition

    super(NAME, false, "properties", false);
  }

  public String retrievePropertyImpl(AbstractPropertyKey key)
      throws IllegalArgumentException {
    AttributeDefinition def = (AttributeDefinition) getDefinition(key
        .getName());
    PolicyAttributeKey policyAttrKey = (PolicyAttributeKey) key;
    try {
      String val = ProfilesFactory.getInstance()
          .retrieveAttributeValue(policyAttrKey);

      // Decrypt obfuscated password if of password type
      if (def.getType() == PropertyDefinition.TYPE_PASSWORD
          && val != null) {
        try {
          val = ContextHolder.getContext().deobfuscatePassword(val);
        } catch (Throwable t) {
          log
              .warn(
                  "Password property "
                      + def.getName()
                      + " could not be decoded. It has been result to the default.",
                  t);
        }
      }
      //
      return val == null ? def.getDefaultValue() : val;
    } catch (Exception e) {
      log.error("Failed to retrieve property.", e);
    }
    return null;
  }
View Full Code Here

Examples of com.adito.properties.attributes.AttributeDefinition

    return null;
  }

  public String storePropertyImpl(AbstractPropertyKey key, String value)
      throws IllegalArgumentException {
    AttributeDefinition def = (AttributeDefinition) getDefinition(key
        .getName());
    PolicyAttributeKey policyAttrKey = (PolicyAttributeKey) key;
    String oldValue = retrieveProperty(key);
    if (def.getDefaultValue().equals(value)) {
      value = null;
    }

    if ((oldValue == null && value != null)
        || (oldValue != null && value == null)
        || !oldValue.equals(value)) {

      // Obfuscate the password for storing in the database

      if (def.getType() == PropertyDefinition.TYPE_PASSWORD) {
        try {
          value = ContextHolder.getContext().obfuscatePassword(value);
        } catch (Throwable t) {
          log.warn("Password property " + def.getName()
              + " could not be encoded.", t);
        }
      }

      // Store to the database
View Full Code Here

Examples of com.adito.properties.attributes.AttributeDefinition

    public AttributeDefinition createAttributeDefinition(int type, String name, String typeMeta, int category,
                                                         String categoryLabel, String defaultValue, int visibility, int sortOrder,
                                                         String messageResourcesKey, boolean hidden, String label,
                                                         String description, boolean system, boolean replaceable,
                                                         String validationString) {
        AttributeDefinition def = new DefaultAttributeDefinition(type, name, typeMeta, category, categoryLabel, defaultValue,
                        visibility, sortOrder, messageResourcesKey, hidden, label, description, system, replaceable,
                        validationString);
        def.init(this);
        return def;
    }
View Full Code Here

Examples of com.adito.properties.attributes.AttributeDefinition

     * @throws Exception
     */
    public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        AttributeDefinitionForm df = (AttributeDefinitionForm) form;
        AttributeDefinition def = (AttributeDefinition) request.getSession().getAttribute(Constants.EDITING_ITEM);
        if (def.isSystem()) {
            throw new Exception("System attribute definitions may not be edited.");
        }
        df.initialise(def);
        df.setEditing();
        df.setReferer(CoreUtil.getReferer(request));
View Full Code Here

Examples of com.adito.properties.attributes.AttributeDefinition

     * @throws Exception
     */
    public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        AttributeDefinitionForm df = (AttributeDefinitionForm) form;
        AttributeDefinition def = (AttributeDefinition) request.getSession().getAttribute(Constants.EDITING_ITEM);
        if (def.isSystem()) {
            throw new Exception("System attribute definitions may not be edited.");
        }
       
        // Initialise the form
        df.initialise(def);
View Full Code Here

Examples of com.adito.properties.attributes.AttributeDefinition

      String typeMeta, int category, String categoryLabel,
      String defaultValue, int visibility, int sortOrder,
      String messageResourcesKey, boolean hidden, String label,
      String description, boolean system, boolean replaceable,
      String validationString) {
    AttributeDefinition def = new DefaultAttributeDefinition(type, name, typeMeta, category,
        categoryLabel, defaultValue, visibility, sortOrder,
        messageResourcesKey, hidden, label, description, system,
        replaceable, validationString);
    def.init(this);
    return def;
  }
View Full Code Here

Examples of com.adito.properties.attributes.AttributeDefinition

                    HttpServletResponse response) throws Exception {
        List<AttributeValueItem> a = new ArrayList<AttributeValueItem>();
        SessionInfo sessionInfo = getSessionInfo(request);
        PropertyClass propertyClass = PropertyClassManager.getInstance().getPropertyClass(UserAttributes.NAME);
        for(PropertyDefinition d : propertyClass.getDefinitions()) {
            AttributeDefinition def = (AttributeDefinition)d;
            if(def.isHidden())
              continue;
            if(def.getVisibility() == AttributeDefinition.USER_OVERRIDABLE_ATTRIBUTE ||
                            def.getVisibility() == AttributeDefinition.USER_VIEWABLE_ATTRIBUTE
                            || def.getVisibility() == AttributeDefinition.USER_CONFIDENTIAL_ATTRIBUTE) {
                a.add(new AttributeValueItem(def, request, Property.getProperty(new UserAttributeKey(sessionInfo.getUser(), def.getName()))));
            }
        }
        Collections.sort(a);
        ((UserAttributesForm)form).initialize(a);
        ((UserAttributesForm)form).setReferer(CoreUtil.getReferer(request));
View Full Code Here

Examples of com.adito.properties.attributes.AttributeDefinition

                errs.add(Globals.ERROR_KEY, new ActionMessage("editAttributeDefinition.error.noDescription"));
            } else {
                if(!getEditing()) {
                    try {
                        PropertyClass propertyClass = PropertyClassManager.getInstance().getPropertyClass(UserAttributes.NAME);
                        AttributeDefinition def = (AttributeDefinition)propertyClass.getDefinition(getName());
                        if(def != null) {
                            errs.add(Globals.ERROR_KEY, new ActionMessage("editAttributeDefinition.error.duplicateName", getName()));                       
                        }
                    }
                    catch(Exception e) {
                        log.error("Failed to test if attribute exists.", e);
                        errs.add(Globals.ERROR_KEY, new ActionMessage("editAttributeDefinition.error.duplicateName", getName()));
                    }
                }
                if (!getName().matches("^[a-zA-Z0-9_-]*$")) {
                    errs.add(Globals.ERROR_KEY, new ActionMessage("editAttributeDefinition.error.invalidName"));
                }
            }
            if(!validationString.trim().equals("")) {
                String className = null;
                int idx = validationString.indexOf('(');
                if(idx == -1) {
                    className = validationString;                       
                }
                else {
                    if(!validationString.endsWith(")")) {
                        errs = new ActionErrors();
                        errs.add(Globals.ERROR_KEY, new ActionMessage("editAttributeDefinition.error.invalidValidationStringFormat"));
                    }
                    className = validationString.substring(0, idx);
                }
               
                try {
                  Class.forName(className);
                }
                catch(ClassNotFoundException cnfe) {
                    errs.add(Globals.ERROR_KEY, new ActionMessage("editAttributeDefinition.error.noSuchValidator", className));                 
                }

                try {
                    // If there is a default value then validate it
                   
                    String defaultValue = getDefaultValue().trim();
                    if(!defaultValue.equals("")) {
                      AttributeDefinition def = ((AttributesPropertyClass)definition.getPropertyClass()).createAttributeDefinition(type,
                            name,
                            typeMeta,
                            -1,
                            category,
                            defaultValue,
                            visibility,
                            sortOrder,
                            null,
                            false,
                            label,
                            description,
                            false,
                            true,
                            validationString);
                        try {
                          def.validate(defaultValue, getClass().getClassLoader());
                        } catch (CoreException ce) {
                            ce.getBundleActionMessage().setArg3(def.getLabel());
                            if (errs == null) {
                                errs = new ActionErrors();
                            }
                            errs.add(Globals.ERROR_KEY, ce.getBundleActionMessage());
                        }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.AttributeDefinition

        CreateTableRequest createTableRequest = new CreateTableRequest();
        createTableRequest.setTableName(DynamoDBMapper.getTableName(clazz, config, reflector));

        // Primary keys
        Method pHashKeyGetter = reflector.getPrimaryHashKeyGetter(clazz);
        AttributeDefinition pHashAttrDefinition = getKeyAttributeDefinition(pHashKeyGetter, converter);
        createTableRequest.withKeySchema(new KeySchemaElement(pHashAttrDefinition.getAttributeName(), KeyType.HASH));
        // Primary range
        Method pRangeKeyGetter = reflector.getPrimaryRangeKeyGetter(clazz);
        AttributeDefinition pRangeAttrDefinition = null;
        if (pRangeKeyGetter != null) {
            pRangeAttrDefinition = getKeyAttributeDefinition(pRangeKeyGetter, converter);
            createTableRequest.withKeySchema(new KeySchemaElement(pRangeAttrDefinition.getAttributeName(), KeyType.RANGE));
        }

        // Parse the index schema
        TableIndexesInfo indexesInfo = parseTableIndexes(clazz, reflector);
        if ( indexesInfo.getGlobalSecondaryIndexes().isEmpty() == false ) {
            createTableRequest.setGlobalSecondaryIndexes(indexesInfo.getGlobalSecondaryIndexes());
        }
        if ( indexesInfo.getLocalSecondaryIndexes().isEmpty() == false ) {
            createTableRequest.setLocalSecondaryIndexes(indexesInfo.getLocalSecondaryIndexes());
        }

        // Aggregate all key attribute definitions
        Map<String, AttributeDefinition> attrDefinitions = new HashMap<String, AttributeDefinition>();
        // Hash key definition
        putAfterCheckConflict(attrDefinitions, pHashAttrDefinition);
        // Range key definition
        if (pRangeKeyGetter != null) {
            putAfterCheckConflict(attrDefinitions, pRangeAttrDefinition);
        }
        for (Method indexKeyGetter : indexesInfo.getIndexKeyGetters()) {
            AttributeDefinition indexKeyAttrDefinition = getKeyAttributeDefinition(indexKeyGetter, converter);
            putAfterCheckConflict(attrDefinitions, indexKeyAttrDefinition);
        }
        createTableRequest.setAttributeDefinitions(attrDefinitions.values());

        return createTableRequest;
View Full Code Here

Examples of com.denimgroup.threadfix.service.defects.utils.versionone.AttributeDefinition

        getV1Data();

        if (fieldsMap != null) {
            for(Map.Entry<String, Object> entry : fieldsMap.entrySet()){
                AttributeDefinition entryDef = findAttributeDefinition(entry.getKey());
                if (entryDef != null) {
                    if (entryDef.getRelationType().equals("select")) {
                        addRelation(entryDef, assetTemplate, entry.getValue());
                    } else {
                        addAttribute(entryDef, assetTemplate, entry.getValue());
                    }
                } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.