Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
wip unstaged
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Oct 20, 2016
1 parent 561f05a commit 9bfda47
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 813 deletions.
2 changes: 1 addition & 1 deletion zanata-war/pom.xml
Expand Up @@ -388,7 +388,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dconcordion.output.dir=${concordion.output.dir} -XX:MaxPermSize=256m</argLine>
<argLine>-Dconcordion.output.dir=${concordion.output.dir}</argLine>
<testNGArtifactName>none:none</testNGArtifactName>
<!-- TODO ensure that stateful tests (eg using Hibernate Search)
are isolated, or rename them to ITCase (Arquillian), and
Expand Down
Expand Up @@ -29,9 +29,11 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.core.EntityTag;

import org.apache.commons.lang.StringUtils;
import org.hibernate.NaturalIdLoadAccess;
import org.hibernate.Query;
import org.hibernate.Session;
import org.zanata.common.ContentState;
Expand Down Expand Up @@ -67,9 +69,10 @@ public ProjectIterationDAO(Session session) {
@Nullable
public HProjectIteration getBySlug(@Nonnull String projectSlug,
@Nonnull String iterationSlug) {
NaturalIdLoadAccess loader =
getSession().byNaturalId(HProject.class);
HProject project =
(HProject) getSession().byNaturalId(HProject.class)
.using("slug", projectSlug).load();
(HProject) loader.using("slug", projectSlug).load();
return getBySlug(project, iterationSlug);
}

Expand All @@ -87,7 +90,7 @@ public HProjectIteration getBySlug(@Nonnull HProject project,
public List<HProjectIteration> getByProjectSlug(
@Nonnull String projectSlug, EntityStatus... includeStatus) {
if (StringUtils.isEmpty(projectSlug)) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("from HProjectIteration version where ").
Expand Down
18 changes: 18 additions & 0 deletions zanata-war/src/main/java/org/zanata/file/DocumentUploadUtil.java
Expand Up @@ -249,6 +249,12 @@ protected static boolean isSinglePart(DocumentFileUploadForm uploadForm) {
return uploadForm.getFirst() && uploadForm.getLast();
}

/**
* Note: the caller is responsible for deleting the temp file.
* @param upload
* @param finalPart
* @return
*/
public File combineToTempFileAndDeleteUploadRecord(HDocumentUpload upload,
DocumentFileUploadForm finalPart) {
File tempFile;
Expand All @@ -271,6 +277,13 @@ public File combineToTempFileAndDeleteUploadRecord(HDocumentUpload upload,
return tempFile;
}

/**
* Note: the caller is responsible for deleting the temp file.
* @param upload
* @param finalPart
* @return
* @throws SQLException
*/
private File
combineToTempFile(HDocumentUpload upload, DocumentFileUploadForm finalPart)
throws SQLException {
Expand Down Expand Up @@ -313,6 +326,11 @@ protected boolean isNewDocument(GlobalDocumentId id) {
id.getVersionSlug(), id.getDocId()) == null;
}

/**
* Note: the caller is responsible for deleting the temp file.
* @param uploadForm
* @return
*/
protected File persistTempFileFromUpload(DocumentFileUploadForm uploadForm) {
File tempFile;
try {
Expand Down
11 changes: 8 additions & 3 deletions zanata-war/src/main/java/org/zanata/rest/Application.java
Expand Up @@ -19,7 +19,7 @@

@ApplicationPath("/rest")
@ApplicationScoped
@Slf4j
//@Slf4j
public class Application extends javax.ws.rs.core.Application {

private Set<Class<?>> classes = buildClassesSet();
Expand All @@ -37,10 +37,10 @@ public Set<Class<?>> getClasses() {
*/
private static Set<Class<?>> buildClassesSet() {
Iterable<Class<?>> pathClasses = ClassIndex.getAnnotated(Path.class);
log.debug("Indexed @Path classes: {}", pathClasses);
// log.debug("Indexed @Path classes: {}", pathClasses);
assert pathClasses.iterator().hasNext();
Iterable<Class<?>> providerClasses = ClassIndex.getAnnotated(Provider.class);
log.debug("Indexed @Provider classes: {}", providerClasses);
// log.debug("Indexed @Provider classes: {}", providerClasses);
assert providerClasses.iterator().hasNext();
return concat(
stream(pathClasses),
Expand All @@ -55,4 +55,9 @@ private static Set<Class<?>> buildClassesSet() {
private static <T> Stream<T> stream(Iterable<T> iterable) {
return StreamSupport.stream(iterable.spliterator(), false);
}

public static void main(String[] args) {
Set<Class<?>> classes = buildClassesSet();
classes.forEach(System.out::println);
}
}

0 comments on commit 9bfda47

Please sign in to comment.