Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Fixed download URL challenge #465

Merged
merged 16 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,14 @@ jobs:
wget http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip
unzip jboss-4.2.3.GA-jdk6.zip
cd project
- run:
name: checking out build repo
command: |
git clone --branch master https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
#git clone --branch master git@github.com:appirio-tech/ops.git ../direct-config-update
#git clone --branch master https://$GITUSER:$GITPASSWD@github.com/appirio-tech/ops ../direct-config-update
- checkout
- run:
name: copying configuration file
command: |
cp ./../buildscript/direct/conf/dev/token.properties.enc .
openssl enc -aes-256-cbc -d -in token.properties.enc -out token.properties -k $SECPASSWD
- run:
name: Installation of build dependencies.
command: |
javac -version
ant -version
aws --version
./buildproperties.sh -e DEV -k directapp
ant package-direct package-static-direct
- store_artifacts:
path: ./direct.jar
Expand Down Expand Up @@ -148,24 +138,14 @@ jobs:
wget http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip
unzip jboss-4.2.3.GA-jdk6.zip
cd project
- run:
name: checking out build repo
command: |
git clone --branch master https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
#git clone --branch master git@github.com:appirio-tech/ops.git ../direct-config-update
#git clone --branch master https://$GITUSER:$GITPASSWD@github.com/appirio-tech/ops ../direct-config-update
- checkout
- run:
name: copying configuration file
command: |
cp ./../buildscript/direct/conf/prod/token.properties.enc .
openssl enc -aes-256-cbc -d -in token.properties.enc -out token.properties -k $SECPASSWD
- run:
name: Installation of build dependencies.
command: |
javac -version
ant -version
aws --version
./buildproperties.sh -e PROD -k directapp
ant package-direct package-static-direct
- store_artifacts:
path: ./direct.jar
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ direct-app
==========

## building
To build, download the docker build container that has all of the build dependencies. You can then run the container to build your local source code.
To build, download the docker build container that has all of the build dependencies. You can then run the container to build your local source code.

1. Clone the github source directory
2. Rename `token.properties.docker` to `token.properties` in the source directory
Expand Down
3 changes: 2 additions & 1 deletion build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ then
fi

VER=`date "+%Y%m%d%H%M"`
SCRIPTDIR="./scripts"

directapp_cdpacakge()
{
Expand All @@ -16,7 +17,7 @@ directapp_cdpacakge()
source $BUILD_VARIABLE_FILE_NAME
AWS_CD_PACKAGE_NAME="${APPNAME}-${PACKAGETYPE}-${VER}.zip"
PACAKAGE_LOCATION="dist-${PACKAGETYPE}"
SCRIPTDIR="./../buildscript/direct/scripts"
# SCRIPTDIR="./../buildscript/direct/scripts"
rm -rf $PACAKAGE_LOCATION
mkdir $PACAKAGE_LOCATION
#cd $PACAKAGE_LOCATION
Expand Down
4 changes: 3 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
<include name="phase_templates/**/*.xml" />
<include name="xml_phase_template.xsd" />
<include name="AwsCredentials.properties" />
<include name="AwsS3Credentials.properties" />
<include name="contest_creation_sns_message.txt" />
<include name="contest_update_sns_message.txt" />
</fileset>
Expand Down Expand Up @@ -526,7 +527,8 @@
<copy file="${tokenized_conf}/direct-ds.xml" todir="${jboss.home}/server/${server.name}/deploy" overwrite="true"/>
<copy todir="${jboss.home}/server/${server.name}/conf" overwrite="true">
<fileset dir="${tokenized_conf}">
<include name="ApplicationServer.properties" />
<include name="AwsS3Credentials.properties" />
<include name="ApplicationServer.properties" />
<include name="DBMS.properties" />
<include name="DataAccess.properties" />
<include name="cache.properties" />
Expand Down
103 changes: 103 additions & 0 deletions buildproperties.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash
KEY_LOCATION=""
BUILDENV_LIST=""
usage()
{
cat << EOF
usage: $0 options
This script need to be executed with below option.
OPTIONS:
-e environment
-b Security file location GIT|AWS
-k key location
EOF
}
#log Function - Used to provide information of execution information with date and time
log()
{
echo "`date +'%D %T'` : $1"
}
track_error()
{
if [ $1 != "0" ]; then
log "$2 exited with error code $1"
log "completed execution IN ERROR at `date`"
exit $1
fi

}
download_buildenvfile()
{
if [ -z "$BUILDENV_LIST" ];
then
if [ -z "$KEY_LOCATION" ];
then
track_error $? "Please provide the file list using -b or file location -k or both -b and -k "
else
aws s3 sync s3://tc-buildproperties-${ENV_CONFIG}/$KEY_LOCATION .
track_error $? "Environment setting"
fi

else
Buffer_seclist=$(echo $BUILDENV_LIST | sed 's/,/ /g' )
for listname in $Buffer_seclist;
do
if [ -z "$KEY_LOCATION" ];
then
aws s3 cp s3://tc-buildproperties-${ENV_CONFIG}/$listname .
track_error $? "Environment setting"
else
aws s3 cp s3://tc-buildproperties-${ENV_CONFIG}/$KEY_LOCATION/$listname .
track_error $? "Environment setting"
fi
done
fi

}

configure_aws_cli() {
aws --version
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
aws configure set default.region $AWS_REGION
aws configure set default.output json
log "Configured AWS CLI."
}

while getopts .b:e:k:. OPTION
do
case $OPTION in
e)
ENV=$OPTARG
;;
b)
BUILDENV_LIST=$OPTARG
;;
k)
KEY_LOCATION=$OPTARG
;;
?)
log "additional param required"
usage
exit
;;
esac
done

AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV}_AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV}_AWS_SECRET_ACCESS_KEY")
AWS_REGION=$(eval "echo \$${ENV}_AWS_REGION")
if [ -z $AWS_REGION ];
then
AWS_REGION="us-east-1"
fi
if [ -z $AWS_ACCESS_KEY_ID ] || [ -z $AWS_SECRET_ACCESS_KEY ] ;
then
log "AWS Secret Parameters are not configured in circleci/environment"
usage
exit 1
else
configure_aws_cli
fi
ENV_CONFIG=`echo "$ENV" | tr '[:upper:]' '[:lower:]'`
download_buildenvfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006,2010 TopCoder Inc., All Rights Reserved.
* Copyright (C) 2006 - 2018 TopCoder Inc., All Rights Reserved.
*/
package com.topcoder.management.deliverable;

Expand All @@ -19,9 +19,13 @@
* This class is highly mutable. All fields can be changed.
* </p>
*
* <p>
* Version 1.3 - Topcoder - Change Download URL in Direct Application
* - Add url property
* </p>
* @author aubergineanode, singlewood
* @author TCSDESIGNER, TCSDEVELOPER
* @version 1.2
* @version 1.3
*/
public class Upload extends AuditedDeliverableStructure {
/**
Expand Down Expand Up @@ -93,6 +97,12 @@ public class Upload extends AuditedDeliverableStructure {
*/
private String description;

/**
* Represent the s3 url
*
*/
private String url;

/**
* Creates a new Upload.
*/
Expand Down Expand Up @@ -267,4 +277,22 @@ public boolean isValidToPersist() {
&& (parameter != null)
&& (super.isValidToPersist()));
}

/**
* Get url
*
* @return url
*/
public String getUrl() {
return url;
}

