Loads an application from a directory.
@param projectDirectory the project directory
@param appDescriptor the application's descriptor
@param result the result to populate
@return a load result (never null)
518890
private static ApplicationLoadResult loadApplication(
			File projectDirectory,
			ApplicationTemplateDescriptor appDescriptor,
			ApplicationLoadResult result ) {

		ApplicationTemplate app = result.applicationTemplate;
		result.applicationTemplate.setDirectory( projectDirectory );


		// Load the graph
		File graphDirectory = new File( projectDirectory, Constants.PROJECT_DIR_GRAPH );
		GRAPH: if( ! graphDirectory.exists()) {
			RoboconfError error = new RoboconfError( ErrorCode.PROJ_NO_GRAPH_DIR, directory( projectDirectory ));
			result.loadErrors.add( error );

		} else if( appDescriptor != null
				&& ! Utils.isEmptyOrWhitespaces( appDescriptor.getGraphEntryPoint())) {

			File mainGraphFile = new File( graphDirectory, appDescriptor.getGraphEntryPoint());
			if( ! mainGraphFile.exists()) {
				RoboconfError error = new RoboconfError( ErrorCode.PROJ_MISSING_GRAPH_EP, expected( mainGraphFile.getAbsolutePath()));
				result.loadErrors.add( error );
				break GRAPH;
			}

			Graphs graphs = loadGraph( mainGraphFile, graphDirectory, result );
			app.setGraphs( graphs );
		}


		// Load the instances
		File instDirectory = new File( projectDirectory, Constants.PROJECT_DIR_INSTANCES );
		INST: if( appDescriptor != null && instDirectory.exists()) {

			if( app.getGraphs() == null ) {
				result.loadErrors.add( new RoboconfError( ErrorCode.CO_GRAPH_COULD_NOT_BE_BUILT ));
				break INST;
			}

			if( Utils.isEmptyOrWhitespaces( appDescriptor.getInstanceEntryPoint()))
				break INST;

			File mainInstFile = new File( instDirectory, appDescriptor.getInstanceEntryPoint());
			InstancesLoadResult ilr = loadInstances( mainInstFile, instDirectory, app.getGraphs(), app.getName());

			result.getParsedFiles().addAll( ilr.getParsedFiles());
			result.objectToSource.putAll( ilr.getObjectToSource());
			result.loadErrors.addAll( ilr.getLoadErrors());
			app.getRootInstances().addAll( ilr.getRootInstances());
		}


		// Commands
		File commandsDirectory = new File( projectDirectory, Constants.PROJECT_DIR_COMMANDS );
		List<String> commandNames = new ArrayList<> ();
		if( app.getGraphs() != null && commandsDirectory.exists()) {

			for( File f : Utils.listAllFiles( commandsDirectory )) {

				if( ! f.getName().endsWith( Constants.FILE_EXT_COMMANDS )) {
					result.loadErrors.add( new RoboconfError( ErrorCode.PROJ_INVALID_COMMAND_EXT ));

				} else {
					CommandsParser parser = new CommandsParser( app, f );
					result.loadErrors.addAll( parser.getParsingErrors());
					commandNames.add( f.getName().replace( Constants.FILE_EXT_COMMANDS, "" ));
				}
			}
		}


		// Autonomic
		File autonomicRulesDirectory = new File( projectDirectory, Constants.PROJECT_DIR_RULES_AUTONOMIC );
		if( app.getGraphs() != null && autonomicRulesDirectory.exists()) {

			for( File f : Utils.listAllFiles( autonomicRulesDirectory )) {

				if( ! f.getName().endsWith( Constants.FILE_EXT_RULE )) {
					result.loadErrors.add( new RoboconfError( ErrorCode.PROJ_INVALID_RULE_EXT ));

				} else {
					// Parsing errors
					RuleParser parser = new RuleParser( f );
					result.loadErrors.addAll( parser.getParsingErrors());

					// Invalid references to commands?
					List<String> coll = new ArrayList<>( parser.getRule().getCommandsToInvoke());
					coll.removeAll( commandNames );
					for( String commandName : coll )
						result.loadErrors.add( new RoboconfError( ErrorCode.RULE_UNKNOWN_COMMAND, name( commandName )));
				}
			}
		}


		// Check for files that are not reachable or not in the right directories
		if( projectDirectory.isDirectory()) {
			String[] exts = { Constants.FILE_EXT_GRAPH, Constants.FILE_EXT_INSTANCES };
			File[] directories = { graphDirectory, instDirectory };

			for( int i=0; i<exts.length; i++ ) {
				List<File> files = Utils.listAllFiles( projectDirectory, exts[ i ]);
				List<File> filesWithInvalidLocation = new ArrayList<> ();
				for( File f : files ) {
					if( ! Utils.isAncestor( directories[ i ], f )) {
						result.loadErrors.add( new ParsingError( ErrorCode.PROJ_INVALID_FILE_LOCATION, f, 1 ));
						filesWithInvalidLocation.add( f );
					}
				}

				files.removeAll( result.getParsedFiles());
				files.removeAll( filesWithInvalidLocation );
				for( File f : files )
					result.loadErrors.add( new ParsingError( ErrorCode.PROJ_UNREACHABLE_FILE, f, 1 ));
			}
		}


		// Validate the entire application
		if( ! RoboconfErrorHelpers.containsCriticalErrors( result.loadErrors )) {
			Collection<ModelError> errors = RuntimeModelValidator.validate( app );
			result.loadErrors.addAll( errors );
		}

		return result;
	}
