Return a pre-configured manifest

@todo Add user attributes list and user groups list
421512
public Manifest getManifest(MavenProject project, ManifestConfiguration config) throws ManifestException, DependencyResolutionRequiredException {
        // Added basic entries
        Manifest m = new Manifest();
        Manifest.Attribute buildAttr = new Manifest.Attribute("Built-By", System.getProperty("user.name"));
        m.addConfiguredAttribute(buildAttr);
        Manifest.Attribute createdAttr = new Manifest.Attribute("Created-By", "Apache Maven");
        m.addConfiguredAttribute(createdAttr);

        if (config.getPackageName() != null) {
            Manifest.Attribute packageAttr = new Manifest.Attribute("Package", config.getPackageName());
            m.addConfiguredAttribute(packageAttr);
        }

        Manifest.Attribute buildJdkAttr = new Manifest.Attribute("Build-Jdk", System.getProperty("java.version"));
        m.addConfiguredAttribute(buildJdkAttr);

        if (config.isAddClasspath()) {
            StringBuffer classpath = new StringBuffer();
            List artifacts = project.getRuntimeClasspathElements();
            String classpathPrefix = config.getClasspathPrefix();

            for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
                File f = new File((String) iter.next());
                if (f.isFile()) {
                    if (classpath.length() > 0) {
                        classpath.append(" ");
                    }

                    classpath.append(classpathPrefix);
                    classpath.append(f.getName());
                }
            }

            if (classpath.length() > 0) {
                Manifest.Attribute classpathAttr = new Manifest.Attribute("Class-Path", classpath.toString());
                m.addConfiguredAttribute(classpathAttr);
            }
        }

        String mainClass = config.getMainClass();
        if (mainClass != null && !"".equals(mainClass)) {
            Manifest.Attribute mainClassAttr = new Manifest.Attribute("Main-Class", mainClass);
            m.addConfiguredAttribute(mainClassAttr);
        }
        return m;
    }
427204
public function getUserAgentByCommonLib()
    {
        $this->autoPopulateSuperGlobals();
        if (!is_null($this->brServerGlobals->get('ua'))) {
            return $this->brServerGlobals->get('ua');
        }
        return $this->getUserAgentByCommonLibDetection();
    }
8394
private static Manifest standardSoyJarManifest() {
    Manifest mf = new Manifest();
    mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
    mf.getMainAttributes().put(new Attributes.Name("Created-By"), "soy");
    return mf;
  }
408863
protected function findOrCreateAdminGroup()
    {
        // Check pre-existing group
        $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
        if ($adminGroup) {
            return $adminGroup;
        }

        // Check if default records create the group
        Group::singleton()->requireDefaultRecords();
        $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
        if ($adminGroup) {
            return $adminGroup;
        }

        // Create new admin group directly
        $adminGroup = Group::create();
        $adminGroup->Code = 'administrators';
        $adminGroup->Title = _t('SilverStripe\\Security\\Group.DefaultGroupTitleAdministrators', 'Administrators');
        $adminGroup->Sort = 0;
        $adminGroup->write();
        Permission::grant($adminGroup->ID, 'ADMIN');
        return $adminGroup;
    }
389537
public function getPreferencesPane()
    {
        parent::getPreferencesPane();
        $group = new XMLElement('fieldset');
        $group->setAttribute('class', 'settings condensed pickable');
        $group->setAttribute('id', 'sendmail');
        $group->appendChild(new XMLElement('legend', __('Email: Sendmail')));

        $div = new XMLElement('div');
        $div->setAttribute('class', 'two columns');

        $readonly = array('readonly' => 'readonly');

        $label = Widget::Label(__('From Name'));
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input('settings[email_sendmail][from_name]', General::sanitize($this->_sender_name), 'text', $readonly));
        $div->appendChild($label);

        $label = Widget::Label(__('From Email Address'));
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input('settings[email_sendmail][from_address]', General::sanitize($this->_sender_email_address), 'text', $readonly));
        $div->appendChild($label);

        $group->appendChild($div);

        return $group;
    }
1349236
public function getUserGroupManager()
    {
        if ($this->userGroupManager != null) {
            return $this->userGroupManager;
        }

        $this->userGroupManager = new UserGroupManager($this->options, $this->getUserService(), $this->getContentService(), $this->getContentTypeService());

        if ($this->logger) {
            $this->userGroupManager->setLogger($this->logger);
        }

        return $this->userGroupManager;
    }