/**
* Set url
*
* @param url url
*/
public void setUrl(String url) {
this.url = url;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2012 TopCoder Inc., All Rights Reserved.
* Copyright (C) 2006-2018 TopCoder Inc., All Rights Reserved.
*/
package com.topcoder.management.deliverable.persistence.sql;

Expand Down Expand Up @@ -193,7 +193,14 @@
* <li>Update {@link #loadUpload(CustomResultSet)} to load the project phase id.</li>
* </ol>
* </p>
*
*
* <p>
* Version 1.6 - Topcoder - Change Download URL in Direct Application
* <ol>
* <li>Update {@link #loadUpload(CustomResultSet)} to load url.</li>
* </ol>
* </p>
*
* <strong>Thread Safety:</strong> This class is immutable and thread-safe in the sense that multiple threads can not
* corrupt its internal data structures. However, the results if used from multiple threads can be unpredictable as the
* database is changed from different threads. This can equally well occur when the component is used on multiple
Expand All @@ -202,7 +209,7 @@
*
* @author aubergineanode, saarixx, urtks, George1
* @author TCSDESIGNER, TCSDEVELOPER
* @version 1.5
* @version 1.6
*/
public class SqlUploadPersistence implements UploadPersistence {

Expand Down Expand Up @@ -2525,6 +2532,7 @@ private Upload loadUpload(CustomResultSet resultSet) throws UploadPersistenceExc
upload.setCreationTimestamp(resultSet.getDate("upload_create_date"));
upload.setModificationUser(resultSet.getString("upload_modify_user"));
upload.setModificationTimestamp(resultSet.getDate("upload_modify_date"));
upload.setUrl(resultSet.getString("upload_url"));

upload.setProject(resultSet.getLong("project_id"));
if (resultSet.getObject("project_phase_id") != null) {
Expand Down
2 changes: 2 additions & 0 deletions conf/AwsS3Credentials.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accessKey = @aws_s3_access_key@
secretKey = @aws_s3_secret_key@
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ com.cronos.onlinereview.services.uploads.impl.DefaultManagersProvider = onlineRe
com.cronos.onlinereview.services.uploads.impl.DefaultUploadServices = onlineReviewUpload_config.xml
com.cronos.onlinereview.services.uploads.impl.DefaultUploadExternalServices = onlineReviewUpload_config.xml
com.topcoder.servlet.request.LocalFileUpload = onlineReviewUpload_config.xml
com.topcoder.servlet.request.LocalStudioFileUpload = onlineReviewUpload_config.xml

com.topcoder.project.service.ProjectServicesFactory = projectServices_config.xml
com.topcoder.project.service.impl.ProjectServicesImpl = projectServices_config.xml
Expand Down
1 change: 1 addition & 0 deletions conf/objectFactory_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@
upload.resource_id AS resource_id,
upload.project_phase_id AS project_phase_id,
upload.parameter AS upload_parameter,
upload.url AS upload_url,
upload_type_lu.upload_type_id AS upload_type_id,
upload_type_lu.create_user AS upload_type_create_user,
upload_type_lu.create_date AS upload_type_create_date,
Expand Down
20 changes: 20 additions & 0 deletions conf/onlineReviewUpload_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,24 @@
<Value>false</Value>
</Property>
</Config>
<!--
=============== Configuration for File Upload component ===============
-->
<Config name="com.topcoder.servlet.request.LocalStudioFileUpload">
<Property name="single_file_limit">
<Value>-1</Value>
</Property>
<Property name="total_file_limit">
<Value>-1</Value>
</Property>
<Property name="default_dir">
<Value>@studio_file_storage_location@</Value>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderReview When this was deployed, the @studio_file_storage_location@ wasn't replaced with the actual file location. Do you know what else needs to be updated to make that happen?

fyi @cwdcwd

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need the token.properties file to be updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderReview Sorry, coming back to this one. What needs to be set in token.properties? Do you know what value @studio_file_storage_location@ needs to be set to?

</Property>
<Property name="allowed_dirs">
<Value>@studio_file_storage_location@</Value>
</Property>
<Property name="overwrite">
<Value>false</Value>
</Property>
</Config>
</CMConfig>
14 changes: 14 additions & 0 deletions conf/web/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@
</constructor-arg>
</bean>

<bean id="studioFileUpload" class="com.topcoder.servlet.request.LocalFileUpload">
<constructor-arg index="0">
<value>com.topcoder.servlet.request.LocalStudioFileUpload</value>
</constructor-arg>
</bean>

<bean id="userPreferenceHome" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="com.topcoder.web.ejb.user.UserPreferenceHome"/>
<property name="cache" value="true"/>
Expand Down Expand Up @@ -943,21 +949,27 @@
class="com.topcoder.direct.services.view.action.contest.DownloadAllSoftwareSubmissionsAction"
scope="prototype" parent="baseDirectStrutsAction">
<property name="fileUpload" ref="fileUpload"/>
<property name="studioFileUpload" ref="studioFileUpload"/>
<property name="roundType" value="CHECKPOINT" />
<property name="s3Bucket" value="@aws_s3_bucket@"/>
</bean>

<bean id="downloadAllSoftwareFinalSubmissions"
class="com.topcoder.direct.services.view.action.contest.DownloadAllSoftwareSubmissionsAction"
scope="prototype" parent="baseDirectStrutsAction">
<property name="fileUpload" ref="fileUpload"/>
<property name="studioFileUpload" ref="studioFileUpload"/>
<property name="roundType" value="FINAL" />
<property name="s3Bucket" value="@aws_s3_bucket@"/>
</bean>

<bean id="downloadAllCopilotPostingSubmissions"
class="com.topcoder.direct.services.view.action.contest.DownloadAllSoftwareSubmissionsAction"
scope="prototype" parent="baseDirectStrutsAction">
<property name="fileUpload" ref="fileUpload"/>
<property name="studioFileUpload" ref="studioFileUpload"/>
<property name="roundType" value="FINAL" />
<property name="s3Bucket" value="@aws_s3_bucket@"/>
</bean>

<bean id="saveSoftwareCheckpointReviewAction"
Expand All @@ -976,6 +988,8 @@
class="com.topcoder.direct.services.view.action.contest.DownloadSoftwareSubmissionAction"
scope="prototype" parent="baseDirectStrutsAction">
<property name="fileUpload" ref="fileUpload"/>
<property name="studioFileUpload" ref="studioFileUpload"/>
<property name="s3Bucket" value="@aws_s3_bucket@"/>
</bean>

<bean id="downloadFinalFix"
Expand Down
Loading