450539
public void projectOntoUnit(Vector2f b, Vector2f result) {
		float dp = b.dot(this);
		
		result.x = dp * b.getX();
		result.y = dp * b.getY();
		
	}
324749
function RedisProject(projectId, adapter) {
    var logger = adapter.logger.fork(projectId);
    this.projectId = projectId;

    this.closeProject = function (callback) {
        var deferred = Q.defer();
        deferred.resolve();
        return deferred.promise.nodeify(callback);
    };

    this.loadObject = function (hash, callback) {
        var deferred = Q.defer();
        if (typeof hash !== 'string') {
            deferred.reject(new Error('loadObject - given hash is not a string : ' + typeof hash));
        } else if (!REGEXP.HASH.test(hash)) {
            deferred.reject(new Error('loadObject - invalid hash :' + hash));
        } else {
            Q.ninvoke(adapter.client, 'hget', projectId, hash)
                .then(function (result) {
                    // Bulk string reply: the value associated with field,
                    // or nil when field is not present in the hash or key does not exist.
                    if (result) {
                        deferred.resolve(JSON.parse(result));
                    } else {
                        logger.error('object does not exist ' + hash);
                        deferred.reject(new Error('object does not exist ' + hash));
                    }
                })
                .catch(deferred.reject);
        }

        return deferred.promise.nodeify(callback);
    };

    this.insertObject = function (object, callback) {
        var deferred = Q.defer();
        if (object === null || typeof object !== 'object') {
            deferred.reject(new Error('object is not an object'));
        } else if (typeof object._id !== 'string' || !REGEXP.HASH.test(object._id)) {
            deferred.reject(new Error('object._id is not a valid hash.'));
        } else {
            Q.ninvoke(adapter.client, 'hsetnx', projectId, object._id, JSON.stringify(object))
                .then(function (result) {
                    // 1 if field is a new field in the hash and value was set.
                    // 0 if field already exists in the hash and no operation was performed.
                    if (result === 0) {
                        Q.ninvoke(adapter.client, 'hget', projectId, object._id)
                            .then(function (objectStr) {
                                var errMsg;
                                if (CANON.stringify(object) === CANON.stringify(JSON.parse(objectStr))) {
                                    logger.info('tried to insert existing hash - the two objects were equal',
                                        object._id);
                                    deferred.resolve();
                                } else {
                                    errMsg = 'tried to insert existing hash - the two objects were NOT equal ';
                                    logger.error(errMsg, {
                                        metadata: {
                                            newObject: CANON.stringify(object),
                                            oldObject: CANON.stringify(JSON.parse(objectStr))
                                        }
                                    });
                                    deferred.reject(new Error(errMsg + object._id));
                                }
                            })
                            .catch(deferred.reject);
                    } else {
                        if (object.type === CONSTANTS.COMMIT_TYPE) {
                            Q.ninvoke(adapter.client, 'hset', projectId + adapter.CONSTANTS.COMMITS,
                                object._id, object.time)
                                .then(function () {
                                    deferred.resolve();
                                })
                                .catch(deferred.reject);
                        } else {
                            deferred.resolve();
                        }
                    }
                });
        }

        return deferred.promise.nodeify(callback);
    };

    this.getBranches = function (callback) {
        return Q.ninvoke(adapter.client, 'hgetall', projectId + adapter.CONSTANTS.BRANCHES)
            .then(function (result) {
                return result || {};
            })
            .nodeify(callback);
    };

    this.getBranchHash = function (branch, callback) {
        return Q.ninvoke(adapter.client, 'hget', projectId + adapter.CONSTANTS.BRANCHES, branch)
            .then(function (branchHash) {
                return branchHash || '';
            }).nodeify(callback);
    };

    this.setBranchHash = function (branch, oldhash, newhash, callback) {
        var deferred = Q.defer(),
            branchesHashMap = projectId + adapter.CONSTANTS.BRANCHES;

        if (oldhash === newhash) {
            Q.ninvoke(adapter.client, 'hget', branchesHashMap, branch)
                .then(function (branchHash) {
                    branchHash = branchHash || '';
                    if (branchHash === oldhash) {
                        deferred.resolve();
                    } else {
                        deferred.reject(new Error('branch hash mismatch'));
                    }
                })
                .catch(deferred.reject);
        } else if (newhash === '') {
            Q.ninvoke(adapter.client, 'hget', branchesHashMap, branch)
                .then(function (branchHash) {
                    if (branchHash === oldhash) {
                        Q.ninvoke(adapter.client, 'hdel', branchesHashMap, branch)
                            .then(deferred.resolve);
                    } else if (branchHash === null) {
                        deferred.resolve();
                    } else {
                        deferred.reject(new Error('branch hash mismatch'));
                    }
                })
                .catch(deferred.reject);
        } else if (oldhash === '') {
            Q.ninvoke(adapter.client, 'hsetnx', branchesHashMap, branch, newhash)
                .then(function (result) {
                    // 1 if field is a new field in the hash and value was set.
                    // 0 if field already exists in the hash and no operation was performed.
                    if (result === 1) {
                        deferred.resolve();
                    } else {
                        deferred.reject(new Error('branch hash mismatch'));
                    }
                })
                .catch(deferred.reject);
        } else {
            Q.ninvoke(adapter.client, 'hget', branchesHashMap, branch)
                .then(function (branchHash) {
                    if (branchHash === oldhash) {
                        Q.ninvoke(adapter.client, 'hset', branchesHashMap, branch, newhash)
                            .then(function () {
                                deferred.resolve();
                            })
                            .catch(deferred.reject);
                    } else {
                        deferred.reject(new Error('branch hash mismatch'));
                    }
                })
                .catch(deferred.reject);
        }

        return deferred.promise.nodeify(callback);
    };

    this.getCommits = function (before, number, callback) {
        return Q.ninvoke(adapter.client, 'hgetall', projectId + adapter.CONSTANTS.COMMITS)
            .then(function (result) {
                var i,
                    hashArray,
                    timestamp,
                    hashKeys = Object.keys(result || {}),
                    commitsInfo = [];

                // FIXME: This is not a very optimized implementation
                for (i = 0; i < hashKeys.length; i += 1) {
                    timestamp = parseInt(result[hashKeys[i]], 10);
                    if (timestamp < before) {
                        commitsInfo.push({
                            hash: hashKeys[i],
                            time: timestamp
                        });
                    }
                }

                commitsInfo.sort(function (a, b) {
                    return b.time - a.time;
                });

                hashArray = commitsInfo.slice(0, number).map(function (commitInfo) {
                    return commitInfo.hash;
                });

                if (hashArray.length > 0) {
                    hashArray.unshift(projectId);
                    return Q.ninvoke(adapter.client, 'hmget', hashArray);
                } else {
                    return [];
                }
            })
            .then(function (commitObjects) {
                return commitObjects.map(function (commitObject) {
                    return JSON.parse(commitObject);
                });
            })
            .nodeify(callback);
    };

    this.createTag = function (name, commitHash, callback) {
        var deferred = Q.defer();

        Q.ninvoke(adapter.client, 'hsetnx', projectId + adapter.CONSTANTS.TAGS, name, commitHash)
            .then(function (result) {
                // 1 if field is a new field in the hash and value was set.
                // 0 if field already exists in the hash and no operation was performed.
                if (result === 1) {
                    deferred.resolve();
                } else {
                    deferred.reject(new Error('Tag already exists [' + name + ']'));
                }
            })
            .catch(deferred.reject);

        return deferred.promise.nodeify(callback);
    };

    this.deleteTag = function (name, callback) {
        return Q.ninvoke(adapter.client, 'hdel', projectId + adapter.CONSTANTS.TAGS, name)
            .nodeify(callback);
    };

    this.getTags = function (callback) {
        return Q.ninvoke(adapter.client, 'hgetall', projectId + adapter.CONSTANTS.TAGS)
            .then(function (result) {
                return result || {};
            })
            .nodeify(callback);
    };
}
120558
def packageDescriptor(self, dir=os.getcwd(), args=[]):
		
		
		# Verify that an Unreal project or plugin exists in the specified directory
		descriptor = self.getDescriptor(dir)
		
		# Perform the packaging step
		if self.isProject(descriptor):
			self.packageProject(dir, args[0] if len(args) > 0 else 'Shipping', args[1:])
		else:
			self.packagePlugin(dir, args)
