/*
 * Copyright (c) 2012-2017 Red Hat, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
package org.eclipse.che.workspace.infrastructure.openshift.project;

import static com.google.common.base.MoreObjects.firstNonNull;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import javax.inject.Named;
import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity;
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
import org.eclipse.che.commons.annotation.Nullable;
import org.eclipse.che.workspace.infrastructure.openshift.OpenShiftClientFactory;

/**
 * Helps to create {@link OpenShiftProject} instances.
 *
 * @author Anton Korneta
 */
@Singleton
public class OpenShiftProjectFactory {

  private final String projectName;
  private final OpenShiftClientFactory clientFactory;

  @Inject
  public OpenShiftProjectFactory(
      @Nullable @Named("che.infra.openshift.project") String projectName,
      OpenShiftClientFactory clientFactory) {
    this.projectName = projectName;
    this.clientFactory = clientFactory;
  }

  public OpenShiftProject create(RuntimeIdentity identity) throws InfrastructureException {
    final String workspaceId = identity.getWorkspaceId();
    final String projectName = firstNonNull(this.projectName, workspaceId);
    return new OpenShiftProject(clientFactory, projectName, workspaceId);
  }
}

@@ -469,32 +469,29 @@
 ase.
-MoreObjects.firstNonNull
+Strings.isNullOrEmpty
 ;%0A%0Ai
@@ -1529,20 +1529,21 @@
 e = 
-firstNonNull
+isNullOrEmpty
 (thi
@@ -1547,33 +1547,35 @@
 this.projectName
-,
+) ?
  workspaceId);%0A 
@@ -1566,25 +1566,43 @@
  workspaceId
-)
+ : this.projectName
 ;%0A    return

Use the workspace id as OpenShift project name when provided value is empty