1306997
static function publishNewUserGroup( $parentNodeIDs, $newGroupAttributes, $isUtf8Encoding = false )
    {
        $newNodeIDs = array();

        if ( !is_array( $newGroupAttributes ) or
             !isset( $newGroupAttributes[ 'name' ] ) or
             empty( $newGroupAttributes[ 'name' ] ) )
        {
            eZDebug::writeWarning( 'Cannot create user group with empty name.', __METHOD__ );
            return $newNodeIDs;
        }
        if ( !is_array( $parentNodeIDs ) or count( $parentNodeIDs ) < 1 )
        {
            eZDebug::writeWarning( 'No one parent node IDs was passed for publishing new group (group name = "' .
                                   $newGroupAttributes[ 'name' ] . '")',
                                   __METHOD__ );
            return $newNodeIDs;
        }

        $ini = eZINI::instance();
        $userGroupClassID = $ini->variable( "UserSettings", "UserGroupClassID" );
        $userCreatorID = $ini->variable( "UserSettings", "UserCreatorID" );
        $defaultSectionID = $ini->variable( "UserSettings", "DefaultSectionID" );

        $userGroupClass = eZContentClass::fetch( $userGroupClassID );
        $contentObject = $userGroupClass->instantiate( $userCreatorID, $defaultSectionID );

        $contentObject->store();

        $contentObjectID = $contentObject->attribute( 'id' );

        reset( $parentNodeIDs );
        $defaultPlacement = current( $parentNodeIDs );
        array_shift( $parentNodeIDs );

        $nodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $contentObjectID,
                                                           'contentobject_version' => 1,
                                                           'parent_node' => $defaultPlacement,
                                                           // parent_remote_id in node assignment holds remote id of the tree node,
                                                           // not of the parent location or of the node assignment itself
                                                           'parent_remote_id' => uniqid( 'LDAP_' ),
                                                           'is_main' => 1 ) );
        $nodeAssignment->store();

        foreach( $parentNodeIDs as $parentNodeID )
        {
            $newNodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $contentObjectID,
                                                                  'contentobject_version' => 1,
                                                                  'parent_node' => $parentNodeID,
                                                                  // parent_remote_id in node assignment holds remote id of the tree node,
                                                                  // not of the parent location or of the node assignment itself
                                                                  'parent_remote_id' => uniqid( 'LDAP_' ),
                                                                  'is_main' => 0 ) );
            $newNodeAssignment->store();
        }

        $version = $contentObject->version( 1 );
        $version->setAttribute( 'modified', time() );
        $version->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
        $version->store();

        $contentObjectAttributes = $version->contentObjectAttributes();

        // find ant set 'name' and 'description' attributes (as standard user group class)
        $nameIdentifier = 'name';
        $descIdentifier = 'description';
        $nameContentAttribute = null;
        $descContentAttribute = null;
        foreach( $contentObjectAttributes as $attribute )
        {
            if ( $attribute->attribute( 'contentclass_attribute_identifier' ) == $nameIdentifier )
            {
                $nameContentAttribute = $attribute;
            }
            else if ( $attribute->attribute( 'contentclass_attribute_identifier' ) == $descIdentifier )
            {
                $descContentAttribute = $attribute;
            }
        }
        if ( $nameContentAttribute )
        {
            if ( $isUtf8Encoding )
                $newGroupAttributes[ 'name' ] = utf8_decode( $newGroupAttributes[ 'name' ] );
            $nameContentAttribute->setAttribute( 'data_text', $newGroupAttributes[ 'name' ] );
            $nameContentAttribute->store();
        }
        if ( $descContentAttribute and
             isset( $newGroupAttributes[ 'description' ] ) )
        {
            if ( $isUtf8Encoding )
                $newGroupAttributes[ 'description' ] = utf8_decode( $newGroupAttributes[ 'description' ] );
            $descContentAttribute->setAttribute( 'data_text', $newGroupAttributes[ 'description' ] );
            $descContentAttribute->store();
        }

        $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
                                                                                     'version' => 1 ) );
        $newNodes = eZContentObjectTreeNode::fetchByContentObjectID( $contentObjectID, true, 1 );
        foreach ( $newNodes as $newNode )
        {
            $newNodeIDs[] = $newNode->attribute( 'node_id' );
        }

        return $newNodeIDs;
    }
31429
private Map<Object, Object> getClassPathManifestAttributes() {
		Map<Object, Object> manifestAttributes = null;
		try {
		    LOGGER.debug("Using Manifest file:{}", getClass().getClassLoader().getResource(MANIFEST).getPath());
		    
		    Manifest manifest = new Manifest(getClass().getClassLoader().getResourceAsStream(MANIFEST));
		    manifestAttributes = manifest.getMainAttributes();
		} catch (IOException e) {
			LOGGER.warn("Unable to read the manifest from the classpath");
			LOGGER.debug("Unable to read the manifest from the classpath", e);
		}
		return manifestAttributes;
	}
1227734
protected function initUserAttributes()
    {
        $attributes =  $this->api('people/~:(' . implode(',', $this->attributeNames) . ')', 'GET');

        $return_attributes = [
            'User' => [
                $this->email        => $attributes['email-address'],
                $this->first_name   => $attributes['first-name'],
                $this->last_name    => $attributes['last-name'],
                $this->status       => $this->statusActive
            ],
            'provider_user_id' => $attributes['id'],
            'provider_id' => UserOauthKey::getAvailableClients()['yandex'],
            'page' => $attributes['public-profile-url'],
        ];

        return $return_attributes;
    }