687851
public ProjectFileHandler getProjectFile(final int projectId, final int version) {
    log.info(
        String.format("Fetching project file. project ID: %d version: %d", projectId, version));
    // TODO spyne: remove huge hack ! There should not be any special handling for Database Storage.
    if (this.storage instanceof DatabaseStorage) {
      return ((DatabaseStorage) this.storage).get(projectId, version);
    }

    /* Fetch meta data from db */
    final ProjectFileHandler pfh = this.projectLoader.fetchProjectMetaData(projectId, version);

    /* Fetch project file from storage and copy to local file */
    final String resourceId = requireNonNull(pfh.getResourceId(),
        String.format("URI is null. project ID: %d version: %d",
            pfh.getProjectId(), pfh.getVersion()));
    try (InputStream is = this.storage.get(resourceId)) {
      final File file = createTempOutputFile(pfh);

      /* Copy from storage to output stream */
      try (FileOutputStream fos = new FileOutputStream(file)) {
        IOUtils.copy(is, fos);
      }

      /* Validate checksum */
      validateChecksum(file, pfh);

      /* Attach file to handler */
      pfh.setLocalFile(file);

      return pfh;
    } catch (final IOException e) {
      throw new StorageException(e);
    }
  }
856731
public Object get(String descriptor, String[] actualReturn) {
        if (descriptor == null) {
            throw new NullPointerException("descriptor must not be null");
        }
        return getKey(createKey(descriptor), actualReturn);
    }
