Creates a new app on a space.

@param app
The definition for the new app
@return The id of the newly created app
549844
public int addApp(ApplicationCreate app) {
		return getResourceFactory().getApiResource("/app/")
				.entity(app, MediaType.APPLICATION_JSON_TYPE)
				.post(ApplicationCreateResponse.class).getId();
	}
1327974
@Override
    public Application onApplicationInit(Application app, JaxRsModuleMetaData metaData) {

        Class<?> clazz = app.getClass();

        if (!shouldHandle(clazz, true)) {
            return null;
        }
        Application newApp = null;

        ManagedObject<?> mo = getClassFromManagedObject(clazz);
        metaData.setManagedAppRef(mo);

        if (mo != null) {
            newApp = (Application) (mo.getObject());
        }

        if (newApp == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "App: app is null from CDI , get app from rs for " + app.getClass().getName());
            }
            return app;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "App: get app from CDI " + app.getClass().getName());
        }
        return newApp;
    }
1279090
public void addApplication(App application)
    {
Utility.getLogger().info("addApp: " + application);
        m_vApplication.add(application);
        ((BaseApplication)application).setEnvironment(this);
        if ((m_applicationDefault == null)
                || ((!(m_applicationDefault instanceof MainApplication))) && (application instanceof MainApplication))
            this.setDefaultApplication(application);        // Initialization app
    }
1138236
@Override
	public Response createApplication( Application app ) {

		this.logger.fine( "Request: create application " + app + "." );
		Response result;
		try {
			String tplName = app.getTemplate() == null ? null : app.getTemplate().getName();
			String tplQualifier = app.getTemplate() == null ? null : app.getTemplate().getVersion();
			String appName = app.getDisplayName() != null ? app.getDisplayName() : app.getName();
			ManagedApplication ma = this.manager.applicationMngr().createApplication( appName, app.getDescription(), tplName, tplQualifier );
			result = Response.ok().entity( ma.getApplication()).build();

		} catch( InvalidApplicationException e ) {
			result = handleError(
					Status.NOT_FOUND,
					new RestError( REST_MNGMT_INVALID_TPL, e, application( app )),
					lang( this.manager )).build();

		} catch( AlreadyExistingException e ) {
			result = handleError(
					Status.FORBIDDEN,
					new RestError( REST_MNGMT_CONFLICT, e, application( app )),
					lang( this.manager )).build();

		} catch( IOException e ) {
			result = handleError(
					Status.UNAUTHORIZED,
					new RestError( REST_SAVE_ERROR, e, application( app )),
					lang( this.manager )).build();
		}

		return result;
	}
147459
def get_space_id(deployment_name,
                 space_name,
                 token_manager=None,
                 app_url=defaults.APP_URL):
    
    spaces = get_spaces(deployment_name,
                        token_manager=token_manager,
                        app_url=app_url)

    for space in spaces:
        if space['name'] == space_name:
            return space['id']

    raise JutException('Unable to find space "%s" within deployment "%s"' %
                    (space_name, deployment_name))
901677
public String addId(final URI id) {
        if (id == null) {
            return null;
        }
        final URI localId = id.normalize();
        index ++;
        final String newId = PREFIX + Integer.toString(index);
        idMap.put(localId, newId);
        return newId;
    }
33661
@Override
    public void initializeApplication(ApplicationDefinition oldAppDef,
                                      ApplicationDefinition appDef) {
        checkServiceState();
        Tenant tenant = Tenant.getTenant(appDef);
        m_olap.createApplication(tenant, appDef.getAppName());
    }
1170566
public static Response getCreateResponse(App app, String type, InputStream is) {
		try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
				RestUtils.class, "crud", "create")) {
			ParaObject content;
			Response entityRes = getEntity(is, Map.class);
			if (entityRes.getStatusInfo() == Response.Status.OK) {
				Map<String, Object> newContent = (Map<String, Object>) entityRes.getEntity();
				String declaredType = (String) newContent.get(Config._TYPE);
				if (!StringUtils.isBlank(type) && (StringUtils.isBlank(declaredType) || !type.startsWith(declaredType))) {
					newContent.put(Config._TYPE, type);
				}
				content = ParaObjectUtils.setAnnotatedFields(newContent);
				if (app != null && content != null && isNotAnApp(type)) {
					warnIfUserTypeDetected(type);
					content.setAppid(app.getAppIdentifier());
					setCreatorid(app, content);
					int typesCount = app.getDatatypes().size();
					app.addDatatypes(content);
					// The reason why we do two validation passes is because we want to return
					// the errors through the API and notify the end user.
					// This is the primary validation pass (validates not only core POJOS but also user defined objects).
					String[] errors = validateObject(app, content);
					if (errors.length == 0) {
						// Secondary validation pass called here. Object is validated again before being created
						// See: IndexAndCacheAspect.java
						String id = content.create();
						if (id != null) {
							// new type added so update app object
							if (typesCount < app.getDatatypes().size()) {
								app.update();
							}
							return Response.created(URI.create(Utils.urlEncode(content.getObjectURI()))).
									entity(content).build();
						}
					}
					return getStatusResponse(Response.Status.BAD_REQUEST, errors);
				}
				return getStatusResponse(Response.Status.BAD_REQUEST, "Failed to create object.");
			}
			return entityRes;
		}
	}
367210
public Object newInstanceWithId(final Object id)
	{
		try
		{
			final Object o = clazz.newInstance();

			idProperty.set(o, id);

			return o;
		}
		catch (Throwable e)
		{
			throw new RuntimeException("Cannot create new instance of " +
			                           clazz +
			                           " with ID " +
			                           id +
			                           " (of type " +
			                           id.getClass() +
			                           ") populated!", e);
		}
	}
1152316
@Override
    public void initializeApplication(ApplicationDefinition oldAppDef,
                                      ApplicationDefinition appDef) {
        checkServiceState();
        OLAPService.instance().initializeApplication(oldAppDef, appDef);
    }
202661
public void deactivateApp(int appId) {
		getResourceFactory().getApiResource("/app/" + appId + "/deactivate")
				.entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post();
	}
1021720
public static Application create(final String name) throws Exception{
    	final Map<String, Object> params = new HashMap<String, Object>();
    	params.put("name", name);
    	
    	return create(params);
    }
992867
@Override
    public String getLayoutContentByAppId(String appId) {
        String value = propertyService.getValue(PROPERTY_LAYOUT_ASSOCIATION, appId);
        return value == null ? null : getLayoutContent(new LayoutIdentifier(value, true));
    }
687983
public static Application get(final BandwidthClient client, final String id) throws Exception {
        assert(id != null);
        final String applicationUri = client.getUserResourceInstanceUri(BandwidthConstants.APPLICATIONS_URI_PATH, id);
        final JSONObject applicationObj = toJSONObject( client.get(applicationUri, null) );
        
        final Application application = new Application(client, applicationObj);
        return application;
    }
1265210
def get_app_guid(self, app_name):
        
        summary = self.space.get_space_summary()
        for app in summary['apps']:
            if app['name'] == app_name:
                return app['guid']
1030614
public static Actor app(String appId) {
		Assert.notNull(appId, "appId must not be null");
		return new Actor(APP, appId);
	}
464064
public List<Application> getAppsOnSpace(int spaceId) {
		return getResourceFactory().getApiResource(
				"/app/space/" + spaceId + "/").get(
				new GenericType<List<Application>>() {
				});
	}