521373
public function add()
    {
        $user = $this->Users->newEntity();
        if ($this->request->is('post')) {
            $user = $this->Users->patchEntity($user, $this->request->getData());
            if (Filter::bool($user->get('notify'))) {
                $user->set('token', Token::generate());
            }

            $result = $this->Users->save($user);
            if ($result) {
                $this->Flash->success(__d('community', 'The user {0} has been saved.', sprintf(
                    '<strong>«%s»</strong>',
                    $result->get('login')
                )));

                return $this->App->redirect(['apply' => ['action' => 'edit', $result->id]]);
            } else {
                $this->Flash->error(__d('community', 'User could not be updated. Please, try again.'));
            }
        }

        $groups = $this->Users->Groups->getTreeList();

        $this
            ->set(compact('user', 'groups'))
            ->set('page_title', __d('community', 'Profiles: Add new user'));
    }
361066
public function getAuthors()
    {
        $result = false;
        if($this->__manifest !== false)
        {
            $authors = $this->__manifest->get('authors', array());
            $result = ObjectConfig::unbox($authors);
        }

        return $result;
    }
642826
private function getManifest()
    {
        if (!isset($this->manifest)) {
            $context = stream_context_create(['http' => ['timeout' => $this->manifestTimeout]]);
            $manifestContents = file_get_contents($this->manifestUrl, false, $context);
            if ($manifestContents === false) {
                throw new \RuntimeException(sprintf('Failed to download manifest: %s', $this->manifestUrl));
            }

            $this->manifest = (array) json_decode($manifestContents, true);
            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new JsonParsingException(
                    'Error parsing manifest file'
                    . (function_exists('json_last_error_msg') ? ': ' . json_last_error_msg() : '')
                );
            }
        }

        return $this->manifest;
    }
364411
protected function loadLayoutConfig()
    {
        $xml = $this->getXml();

        foreach ($xml->xpath("./resources/layout/config[@file != '']") as $node) {
            $file = (string)$node['file'];
            $priority = intval((string)$node['priority']);
            $scope = (string)$node['scope'];

            if (!$scope) {
                $scope = $this->getModuleName();
            }

            $file = $scope . '::' . $file;
            $this->manifest['application_config']['rampage']['layout']['files'][$file] = $priority;
        }

        $map = array(
            'layout' => './layout[@template != ""]/@template',
            'exception_template' => './layout/error[@type = "exception" and @template != ""]/@template',
            'not_found_template' => './layout/error[@type = "not-found" and @template != ""]/@template'
        );

        foreach ($map as $var => $xpath) {
            $value = $xml->xpath($xpath)->current();
            if ($value) {
                $this->manifest['application_config']['view_manager'][$var] = (string)$value;
            }
        }

        return $this;
    }
875629
public function userCreationFormAction()
    {
        $roleUser = $this->roleManager->getRoleByName('ROLE_USER');
        $isAdmin = ($this->authorization->isGranted('ROLE_ADMIN')) ? true : false;
        $roles = $this->roleManager->getAllPlatformRoles();
        $unavailableRoles = [];

        foreach ($roles as $role) {
            $isAvailable = $this->roleManager->validateRoleInsert(new User(), $role);

            if (!$isAvailable) {
                $unavailableRoles[] = $role;
            }
        }
        $profileType = new ProfileCreationType(
            $this->localeManager,
            array($roleUser),
            $isAdmin,
            $this->authenticationManager->getDrivers()
        );
        $form = $this->formFactory->create($profileType);

        $error = null;

        if (!$this->mailManager->isMailerAvailable()) {
            $error = 'mail_not_available';
        }

        return array(
            'form_complete_user' => $form->createView(),
            'error' => $error,
            'unavailableRoles' => $unavailableRoles
        );
    }
23462
public static function bindings()
    {
        $registrar = new static;

        $registrar->bind('auth_permission', function($hashedId) {
            return Permission::firstHashedOrFail($hashedId);
        });

        $registrar->bind('auth_permissions_group', function($hashedId) {
            return PermissionsGroup::firstHashedOrFail($hashedId);
        });
    }
33478
public function detect()
    {
        $themes  = new Collection();
        $file    = $this->app->make('files');
        $path    = rtrim(__DIR__ . '/../' . array_get($this->config, 'indexes_path', ''));
        $folders = $file->directories($path);
        foreach ($folders as $folder) {
            $templateDir = class_basename($folder);
            $name        = $this->parseThemeNameFromPath($folder);
            $manifest    = new Manifest($file, $this->config + ['dir' => $templateDir], rtrim($folder, '/') . '/');
            $items       = $manifest->items();
            if (is_null($items)) {
                continue;
            }
            $themes[$name] = $items->getAttributes();
        }
        return $themes;
    }
1210492
public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $treeBuilder->root('e_xpansion_admin_groups')
            ->children()
                ->arrayNode('groups')
                    ->prototype('array')
                        ->children()
                            ->variableNode('label')->end()
                            ->arrayNode('logins')->prototype('scalar')->end()->end()
                            ->arrayNode('permissions')->prototype('scalar')->end()->end()
                        ->end()
                    ->end()
                ->end()
                ->arrayNode('permissions')
                    ->prototype('scalar')->end()
                ->end()
            ->end();

        return $treeBuilder;
    }