576159
public void loadProjects() {

        CmsObject cms = A_CmsUI.getCmsObject();
        Locale locale = UI.getCurrent().getLocale();
        m_container.removeAllItems();
        boolean isMultiOU = false;
        // hide ou column if only one ou exists
        try {
            isMultiOU = !OpenCms.getOrgUnitManager().getOrganizationalUnits(cms, "", true).isEmpty();
        } catch (CmsException e) {
            // noop
        }
        if (isMultiOU) {
            setVisibleColumns(
                CmsProjectsTable.PROP_NAME,
                CmsProjectsTable.PROP_DESCRIPTION,
                PROP_PUBLISH_DATE,
                PROP_PUBLISH_USER,
                CmsProjectsTable.PROP_ORG_UNIT,
                CmsProjectsTable.PROP_OWNER,
                CmsProjectsTable.PROP_MANAGER,
                CmsProjectsTable.PROP_USER,
                CmsProjectsTable.PROP_DATE_CREATED,
                CmsProjectsTable.PROP_RESOURCES);
        } else {
            setVisibleColumns(
                CmsProjectsTable.PROP_NAME,
                CmsProjectsTable.PROP_DESCRIPTION,
                PROP_PUBLISH_DATE,
                PROP_PUBLISH_USER,
                CmsProjectsTable.PROP_OWNER,
                CmsProjectsTable.PROP_MANAGER,
                CmsProjectsTable.PROP_USER,
                CmsProjectsTable.PROP_DATE_CREATED,
                CmsProjectsTable.PROP_RESOURCES);
        }

        // get content
        try {
            List<CmsHistoryProject> projects = cms.getAllHistoricalProjects();
            for (CmsHistoryProject project : projects) {
                Item item = m_container.addItem(new Integer(project.getPublishTag()));
                if (item != null) {
                    item.getItemProperty(CmsProjectsTable.PROP_ID).setValue(project.getUuid());
                    item.getItemProperty(CmsProjectsTable.PROP_NAME).setValue(project.getSimpleName());
                    item.getItemProperty(CmsProjectsTable.PROP_DESCRIPTION).setValue(project.getDescription());
                    item.getItemProperty(PROP_PUBLISH_DATE).setValue(new Date(project.getPublishingDate()));
                    item.getItemProperty(PROP_PUBLISH_USER).setValue(project.getPublishedByName(cms));
                    try {
                        item.getItemProperty(CmsProjectsTable.PROP_ORG_UNIT).setValue(
                            OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, project.getOuFqn()).getDisplayName(
                                locale));
                        item.getItemProperty(CmsProjectsTable.PROP_OWNER).setValue(
                            cms.readUser(project.getOwnerId()).getName());
                        item.getItemProperty(CmsProjectsTable.PROP_MANAGER).setValue(
                            cms.readGroup(project.getManagerGroupId()).getSimpleName());
                        item.getItemProperty(CmsProjectsTable.PROP_USER).setValue(
                            cms.readGroup(project.getGroupId()).getSimpleName());
                    } catch (CmsException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    item.getItemProperty(CmsProjectsTable.PROP_DATE_CREATED).setValue(
                        new Date(project.getDateCreated()));

                    StringBuffer html = new StringBuffer(512);
                    for (String resource : cms.readProjectResources(project)) {
                        html.append(resource);
                        html.append("<br />");
                    }
                    Label resLabel = new Label();
                    resLabel.setContentMode(ContentMode.HTML);
                    resLabel.setValue(html.toString());
                    item.getItemProperty(CmsProjectsTable.PROP_RESOURCES).setValue(resLabel);
                }
            }
            m_container.sort(new Object[] {PROP_PUBLISH_DATE}, new boolean[] {false});
        } catch (CmsException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
1245563
public static <R> MethodResult<R> success(R result) {
        return new MethodResult<>(result, null, false);
    }
1003514
@Override
    public void call(Result result, String prefix) {
        path(result, prefix, "java.class.path");
        path(result, prefix, "sun.boot.class.path");
        dirs(result, prefix, "java.ext.dirs");
    }
832910
static File getAppFolder(final File baseDirectory, final String configuration, final String sdk)
  {
    return new File(getBuildDir(baseDirectory), configuration + "-" + sdk);
  }
938115
private Set<String> determineReturnTypes(final MethodResult result) {
        final List<Instruction> visitedInstructions = interpretRelevantInstructions(result.getInstructions());

        // find project defined methods in invoke occurrences
        final Set<ProjectMethod> projectMethods = findProjectMethods(visitedInstructions);

        // add project methods to global method pool
        projectMethods.forEach(MethodPool.getInstance()::addProjectMethod);

        final Element returnedElement = simulator.simulate(visitedInstructions);
        if (returnedElement == null) {
            // happens for abstract methods or if there is no return
            return singleton(result.getOriginalMethodSignature().getReturnType());
        }

        return returnedElement.getTypes();
    }
840641
public static List<File> createRecipeDirectories( File applicationDirectory ) throws IOException {

		List<File> result = new ArrayList<> ();
		ApplicationLoadResult alr = RuntimeModelIo.loadApplicationFlexibly( applicationDirectory );
		if( alr.getApplicationTemplate() != null ) {
			for( Component c : ComponentHelpers.findAllComponents( alr.getApplicationTemplate())) {
				File directory = ResourceUtils.findInstanceResourcesDirectory( applicationDirectory, c );
				if( ! directory.exists())
					result.add( directory );

				Utils.createDirectory( directory );
			}
		}

		return result;
	}
897259
@SuppressWarnings("WeakerAccess")
  public CreateAppProfileRequest setDescription(@Nonnull String description) {
    proto.getAppProfileBuilder().setDescription(description);
    return this;
  }
428387
@Override
  public AppsResponse getApps(WebResource resource, ResourcePath<Apps> appsResponsePath) {
    return resource.path(appsResponsePath.getPath()).get(AppsResponse.class);
  }
1001557
private Object renderApplicationDescription() throws IOException {

		// No locale? => Display the application's description.
		// Otherwise, read app.desc_fr_FR.txt or the required file for another locale.
		// If it does not exist, return the empty string.

		String s;
		if( this.locale == null
				&& ! Utils.isEmptyOrWhitespaces( this.applicationTemplate.getDescription()))
			s = this.applicationTemplate.getDescription();
		else
			s = readCustomInformation( this.applicationDirectory, DocConstants.APP_DESC_PREFIX, DocConstants.FILE_SUFFIX );

		String result = "";
		if( ! Utils.isEmptyOrWhitespaces( s ))
			result = renderParagraph( s );

		return result;
	}
12938
public static Class<?> loadProjectClass(Project project, String className) {
        URLClassLoader classLoader = getProjectClassLoader(project);
        if (classLoader != null ){
            try {
                return classLoader.loadClass(className);
            } catch (ClassNotFoundException e) {
                // ignore
            } finally {
                try {
                    classLoader.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        }
        return null;
    }
481508
@Override
  public AppResponse getApp(WebResource resource, ResourcePath<App> appResourcePath) {
    return resource.path(appResourcePath.getPath()).get(AppResponse.class);
  }