当前位置: 首页>>代码示例>>Java>>正文


Java Project类代码示例

本文整理汇总了Java中de.espirit.firstspirit.access.project.Project的典型用法代码示例。如果您正苦于以下问题:Java Project类的具体用法?Java Project怎么用?Java Project使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Project类属于de.espirit.firstspirit.access.project包,在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: activateProjectIfNecessary

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static void activateProjectIfNecessary(ProjectImportParameters projectImportParameters, Project fsProject) {
    boolean projectIsActive = fsProject.isActive();
    if (projectImportParameters.isFsForceProjectActivation()) {
        if (!projectIsActive) {
            LOGGER.warn("Project '" + projectImportParameters.getProjectName() + "' is not active! Try to activate...");
            UserService userService = fsProject.getUserService();
            AdminService adminService = userService.getConnection().getService(AdminService.class);
            adminService.getProjectStorage().activateProject(fsProject);
        }
        if(!fsProject.isActive()) {
            throw new ExecutionException("Project with name '"
                    + projectImportParameters.getProjectName()
                    + "' seems to be deactivated! To force activation, configure fsForceProjectActivation with true!");
        }
    }
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:17,代码来源:ProjectImporter.java

示例2: performDeletion

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
@SuppressWarnings("squid:S2221")
private static boolean performDeletion(Project project, ProjectStorage projectStorage) {
    try {
        LOGGER.debug("Deactivate project.");
        projectStorage.deactivateProject(project);
        LOGGER.debug("Project was locked and deactivated.");
        LOGGER.debug("Remove Project.");
        projectStorage.refreshProjects();
        projectStorage.removeProject(project);
        projectStorage.refreshProjects();
    } catch (Exception e) {
        LOGGER.error("Cannot delete project!", e);
        return false;
    }
    LOGGER.info("Successfully deleted project from server!");
    return true;
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:18,代码来源:ProjectDeleter.java

示例3: testProjectExistsOnServerReturnsTrueIfProjectExists

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
 * Test that projectExistsOnServer is true if a project exists.
 */
@Test
public void testProjectExistsOnServerReturnsTrueIfProjectExists() {
    // Arrange
    final Project mockProject = mock(Project.class);
    final ServerConnection mockConnection = mock(ServerConnection.class);
    when(mockConnection.isConnected()).thenReturn(true);
    when(mockConnection.getProjectByName(anyString())).thenReturn(mockProject);

    final ProjectExportParameters mockProjectExportParameters = mock(ProjectExportParameters.class);
    when(mockProjectExportParameters.getProjectName()).thenReturn("anyString");

    // Act
    final boolean projectExists = testling.projectExistsOnServer(mockConnection, mockProjectExportParameters);

    // Assert
    assertThat("Expected equal.", projectExists, equalTo(true));
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:21,代码来源:ProjectExporterTest.java

示例4: testPerformExportProjectIsNotActiveAndActivationWasNotForced

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
 * Test that export fails if the project is not active and will not be forced to be active.
 */
@Test
public void testPerformExportProjectIsNotActiveAndActivationWasNotForced() {
    // Arrange
    final Project mockProject = mock(Project.class);
    when(mockProject.isActive()).thenReturn(false);

    final ProjectExportParameters mockProjectExportParameters = mock(ProjectExportParameters.class);
    when(mockProjectExportParameters.isFsForceProjectActivation()).thenReturn(false);

    final ServerConnection mockConnection = mock(ServerConnection.class);
    when(mockConnection.getProjectByName(mockProjectExportParameters.getProjectName())).thenReturn(mockProject);

    // Act
    final boolean exported = testling.performExport(mockConnection, mockProjectExportParameters);

    // Assert
    assertThat("Expect equals", exported, is(false));
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:22,代码来源:ProjectExporterTest.java

示例5: testPerformExportProjectWhenActivationFails

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
 * Test that export fails if the project could not be activated by the FirstSpirit server.
 */
@Test
public void testPerformExportProjectWhenActivationFails() {
    // Arrange
    final Project mockProject = mock(Project.class);
    when(mockProject.isActive()).thenReturn(false);

    final ProjectExportParameters mockProjectExportParameters = mock(ProjectExportParameters.class);
    when(mockProjectExportParameters.isFsForceProjectActivation()).thenReturn(true);

    final ServerConnection mockConnection = mock(ServerConnection.class);
    when(mockConnection.getProjectByName(mockProjectExportParameters.getProjectName())).thenReturn(mockProject);

    final ProjectExporter spyProjectExporter = spy(testling);
    doReturn(false).when(spyProjectExporter).activateProjectByForce(mockConnection, mockProject);

    // Act
    final boolean exported = spyProjectExporter.performExport(mockConnection, mockProjectExportParameters);

    // Assert
    assertThat("Expect equals", exported, is(false));
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:25,代码来源:ProjectExporterTest.java

示例6: testActivateProjectByForceCallsAdminService

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
 * Test that the AdminService tries to activate the project.
 */
@Test
public void testActivateProjectByForceCallsAdminService() {
    // Arrange
    final Project mockProject = mock(Project.class);

    final ProjectStorage mockProjectStorage = mock(ProjectStorage.class);
    final AdminService mockAdminService = mock(AdminService.class);
    when(mockAdminService.getProjectStorage()).thenReturn(mockProjectStorage);

    final ServerConnection mockConnection = mock(ServerConnection.class);
    when(mockConnection.getService(AdminService.class)).thenReturn(mockAdminService);

    // Act
    testling.activateProjectByForce(mockConnection, mockProject);

    // Assert
    verify(mockProjectStorage).activateProject(mockProject);
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:22,代码来源:ProjectExporterTest.java

示例7: installWebAppAndActivateWebServer

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static boolean installWebAppAndActivateWebServer(final WebScope webScope, final long projectId,
                                                         final Connection connection, final WebAppId webAppId) {

    final Project project = connection.getProjectById(projectId);

    try {
        ModuleAdminAgent moduleAdminAgent = connection.getBroker().requireSpecialist(ModuleAdminAgent.TYPE);
        boolean successfullyDeployed = moduleAdminAgent.deployWebApp(webAppId);
        if (!setActiveWebServerForProject(webScope, project) || !successfullyDeployed){
            return false;
        }

    } catch (IllegalStateException ise) {
        LOGGER.error("Cannot deploy war file!", ise);
        return false;
    }
    return true;
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:19,代码来源:ModuleInstaller.java

示例8: requireProjectSpecificBroker

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private void requireProjectSpecificBroker() {
    LOGGER.debug("Require project specific specialist broker for project '{}'...", clientConfig.getProject());

    String name;
    try {
        final Project project = getProject();
        name = project != null ? project.getName() : null;
    } catch (Exception e) { //NOSONAR
        throw new IllegalStateException(
            "Project '" + clientConfig.getProject() + "' not found on server. Correct project name or omit --dont-create-project option.", e);
    }

    if (StringUtils.isNotBlank(name)) {
        final SpecialistsBroker broker = connection.getBroker();
        final BrokerAgent brokerAgent = broker.requireSpecialist(BrokerAgent.TYPE);
        projectBroker = brokerAgent.getBrokerByProjectName(name);
    }
    if (projectBroker == null) {
        throw new IllegalStateException("ProjectBroker cannot be retrieved for project " + name + ". Wrong project name?");
    }
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:22,代码来源:CliContextImpl.java

示例9: getProject

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
@Override
public Project getProject() {
    final String projectName = clientConfig.getProject();
    if (StringUtils.isBlank(projectName)) {
        return null;
    }
    Project project = connection.getProjectByName(projectName);
    if (project == null && clientConfig.isCreatingProjectIfMissing()) {
        project = createProject(projectName);
    }
    LOGGER.debug("activate project if deactivated: " + clientConfig.isActivateProjectIfDeactivated(), projectName);
    if (clientConfig.isActivateProjectIfDeactivated()) {
        activateProject(projectName, project);
    }
    LOGGER.info("project is '{}'", project);
    return project;
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:18,代码来源:CliContextImpl.java

示例10: execute

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
@Override
public ContentCreatorAddressResult execute(ContentCreatorAddressParameters parameters) {
    final Connection connection = parameters.getConnection();
    final Project project = connection.getProjectByName(parameters.getProjectName());
    final long projectId = project.getId();
    final Locale locale = Optional.ofNullable(parameters.getLocale()).orElse(project.getMasterLanguage().getLocale());
    final String language = locale.getLanguage();
    final String contentCreatorUrl =
        connection.getServerConfiguration().getUrl() + "fs5webedit_" + projectId + "/?locale=" + language + "&project=" + projectId;
    return new ContentCreatorAddressResult(contentCreatorUrl);
}
 
开发者ID:e-Spirit,项目名称:FSTestTools,代码行数:12,代码来源:ContentCreatorAddressCommand.java

示例11: performImport

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static boolean performImport(Connection connection, ProjectImportParameters projectImportParameters) {
    ProjectStorage projectStorage = connection.getService(AdminService.class).getProjectStorage();
    try {
        removeExportFileFromServerIfExists(projectImportParameters, projectStorage);
        ExportFile exportFile;
        try (FileInputStream fileInputStream = new FileInputStream(projectImportParameters.getProjectFile())) {
            exportFile = projectStorage.uploadExportFile(projectImportParameters.getProjectFile().getName(), fileInputStream);
        }
        ProjectInfo info = projectStorage.getProjectInfo(exportFile);

        HashMap<String, String> layerMapping = getLayerMappingDefinition(projectImportParameters, info);

        ImportParameters importParameters = new ImportParameters(exportFile, info,
                projectImportParameters.getProjectName(), projectImportParameters.getProjectDescription(), layerMapping,
                new HashMap<>());
        importParameters.getLayerMapping();
        ServerActionHandle<ImportProgress, Boolean> importHandle = projectStorage.startImport(importParameters);
        waitUntilImportFinished(importHandle);
        refreshProjects(connection);

        Project fsProject = connection.getProjectByName(projectImportParameters.getProjectName());
        boolean projectIsPresent = fsProject != null;
        if (projectIsPresent) {
            activateProjectIfNecessary(projectImportParameters, fsProject);
        }

        return projectIsPresent;
    } catch (ExecutionException | IOException e) {
        LOGGER.error("Not able to perform import!", e);
        return false;
    }
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:33,代码来源:ProjectImporter.java

示例12: projectExistsOnServer

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static boolean projectExistsOnServer(Connection connection, ProjectImportParameters projectImportParameters) {
    Project[] projects = connection.getProjects();
    if (projects == null || projects.length < 1) {
        LOGGER.debug("Could not find any projects on the server.");
        return false;
    }
    for (Project project: connection.getProjects()) {
        LOGGER.debug("Found project: "+project.getName());
        if (project.getName().equals(projectImportParameters.getProjectName())) {
            return true;
        }
    }
    LOGGER.debug("Could not find project "+ projectImportParameters.getProjectName());
    return false;
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:16,代码来源:ProjectImporter.java

示例13: deleteProject

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
/**
 * This methods deletes a FirstSpirit project from a server
 * @param connection to the FirstSpirit server
 * @param projectName of the project you want to delete
 * @return true if the project was deleted successfully, false otherwise.
 * @throws ExecutionException If a project with the given name does not exist on the server or it does exists, but cannot be locked.
 */
public boolean deleteProject(Connection connection, String projectName) {
    LOGGER.info("Start deleting project: '{}'", projectName);
    if (connection == null) {
        LOGGER.error("Connection is not set!");
        throw new IllegalArgumentException("Connection is null.");
    }

    Project project = connection.getProjectByName(projectName);
    if (project == null) {
        LOGGER.error("Cannot find project!");
        throw new ExecutionException(EXCEPTIONSTRING + projectName + " does not exist on server.");
    }

    LOGGER.debug("Lock project");
    try {
        project.lock();
        LOGGER.debug("Project is locked.");
    } catch (LockException e) {
        LOGGER.error("Cannot lock project. ", e);
        throw new ExecutionException(EXCEPTIONSTRING + projectName + " could not be locked.");
    }

    ProjectStorage projectStorage = returnProjectStorage(connection, project);
    if (projectStorage == null) {
        LOGGER.error("Cannot process deletion. Preparation failed.");
        throw new ExecutionException(EXCEPTIONSTRING + "ProjectStorage is missing.");
    }
    return performDeletion(project, projectStorage);
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:37,代码来源:ProjectDeleter.java

示例14: returnProjectStorage

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
@VisibleForTesting
ProjectStorage returnProjectStorage (Connection connection,  Project project) {
    if (connection == null || !canAccessProject(connection, project)) {
        LOGGER.info("Cannot access project.");
        return null;
    }

    ProjectStorage projectStorage = connection.getBroker().requireSpecialist(ServicesBroker.TYPE).getService(AdminService.class).getProjectStorage();
    if (projectStorage == null) {
        LOGGER.info("Cannot access project storage.");
    }
    return projectStorage;
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:14,代码来源:ProjectDeleter.java

示例15: canAccessProject

import de.espirit.firstspirit.access.project.Project; //导入依赖的package包/类
private static boolean canAccessProject(Connection connection,  Project project) {
    if (connection.getProjects().length < 1 || project == null) {
        LOGGER.info("Cannot find project on server.");
        return false;
    }
    return true;
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:8,代码来源:ProjectDeleter.java


注:本文中的de.espirit.firstspirit.access.project.Project类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。